chatter icon indicating copy to clipboard operation
chatter copied to clipboard

Add condition to message deletion

Open Askancy opened this issue 6 years ago • 0 comments

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?

Askancy avatar May 05 '19 20:05 Askancy