From 016c6e4144a25a8a389af6c71a4969cf90026449 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Tue, 31 Jan 2023 03:18:25 -0700 Subject: [PATCH 1/3] Update SharePipeline, fix ReblogService and undo handling --- app/Jobs/SharePipeline/SharePipeline.php | 2 +- app/Jobs/SharePipeline/UndoSharePipeline.php | 2 +- app/Util/ActivityPub/Inbox.php | 17 +++++++++++++---- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/app/Jobs/SharePipeline/SharePipeline.php b/app/Jobs/SharePipeline/SharePipeline.php index 2cc807acb..528c78ca2 100644 --- a/app/Jobs/SharePipeline/SharePipeline.php +++ b/app/Jobs/SharePipeline/SharePipeline.php @@ -63,7 +63,7 @@ class SharePipeline implements ShouldQueue return true; } - ReblogService::addPostReblog($parent->id, $status->id); + ReblogService::addPostReblog($parent->profile_id, $status->id); $parent->reblogs_count = $parent->reblogs_count + 1; $parent->save(); diff --git a/app/Jobs/SharePipeline/UndoSharePipeline.php b/app/Jobs/SharePipeline/UndoSharePipeline.php index d63f909b3..6d39dfa39 100644 --- a/app/Jobs/SharePipeline/UndoSharePipeline.php +++ b/app/Jobs/SharePipeline/UndoSharePipeline.php @@ -37,7 +37,7 @@ class UndoSharePipeline implements ShouldQueue if($parent) { $target = $parent->profile_id; - ReblogService::removePostReblog($parent->id, $status->id); + ReblogService::removePostReblog($parent->profile_id, $status->id); if($parent->reblogs_count > 0) { $parent->reblogs_count = $parent->reblogs_count - 1; diff --git a/app/Util/ActivityPub/Inbox.php b/app/Util/ActivityPub/Inbox.php index 6b6586433..7ea1eb8af 100644 --- a/app/Util/ActivityPub/Inbox.php +++ b/app/Util/ActivityPub/Inbox.php @@ -37,6 +37,7 @@ use App\Util\ActivityPub\Validator\UndoFollow as UndoFollowValidator; use App\Services\PollService; use App\Services\FollowerService; +use App\Services\ReblogService; use App\Services\StatusService; use App\Services\UserFilterService; use App\Services\NetworkTimelineService; @@ -602,6 +603,8 @@ class Inbox $parent->reblogs_count = $parent->reblogs_count + 1; $parent->save(); + ReblogService::addPostReblog($parent->profile_id, $status->id); + return; } @@ -789,17 +792,23 @@ class Inbox if(is_array($obj) && isset($obj['object'])) { $obj = $obj['object']; } - if(!is_string($obj) || !Helpers::validateLocalUrl($obj)) { + if(!is_string($obj)) { return; } - $status = Status::whereUri($obj)->exists(); + if(Helpers::validateLocalUrl($obj)) { + $parsedId = last(explode('/', $obj)); + $status = Status::find($parsedId); + } else { + $status = Status::whereUri($obj)->first(); + } if(!$status) { return; } Status::whereProfileId($profile->id) ->whereReblogOfId($status->id) - ->forceDelete(); - Notification::whereProfileId($status->profile->id) + ->delete(); + ReblogService::removePostReblog($profile->id, $status->id); + Notification::whereProfileId($status->profile_id) ->whereActorId($profile->id) ->whereAction('share') ->whereItemId($status->reblog_of_id) From a7f583497c3611c3ae0846e4274da0700e17cf6b Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Tue, 31 Jan 2023 03:37:32 -0700 Subject: [PATCH 2/3] Update AP Helpers, fix media validation bug that would reject media with alttext/name longer than 255 chars and store remote alt text if set --- app/Util/ActivityPub/Helpers.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/Util/ActivityPub/Helpers.php b/app/Util/ActivityPub/Helpers.php index 39e7a8bf2..5b18f7565 100644 --- a/app/Util/ActivityPub/Helpers.php +++ b/app/Util/ActivityPub/Helpers.php @@ -101,13 +101,13 @@ class Helpers { 'string', Rule::in($mediaTypes) ], - '*.url' => 'required|url|max:255', + '*.url' => 'required|url', '*.mediaType' => [ 'required', 'string', Rule::in($mimeTypes) ], - '*.name' => 'sometimes|nullable|string|max:255' + '*.name' => 'sometimes|nullable|string' ])->passes(); return $valid; @@ -665,12 +665,13 @@ class Helpers { foreach($attachments as $media) { $type = $media['mediaType']; $url = $media['url']; - $blurhash = isset($media['blurhash']) ? $media['blurhash'] : null; - $license = isset($media['license']) ? License::nameToId($media['license']) : null; $valid = self::validateUrl($url); if(in_array($type, $allowed) == false || $valid == false) { continue; } + $blurhash = isset($media['blurhash']) ? $media['blurhash'] : null; + $license = isset($media['license']) ? License::nameToId($media['license']) : null; + $caption = $media['name'] ? Purify::clean($media['name']) : null; $media = new Media(); $media->blurhash = $blurhash; @@ -680,6 +681,7 @@ class Helpers { $media->user_id = null; $media->media_path = $url; $media->remote_url = $url; + $media->caption = $caption; if($license) { $media->license = $license; } From 4be9d0f65f2fcf8f7d69ba78d341a52140c8690b Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Tue, 31 Jan 2023 03:38:14 -0700 Subject: [PATCH 3/3] Update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 95b4820af..fb4dec539 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -86,6 +86,8 @@ - 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)) +- Update SharePipeline, fix ReblogService and undo handling ([016c6e41](https://github.com/pixelfed/pixelfed/commit/016c6e41)) +- Update AP Helpers, fix media validation bug that would reject media with alttext/name longer than 255 chars and store remote alt text if set ([a7f58349](https://github.com/pixelfed/pixelfed/commit/a7f58349)) - ([](https://github.com/pixelfed/pixelfed/commit/)) ## [v0.11.4 (2022-10-04)](https://github.com/pixelfed/pixelfed/compare/v0.11.3...v0.11.4)