Skip to content
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

Add condition to message deletion #246

Open
Askancy opened this issue May 5, 2019 · 0 comments
Open

Add condition to message deletion #246

Askancy opened this issue May 5, 2019 · 0 comments

Comments

@Askancy
Copy link

Askancy commented May 5, 2019

Hi, I just installed Chatter in my Laravel 5.7 and wanted to include moderation features.
In my configuration the permissions are:

$user->role 1 -> user
$user->role 2 -> editor
$user->role 3 -> moderator
$user->role 4 -> admin

I have seen that only the message owner can modify or delete the message and if I have not seen badly, it is the function destroy in ChatterPostController.php

        $post = Models::post()->with('discussion','user')->findOrFail($id);

        if ($request->user()->id !== (int) $post->user_id && $request->user()->role === '1') {
            return redirect('/'.config('chatter.routes.home'))->with([
                'chatter_alert_type' => 'danger',
                'chatter_alert'      => trans('chatter::alert.danger.reason.destroy_post'),
            ]);
        }

        if ($post->discussion->posts()->oldest()->first()->id === $post->id || $post->user->role === '4') {
            if(config('chatter.soft_deletes')) {
                $post->discussion->posts()->delete();
                $post->discussion()->delete();
            } else {
                $post->discussion->posts()->forceDelete();
                $post->discussion()->forceDelete();
            }

            return redirect('/'.config('chatter.routes.home'))->with([
                'chatter_alert_type' => 'success',
                'chatter_alert'      => trans('chatter::alert.success.reason.destroy_post'),
            ]);
        }

But if I have messages in the topic:

ID 1
ID 1
ID 7

(And I'm ID 7)

when I delete the second ID1 message, my message (ID7) is also deleted.

Is it possible that there is no integrated moderation system in the forum system?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant