Skip to content

Commit 9476255

Browse files
authored
Merge pull request #10 from 7span/imp/send-message-event
Implement: configration for the trigger the event for the send message
2 parents 12a4845 + 5a83f66 commit 9476255

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

config/chat.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,8 @@
1111
| Chat file directory
1212
|
1313
*/
14-
'media_folder' => env('CHAT_MEDIA_FOLDER', 'image')
14+
'media_folder' => env('CHAT_MEDIA_FOLDER', 'image'),
15+
'pusher_event_trigger' => [
16+
'send_message' => env('CHAT_SEND_MESSAGE_PUSHER_EVENT', true)
17+
]
1518
];

src/Message.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ public function send(int $userId, int $channelId, array $data, array $variables
7272

7373
$message = MessageModel::with(['channel', 'sender', 'variables'])->find($message->id);
7474

75-
broadcast(new SendMessage($channel->slug, $message))->toOthers();
75+
if(config('chat.pusher_event_trigger.send_message')){
76+
broadcast(new SendMessage($channel->slug, $message))->toOthers();
77+
}
7678

7779
// Added the unread message count
7880
ChannelUser::where('channel_id', $channelId)->where('user_id', '!=', $userId)->increment('unread_message_count', 1, ['updated_by' => $userId]);

0 commit comments

Comments
 (0)