johnDoe220's avatar

BUG IN DISCUSSION

Hello, there is a bug in the answer question and that is that when I answer my own question, a notification is sent to me. https://postimg.cc/9ry7n4xN

0 likes
9 replies
LaryAI's avatar
Level 58

This issue can be resolved by disabling the notification for the user when they answer their own question. To do this, you can add the following code to the DiscussionController:

public function store(Request $request)
{
    $discussion = Discussion::create([
        'title' => $request->title,
        'content' => $request->content,
        'user_id' => Auth::id(),
        'channel_id' => $request->channel_id
    ]);

    if (Auth::id() == $discussion->user_id) {
        $discussion->notify(new NewDiscussion($discussion, false));
    } else {
        $discussion->notify(new NewDiscussion($discussion));
    }

    return redirect()->route('discussions.show', $discussion->slug);
}

The notify() method takes a second argument which is a boolean value. By setting this to false, the notification will not be sent to the user who created the discussion.

soufyaneyassin's avatar

there is a bug (well not a bug just a missing functionality..) in the number of views as well, whenever i refresh the page the count of views increments...

johnDoe220's avatar

@soufyaneyassin Yes, if you are not the creator of the answer, one visit will be added with each refresh. Of course, this bug was fixed for a while, but it came back again! I do not know the reason

kokoshneta's avatar

This has been reported by several members before, myself included.

But @jeffreyway it still applies – a member’s interaction with their own questions (views, replies, mentions, best answers) should not count in aggregation or trigger notifications.

_adrian's avatar

Okay thanks for letting me know. I pushed this on to Jeffrey so he can take a look whenever he has some time 👾

_adrian's avatar

This should likely be fixed by now, btw. 👌

kokoshneta's avatar

@_adrian Doesn’t seem to be.

I just replied to a question of my own (commenting on Lary’s answer) and immediately not a notification icon about it when I refreshed the page.

No e-mail, though, which is a good start!

Please or to participate in this conversation.