Merge pull request #4137 from pixelfed/staging

Update SharePipeline, fix ReblogService and undo handling
This commit is contained in:
daniel 2023-01-31 03:38:50 -07:00 committed by GitHub
commit 3e89d8b273
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 10 deletions

View file

@ -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)

View file

@ -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();

View file

@ -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;

View file

@ -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;
}

View file

@ -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)