1
0
Fork 0

Merge pull request #3235 from pixelfed/staging

Staging
This commit is contained in:
daniel 2022-02-13 00:32:54 -07:00 committed by GitHub
commit 8707e00c74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 16 deletions

View File

@ -44,6 +44,8 @@
- Updated filesystems config, set S3 visibility to public by default. Fixes #2913. ([49a53c27](https://github.com/pixelfed/pixelfed/commit/49a53c27)) - Updated filesystems config, set S3 visibility to public by default. Fixes #2913. ([49a53c27](https://github.com/pixelfed/pixelfed/commit/49a53c27))
- Updated CommentPipeline, improve parent reply_count calculation. ([ccc94802](https://github.com/pixelfed/pixelfed/commit/ccc94802)) - Updated CommentPipeline, improve parent reply_count calculation. ([ccc94802](https://github.com/pixelfed/pixelfed/commit/ccc94802))
- Updated StatusTagsPipeline, process federated hashtags and mentions ([a84b1736](https://github.com/pixelfed/pixelfed/commit/a84b1736)) - Updated StatusTagsPipeline, process federated hashtags and mentions ([a84b1736](https://github.com/pixelfed/pixelfed/commit/a84b1736))
- Updated Inbox, fix undo announce. ([cf286fb0](https://github.com/pixelfed/pixelfed/commit/cf286fb0))
- Updated ApiV1Controller, improve favourites endpoint. ([151dc17c](https://github.com/pixelfed/pixelfed/commit/151dc17c))
- ([](https://github.com/pixelfed/pixelfed/commit/)) - ([](https://github.com/pixelfed/pixelfed/commit/))
## [v0.11.2 (2022-01-09)](https://github.com/pixelfed/pixelfed/compare/v0.11.1...v0.11.2) ## [v0.11.2 (2022-01-09)](https://github.com/pixelfed/pixelfed/compare/v0.11.1...v0.11.2)

View File

@ -1026,33 +1026,45 @@ class ApiV1Controller extends Controller
$user = $request->user(); $user = $request->user();
$status = Status::findOrFail($id); $status = StatusService::getMastodon($id, false);
if($status->profile_id !== $user->profile_id) { abort_unless($status, 400);
if($status->scope == 'private') {
abort_if(!$status->profile->followedBy($user->profile), 403); $spid = $status['account']['id'];
if($spid !== $user->profile_id) {
if($status['visibility'] == 'private') {
abort_if(!FollowerService::follows($user->profile_id, $spid), 403);
} else { } else {
abort_if(!in_array($status->scope, ['public','unlisted']), 403); abort_if(!in_array($status['visibility'], ['public','unlisted']), 403);
} }
} }
abort_if(
Like::whereProfileId($user->profile_id)
->where('created_at', '>', now()->subDay())
->count() >= 100,
429
);
$like = Like::firstOrCreate([ $like = Like::firstOrCreate([
'profile_id' => $user->profile_id, 'profile_id' => $user->profile_id,
'status_id' => $status->id 'status_id' => $status['id']
]); ]);
if($like->wasRecentlyCreated == true) { if($like->wasRecentlyCreated == true) {
$like->status_profile_id = $status->profile_id; $like->status_profile_id = $spid;
$like->is_comment = !empty($status->in_reply_to_id); $like->is_comment = !empty($status['in_reply_to_id']);
$like->save(); $like->save();
$status->likes_count = $status->likes()->count(); Status::findOrFail($status['id'])->update([
$status->save(); 'favourites_count' => ($status['favourites_count'] ?? 0) + 1
]);
LikePipeline::dispatch($like); LikePipeline::dispatch($like);
} }
$res = StatusService::getMastodon($status->id, false); $status['favourited'] = true;
$res['favourited'] = true; $status['favourites_count'] = $status['favourites_count'] + 1;
return response()->json($res); return response()->json($status);
} }
/** /**

View File

@ -114,6 +114,10 @@ class Inbox
$this->handleStoryReplyActivity(); $this->handleStoryReplyActivity();
break; break;
// case 'Update':
// (new UpdateActivity($this->payload, $this->profile))->handle();
// break;
default: default:
// TODO: decide how to handle invalid verbs. // TODO: decide how to handle invalid verbs.
break; break;
@ -688,11 +692,13 @@ class Inbox
break; break;
case 'Announce': case 'Announce':
if(is_array($obj) && isset($obj['object'])) {
$obj = $obj['object']; $obj = $obj['object'];
if(!Helpers::validateLocalUrl($obj)) { }
if(!is_string($obj) || !Helpers::validateLocalUrl($obj)) {
return; return;
} }
$status = Helpers::statusFetch($obj); $status = Status::whereUri($obj)->exists();
if(!$status) { if(!$status) {
return; return;
} }