-
-
Notifications
You must be signed in to change notification settings - Fork 844
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(permission): add delete own posts permission #3784
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
One thing I'd like us to make consistent is the key
of the permission and locale label. Let's make tem consistent and use allow_hide_own_posts
for te permission key AND the label allow_hide_own_posts_label
, andeplace any allow_delete_own_posts
@@ -71,6 +71,14 @@ public function edit(User $actor, Post $post) | |||
*/ | |||
public function hide(User $actor, Post $post) | |||
{ | |||
return $this->edit($actor, $post); | |||
if ($post->user_id == $actor->id && (! $post->hidden_at || $post->hidden_user_id == $actor->id) && $actor->can('reply', $post->discussion)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should drop the bit about only being able to hide when the discussion is still open 🤔
if ($post->user_id == $actor->id && (! $post->hidden_at || $post->hidden_user_id == $actor->id) && $actor->can('reply', $post->discussion)) { | |
if ($post->user_id == $actor->id && (! $post->hidden_at || $post->hidden_user_id == $actor->id)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to keep the behavior close to the post-editing one for consistency so that's why that's there! I was wondering if it would be necessary or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, not sure, let's keep it as is for now, then we'll see I guess unless other core devs have an opinion on is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer to keep it. If a user can't participate in a discussion going forward, i don't think they should be able to participate retroactively either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, left a few comments though.
: app.translator.trans('core.admin.permissions_controls.allow_indefinitely_button'), | ||
key: 'allow_hide_own_posts', | ||
options: [ | ||
{ value: '-1', label: app.translator.trans('core.admin.permissions_controls.allow_indefinitely_button') }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps this should be extracted into a util? Although probably not, if we restructure the permissions system during 2.0, that would become redundant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we will end up restructuring it in 2.0, we need some brainstorming .
Fixes https://discuss.flarum.org/d/31993-adding-permission-to-delete-own-posts
Changes proposed in this pull request:
Reviewers should focus on:
Screenshot
Necessity
Confirmed
composer test
).Required changes:
None