Update ComposeController, add parental controls support

This commit is contained in:
Daniel Supernault 2024-01-11 04:40:25 -07:00
parent 1a16ec2078
commit 2dcfc81495
No known key found for this signature in database
GPG key ID: 23740873EE6F76A1
2 changed files with 661 additions and 630 deletions

View file

@ -1750,6 +1750,8 @@ class ApiV1Controller extends Controller
]); ]);
$user = $request->user(); $user = $request->user();
abort_if($user->has_roles && !UserRoleService::can('can-post', $user->id), 403, 'Invalid permissions for this action');
AccountService::setLastActive($user->id); AccountService::setLastActive($user->id);
$media = Media::whereUserId($user->id) $media = Media::whereUserId($user->id)
@ -2983,6 +2985,15 @@ class ApiV1Controller extends Controller
$in_reply_to_id = $request->input('in_reply_to_id'); $in_reply_to_id = $request->input('in_reply_to_id');
$user = $request->user(); $user = $request->user();
if($user->has_roles) {
if($in_reply_to_id != null) {
abort_if(!UserRoleService::can('can-comment', $user->id), 403, 'Invalid permissions for this action');
} else {
abort_if(!UserRoleService::can('can-post', $user->id), 403, 'Invalid permissions for this action');
}
}
$profile = $user->profile; $profile = $user->profile;
$limitKey = 'compose:rate-limit:store:' . $user->id; $limitKey = 'compose:rate-limit:store:' . $user->id;

File diff suppressed because it is too large Load diff