forked from mirror/pixelfed
Merge pull request #1459 from pixelfed/frontend-ui-refactor
Frontend ui refactor
This commit is contained in:
commit
052edb8cbc
|
@ -191,7 +191,6 @@ class AccountController extends Controller
|
|||
|
||||
$pid = $user->id;
|
||||
Cache::forget("user:filter:list:$pid");
|
||||
Cache::forget("feature:discover:people:$pid");
|
||||
Cache::forget("feature:discover:posts:$pid");
|
||||
Cache::forget("api:local:exp:rec:$pid");
|
||||
|
||||
|
@ -242,7 +241,6 @@ class AccountController extends Controller
|
|||
|
||||
$pid = $user->id;
|
||||
Cache::forget("user:filter:list:$pid");
|
||||
Cache::forget("feature:discover:people:$pid");
|
||||
Cache::forget("feature:discover:posts:$pid");
|
||||
Cache::forget("api:local:exp:rec:$pid");
|
||||
|
||||
|
@ -296,7 +294,6 @@ class AccountController extends Controller
|
|||
|
||||
$pid = $user->id;
|
||||
Cache::forget("user:filter:list:$pid");
|
||||
Cache::forget("feature:discover:people:$pid");
|
||||
Cache::forget("feature:discover:posts:$pid");
|
||||
Cache::forget("api:local:exp:rec:$pid");
|
||||
|
||||
|
@ -348,7 +345,6 @@ class AccountController extends Controller
|
|||
|
||||
$pid = $user->id;
|
||||
Cache::forget("user:filter:list:$pid");
|
||||
Cache::forget("feature:discover:people:$pid");
|
||||
Cache::forget("feature:discover:posts:$pid");
|
||||
Cache::forget("api:local:exp:rec:$pid");
|
||||
|
||||
|
|
|
@ -61,8 +61,6 @@ class FollowPipeline implements ShouldQueue
|
|||
$notification->item_type = "App\Profile";
|
||||
$notification->save();
|
||||
|
||||
Cache::forever('notification.'.$notification->id, $notification);
|
||||
Cache::forget('feature:discover:people:'.$actor->id);
|
||||
$redis = Redis::connection();
|
||||
|
||||
$nkey = config('cache.prefix').':user.'.$target->id.'.notifications';
|
||||
|
|
|
@ -2,16 +2,13 @@
|
|||
|
||||
namespace App\Jobs\SharePipeline;
|
||||
|
||||
use App\Status;
|
||||
use App\Notification;
|
||||
use Cache;
|
||||
use Cache, Log, Redis;
|
||||
use App\{Status, Notification};
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Log;
|
||||
use Redis;
|
||||
|
||||
class SharePipeline implements ShouldQueue
|
||||
{
|
||||
|
@ -74,8 +71,6 @@ class SharePipeline implements ShouldQueue
|
|||
$notification->item_type = "App\Status";
|
||||
$notification->save();
|
||||
|
||||
Cache::forever('notification.'.$notification->id, $notification);
|
||||
|
||||
$redis = Redis::connection();
|
||||
$key = config('cache.prefix').':user.'.$status->profile_id.'.notifications';
|
||||
$redis->lpush($key, $notification->id);
|
||||
|
|
|
@ -403,7 +403,10 @@ class Helpers {
|
|||
return;
|
||||
}
|
||||
$domain = parse_url($res['id'], PHP_URL_HOST);
|
||||
$username = Purify::clean($res['preferredUsername']);
|
||||
$username = (string) Purify::clean($res['preferredUsername']);
|
||||
if(empty($username)) {
|
||||
return;
|
||||
}
|
||||
$remoteUsername = "@{$username}@{$domain}";
|
||||
|
||||
abort_if(!self::validateUrl($res['inbox']), 400);
|
||||
|
@ -414,7 +417,7 @@ class Helpers {
|
|||
if(!$profile) {
|
||||
$profile = new Profile;
|
||||
$profile->domain = $domain;
|
||||
$profile->username = Purify::clean($remoteUsername);
|
||||
$profile->username = (string) Purify::clean($remoteUsername);
|
||||
$profile->name = Purify::clean($res['name']) ?? 'user';
|
||||
$profile->bio = Purify::clean($res['summary']);
|
||||
$profile->sharedInbox = isset($res['endpoints']) && isset($res['endpoints']['sharedInbox']) ? $res['endpoints']['sharedInbox'] : null;
|
||||
|
|
|
@ -0,0 +1,86 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use App\Util\ActivityPub\Helpers;
|
||||
|
||||
class APAnnounceStrategyTest extends TestCase
|
||||
{
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->invalid = [
|
||||
'id' => 'test',
|
||||
'type' => 'Announce',
|
||||
'actor' => null,
|
||||
'published' => '',
|
||||
'to' => ['test'],
|
||||
'cc' => 'test',
|
||||
'object' => 'test'
|
||||
];
|
||||
|
||||
$this->mastodon = json_decode('{"@context":["https://www.w3.org/ns/activitystreams","https://w3id.org/security/v1",{"manuallyApprovesFollowers":"as:manuallyApprovesFollowers","sensitive":"as:sensitive","movedTo":{"@id":"as:movedTo","@type":"@id"},"Hashtag":"as:Hashtag","ostatus":"http://ostatus.org#","atomUri":"ostatus:atomUri","inReplyToAtomUri":"ostatus:inReplyToAtomUri","conversation":"ostatus:conversation","toot":"http://joinmastodon.org/ns#","Emoji":"toot:Emoji","focalPoint":{"@container":"@list","@id":"toot:focalPoint"},"featured":{"@id":"toot:featured","@type":"@id"},"schema":"http://schema.org#","PropertyValue":"schema:PropertyValue","value":"schema:value"}],"id":"https://mastodon.social/users/dansup/statuses/100784657480587830/activity","type":"Announce","actor":"https://mastodon.social/users/dansup","published":"2018-09-25T05:03:49Z","to":["https://www.w3.org/ns/activitystreams#Public"],"cc":["https://pleroma.site/users/pixeldev","https://mastodon.social/users/dansup/followers"],"object":"https://pleroma.site/objects/68b5c876-f52b-4819-8d81-de6839d73fbc","atomUri":"https://mastodon.social/users/dansup/statuses/100784657480587830/activity"}', true);
|
||||
|
||||
$this->pleroma = json_decode('{"@context":"https://www.w3.org/ns/activitystreams","actor":"https://pleroma.site/users/pixeldev","cc":["https://www.w3.org/ns/activitystreams#Public"],"context":"tag:mastodon.social,2018-10-14:objectId=59146153:objectType=Conversation","context_id":12325955,"id":"https://pleroma.site/activities/db2273eb-d504-4e3a-8f74-c343d069755a","object":"https://mastodon.social/users/dansup/statuses/100891324792793720","published":"2018-10-14T01:22:18.554227Z","to":["https://pleroma.site/users/pixeldev/followers","https://mastodon.social/users/dansup"],"type":"Announce"}', true);
|
||||
}
|
||||
|
||||
public function testBasicValidation()
|
||||
{
|
||||
$this->assertFalse(Helpers::validateObject($this->invalid));
|
||||
}
|
||||
|
||||
public function testMastodonValidation()
|
||||
{
|
||||
$this->assertTrue(Helpers::validateObject($this->mastodon));
|
||||
}
|
||||
|
||||
public function testPleromaValidation()
|
||||
{
|
||||
$this->assertTrue(Helpers::validateObject($this->pleroma));
|
||||
}
|
||||
|
||||
public function testMastodonAudienceScope()
|
||||
{
|
||||
$scope = Helpers::normalizeAudience($this->mastodon, false);
|
||||
$actual = [
|
||||
"to" => [],
|
||||
"cc" => [
|
||||
"https://pleroma.site/users/pixeldev",
|
||||
"https://mastodon.social/users/dansup/followers",
|
||||
],
|
||||
"scope" => "public",
|
||||
];
|
||||
|
||||
$this->assertEquals($scope, $actual);
|
||||
}
|
||||
|
||||
public function testPleromaAudienceScope()
|
||||
{
|
||||
$scope = Helpers::normalizeAudience($this->pleroma, false);
|
||||
$actual = [
|
||||
"to" => [
|
||||
"https://pleroma.site/users/pixeldev/followers",
|
||||
"https://mastodon.social/users/dansup",
|
||||
],
|
||||
"cc" => [],
|
||||
"scope" => "unlisted",
|
||||
];
|
||||
|
||||
$this->assertEquals($scope, $actual);
|
||||
}
|
||||
|
||||
public function testInvalidAudienceScope()
|
||||
{
|
||||
$scope = Helpers::normalizeAudience($this->invalid, false);
|
||||
$actual = [
|
||||
'to' => [],
|
||||
'cc' => [],
|
||||
'scope' => 'private'
|
||||
];
|
||||
$this->assertEquals($scope, $actual);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use App\Util\ActivityPub\Helpers;
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
|
||||
class RemoteFollowTest extends TestCase
|
||||
{
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->mastodon = '{"type":"Follow","signature":{"type":"RsaSignature2017","signatureValue":"Kn1/UkAQGJVaXBfWLAHcnwHg8YMAUqlEaBuYLazAG+pz5hqivsyrBmPV186Xzr+B4ZLExA9+SnOoNx/GOz4hBm0kAmukNSILAsUd84tcJ2yT9zc1RKtembK4WiwOw7li0+maeDN0HaB6t+6eTqsCWmtiZpprhXD8V1GGT8yG7X24fQ9oFGn+ng7lasbcCC0988Y1eGqNe7KryxcPuQz57YkDapvtONzk8gyLTkZMV4De93MyRHq6GVjQVIgtiYabQAxrX6Q8C+4P/jQoqdWJHEe+MY5JKyNaT/hMPt2Md1ok9fZQBGHlErk22/zy8bSN19GdG09HmIysBUHRYpBLig==","creator":"http://mastodon.example.org/users/admin#main-key","created":"2018-02-17T13:29:31Z"},"object":"http://localtesting.pleroma.lol/users/lain","nickname":"lain","id":"http://mastodon.example.org/users/admin#follows/2","actor":"http://mastodon.example.org/users/admin","@context":["https://www.w3.org/ns/activitystreams","https://w3id.org/security/v1",{"toot":"http://joinmastodon.org/ns#","sensitive":"as:sensitive","ostatus":"http://ostatus.org#","movedTo":"as:movedTo","manuallyApprovesFollowers":"as:manuallyApprovesFollowers","inReplyToAtomUri":"ostatus:inReplyToAtomUri","conversation":"ostatus:conversation","atomUri":"ostatus:atomUri","Hashtag":"as:Hashtag","Emoji":"toot:Emoji"}]}';
|
||||
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function validateMastodonFollowObject()
|
||||
{
|
||||
$mastodon = json_decode($this->mastodon, true);
|
||||
$mastodon = Helpers::validateObject($mastodon);
|
||||
$this->assertTrue($mastodon);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue