Merge pull request #4136 from pixelfed/staging

Staging
This commit is contained in:
daniel 2023-01-31 02:34:40 -07:00 committed by GitHub
commit df52422b4a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 66 additions and 126 deletions

View file

@ -84,6 +84,8 @@
- Update AdminApiController, fix postgres support ([84fb59d0](https://github.com/pixelfed/pixelfed/commit/84fb59d0)) - Update AdminApiController, fix postgres support ([84fb59d0](https://github.com/pixelfed/pixelfed/commit/84fb59d0))
- Update StatusReplyPipeline, fix comment counts ([164aa577](https://github.com/pixelfed/pixelfed/commit/164aa577)) - Update StatusReplyPipeline, fix comment counts ([164aa577](https://github.com/pixelfed/pixelfed/commit/164aa577))
- Update ComposeModal, add Alt Text button to caption screen ([4db48188](https://github.com/pixelfed/pixelfed/commit/4db48188)) - Update ComposeModal, add Alt Text button to caption screen ([4db48188](https://github.com/pixelfed/pixelfed/commit/4db48188))
- Update AccountService, fix actor cache invalidation ([498b46f7](https://github.com/pixelfed/pixelfed/commit/498b46f7))
- Update SharePipeline, fix share handling and notification generation ([83e1e203](https://github.com/pixelfed/pixelfed/commit/83e1e203))
- ([](https://github.com/pixelfed/pixelfed/commit/)) - ([](https://github.com/pixelfed/pixelfed/commit/))
## [v0.11.4 (2022-10-04)](https://github.com/pixelfed/pixelfed/compare/v0.11.3...v0.11.4) ## [v0.11.4 (2022-10-04)](https://github.com/pixelfed/pixelfed/compare/v0.11.3...v0.11.4)

View file

@ -2814,9 +2814,7 @@ class ApiV1Controller extends Controller
'visibility' => 'public' 'visibility' => 'public'
]); ]);
if($share->wasRecentlyCreated == true) { SharePipeline::dispatch($share)->onQueue('low');
SharePipeline::dispatch($share);
}
StatusService::del($status->id); StatusService::del($status->id);
ReblogService::add($user->profile_id, $status->id); ReblogService::add($user->profile_id, $status->id);
@ -2858,7 +2856,7 @@ class ApiV1Controller extends Controller
return $this->json($res); return $this->json($res);
} }
UndoSharePipeline::dispatch($reblog); UndoSharePipeline::dispatch($reblog)->onQueue('low');
ReblogService::del($user->profile_id, $status->id); ReblogService::del($user->profile_id, $status->id);
$res = StatusService::getMastodon($status->id); $res = StatusService::getMastodon($status->id);

View file

@ -31,7 +31,7 @@ class BookmarkController extends Controller
abort_if( abort_if(
$profile->id !== $status->profile_id && !FollowerService::follows($profile->id, $status->profile_id), $profile->id !== $status->profile_id && !FollowerService::follows($profile->id, $status->profile_id),
404, 404,
'Error: Cannot bookmark private posts from accounts you do not follow.' 'Error: You cannot bookmark private posts from accounts you do not follow.'
); );
} }

View file

@ -58,47 +58,32 @@ class SharePipeline implements ShouldQueue
return; return;
} }
$exists = Notification::whereProfileId($target->id)
->whereActorId($status->profile_id)
->whereAction('share')
->whereItemId($status->reblog_of_id)
->whereItemType('App\Status')
->exists();
if($target->id === $status->profile_id) { if($target->id === $status->profile_id) {
$this->remoteAnnounceDeliver(); $this->remoteAnnounceDeliver();
return true; return true;
} }
if($exists === true) {
return true;
}
$this->remoteAnnounceDeliver();
ReblogService::addPostReblog($parent->id, $status->id); ReblogService::addPostReblog($parent->id, $status->id);
$parent->reblogs_count = $parent->shares()->count(); $parent->reblogs_count = $parent->reblogs_count + 1;
$parent->save(); $parent->save();
StatusService::del($parent->id); StatusService::del($parent->id);
try { Notification::firstOrCreate(
$notification = new Notification; [
$notification->profile_id = $target->id; 'profile_id' => $target->id,
$notification->actor_id = $actor->id; 'actor_id' => $actor->id,
$notification->action = 'share'; 'action' => 'share',
$notification->message = $status->shareToText(); 'item_type' => 'App\Status',
$notification->rendered = $status->shareToHtml(); 'item_id' => $status->reblog_of_id ?? $status->id,
$notification->item_id = $status->reblog_of_id ?? $status->id; ],
$notification->item_type = "App\Status"; [
$notification->save(); 'message' => $status->shareToText(),
'rendered' => $status->shareToHtml()
]
);
$redis = Redis::connection(); return $this->remoteAnnounceDeliver();
$key = config('cache.prefix').':user.'.$status->profile_id.'.notifications';
$redis->lpush($key, $notification->id);
} catch (Exception $e) {
Log::error($e);
}
} }
public function remoteAnnounceDeliver() public function remoteAnnounceDeliver()

View file

@ -33,35 +33,39 @@ class UndoSharePipeline implements ShouldQueue
{ {
$status = $this->status; $status = $this->status;
$actor = $status->profile; $actor = $status->profile;
$parent = $status->parent(); $parent = Status::find($status->reblog_of_id);
$target = $status->parent()->profile;
ReblogService::removePostReblog($parent->id, $status->id); if($parent) {
$target = $parent->profile_id;
ReblogService::removePostReblog($parent->id, $status->id);
if ($status->uri !== null) { if($parent->reblogs_count > 0) {
$parent->reblogs_count = $parent->reblogs_count - 1;
$parent->save();
StatusService::del($parent->id);
}
$notification = Notification::whereProfileId($target)
->whereActorId($status->profile_id)
->whereAction('share')
->whereItemId($status->reblog_of_id)
->whereItemType('App\Status')
->first();
if($notification) {
$notification->forceDelete();
}
}
if ($status->uri != null) {
return; return;
} }
if($target->domain === null) { if(config_cache('federation.activitypub.enabled') == false) {
Notification::whereProfileId($target->id) return $status->delete();
->whereActorId($status->profile_id) } else {
->whereAction('share') return $this->remoteAnnounceDeliver();
->whereItemId($status->reblog_of_id)
->whereItemType('App\Status')
->delete();
} }
$this->remoteAnnounceDeliver();
if($parent->reblogs_count > 0) {
$parent->reblogs_count = $parent->reblogs_count - 1;
$parent->save();
StatusService::del($parent->id);
}
$status->forceDelete();
return 1;
} }
public function remoteAnnounceDeliver() public function remoteAnnounceDeliver()
@ -124,5 +128,8 @@ class UndoSharePipeline implements ShouldQueue
$promise->wait(); $promise->wait();
$status->delete();
return 1;
} }
} }

View file

@ -16,7 +16,7 @@ class Notification extends Model
*/ */
protected $dates = ['deleted_at']; protected $dates = ['deleted_at'];
protected $fillable = ['*']; protected $guarded = [];
public function actor() public function actor()
{ {

View file

@ -569,13 +569,9 @@ class Inbox
return; return;
} }
if(Helpers::validateLocalUrl($activity) == false) {
return;
}
$parent = Helpers::statusFetch($activity); $parent = Helpers::statusFetch($activity);
if(empty($parent)) { if(!$parent || empty($parent)) {
return; return;
} }
@ -590,15 +586,18 @@ class Inbox
'type' => 'share' 'type' => 'share'
]); ]);
Notification::firstOrCreate([ Notification::firstOrCreate(
'profile_id' => $parent->profile->id, [
'actor_id' => $actor->id, 'profile_id' => $parent->profile_id,
'action' => 'share', 'actor_id' => $actor->id,
'message' => $status->replyToText(), 'action' => 'share',
'rendered' => $status->replyToHtml(), 'item_id' => $parent->id,
'item_id' => $parent->id, 'item_type' => 'App\Status',
'item_type' => 'App\Status' ], [
]); 'message' => $status->replyToText(),
'rendered' => $status->replyToHtml(),
]
);
$parent->reblogs_count = $parent->reblogs_count + 1; $parent->reblogs_count = $parent->reblogs_count + 1;
$parent->save(); $parent->save();

View file

@ -11,18 +11,15 @@ class Announce {
{ {
$valid = Validator::make($payload, [ $valid = Validator::make($payload, [
'@context' => 'required', '@context' => 'required',
'id' => 'required|string', 'id' => 'required|url',
'type' => [ 'type' => [
'required', 'required',
Rule::in(['Announce']) Rule::in(['Announce'])
], ],
'actor' => 'required|url', 'actor' => 'required|url',
'published' => 'required|date',
'to' => 'required',
'cc' => 'required',
'object' => 'required|url' 'object' => 'required|url'
])->passes(); ])->passes();
return $valid; return $valid;
} }
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 333 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 330 B

View file

@ -53,22 +53,6 @@ class AnnounceTest extends TestCase
'object' => 'https://example.org/p/bob/100000000000000', 'object' => 'https://example.org/p/bob/100000000000000',
]; ];
$this->invalidDate = [
'@context' => 'https://www.w3.org/ns/activitystreams',
'id' => 'https://example.org/users/alice/statuses/100000000000001/activity',
'type' => 'Announce',
'actor' => 'https://example.org/users/alice',
'published' => '2018-12-31T23:59:59ZEZE',
'to' => [
'https://www.w3.org/ns/activitystreams#Public'
],
'cc' => [
'https://example.org/users/bob',
'https://example.org/users/alice/followers'
],
'object' => 'https://example.org/p/bob/100000000000000',
];
$this->contextMissing = [ $this->contextMissing = [
'id' => 'https://example.org/users/alice/statuses/100000000000001/activity', 'id' => 'https://example.org/users/alice/statuses/100000000000001/activity',
'type' => 'Announce', 'type' => 'Announce',
@ -84,25 +68,6 @@ class AnnounceTest extends TestCase
'object' => 'https://example.org/p/bob/100000000000000', 'object' => 'https://example.org/p/bob/100000000000000',
]; ];
$this->audienceMissing = [
'id' => 'https://example.org/users/alice/statuses/100000000000001/activity',
'type' => 'Announce',
'actor' => 'https://example.org/users/alice',
'published' => '2018-12-31T23:59:59Z',
'object' => 'https://example.org/p/bob/100000000000000',
];
$this->audienceMissing2 = [
'@context' => 'https://www.w3.org/ns/activitystreams',
'id' => 'https://example.org/users/alice/statuses/100000000000001/activity',
'type' => 'Announce',
'actor' => 'https://example.org/users/alice',
'published' => '2018-12-31T23:59:59Z',
'to' => null,
'cc' => null,
'object' => 'https://example.org/p/bob/100000000000000',
];
$this->invalidActor = [ $this->invalidActor = [
'@context' => 'https://www.w3.org/ns/activitystreams', '@context' => 'https://www.w3.org/ns/activitystreams',
'id' => 'https://example.org/users/alice/statuses/100000000000001/activity', 'id' => 'https://example.org/users/alice/statuses/100000000000001/activity',
@ -185,25 +150,12 @@ class AnnounceTest extends TestCase
$this->assertFalse(Announce::validate($this->invalidAnnounce)); $this->assertFalse(Announce::validate($this->invalidAnnounce));
} }
/** @test */
public function invalid_date()
{
$this->assertFalse(Announce::validate($this->invalidDate));
}
/** @test */ /** @test */
public function context_missing() public function context_missing()
{ {
$this->assertFalse(Announce::validate($this->contextMissing)); $this->assertFalse(Announce::validate($this->contextMissing));
} }
/** @test */
public function audience_missing()
{
$this->assertFalse(Announce::validate($this->audienceMissing));
$this->assertFalse(Announce::validate($this->audienceMissing2));
}
/** @test */ /** @test */
public function invalid_actor() public function invalid_actor()
{ {