mirror of
https://gh.llkk.cc/https://github.com/LJPc-solutions/freescout-internal-conversations-module.git
synced 2025-10-03 16:50:57 +08:00
fix: notification bugs for thumbs up and tagged users
This commit is contained in:
parent
647a689e39
commit
7b041b0e4f
2 changed files with 15 additions and 2 deletions
|
@ -91,6 +91,9 @@ class UsersController extends Controller {
|
|||
$connectedUsers[] = (string) $userId;
|
||||
$conversation->setMeta( 'internal_conversations.users', $connectedUsers );
|
||||
$conversation->save();
|
||||
|
||||
// Register subscription for the added user
|
||||
\App\Subscription::registerEvent( \Modules\InternalConversations\Providers\InternalConversationsServiceProvider::EVENT_IC_NEW_REPLY, $conversation, $userId );
|
||||
|
||||
return Response::json( [ 'status' => 'success', 'connected_users' => $connectedUsers ] );
|
||||
}
|
||||
|
@ -111,6 +114,8 @@ class UsersController extends Controller {
|
|||
continue;
|
||||
}
|
||||
$connectedUsers[] = (string) $user->id;
|
||||
// Register subscription for the added user
|
||||
\App\Subscription::registerEvent( \Modules\InternalConversations\Providers\InternalConversationsServiceProvider::EVENT_IC_NEW_REPLY, $conversation, $user->id );
|
||||
}
|
||||
$conversation->setMeta( 'internal_conversations.users', $connectedUsers );
|
||||
$conversation->save();
|
||||
|
|
|
@ -103,6 +103,8 @@ class InternalConversationsServiceProvider extends ServiceProvider {
|
|||
}
|
||||
if ( ! in_array( (string) $user, $connectedUsers ) ) {
|
||||
$connectedUsers[] = (string) $user;
|
||||
// Register subscription for selected user to receive reply notifications
|
||||
Subscription::registerEvent( self::EVENT_IC_NEW_REPLY, $conversation, $user );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -119,6 +121,8 @@ class InternalConversationsServiceProvider extends ServiceProvider {
|
|||
// Check if user has mailbox access
|
||||
if ( $mailbox->userHasAccess( $userId ) && ! in_array( (string) $userId, $connectedUsers ) ) {
|
||||
$connectedUsers[] = (string) $userId;
|
||||
// Register subscription for mentioned user to receive reply notifications
|
||||
Subscription::registerEvent( self::EVENT_IC_NEW_REPLY, $conversation, $userId );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -438,6 +442,8 @@ class InternalConversationsServiceProvider extends ServiceProvider {
|
|||
continue;
|
||||
}
|
||||
$connectedUsers[] = (string) $userId;
|
||||
// Register subscription for mentioned user to receive reply notifications
|
||||
Subscription::registerEvent( self::EVENT_IC_NEW_REPLY, $conversation, $userId );
|
||||
}
|
||||
$conversation->setMeta( 'internal_conversations.users', $connectedUsers );
|
||||
$conversation->save();
|
||||
|
@ -488,6 +494,8 @@ class InternalConversationsServiceProvider extends ServiceProvider {
|
|||
// Ensure public state is preserved
|
||||
$conversation->setMeta( 'internal_conversations.is_public', true );
|
||||
$conversation->save();
|
||||
// Register subscription for the user who replied
|
||||
Subscription::registerEvent( self::EVENT_IC_NEW_REPLY, $conversation, $thread->created_by_user_id );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -519,12 +527,12 @@ class InternalConversationsServiceProvider extends ServiceProvider {
|
|||
return $filter_out;
|
||||
}
|
||||
|
||||
// For thumbs up events, only filter out if user is not the thread author
|
||||
// For thumbs up events, only allow the thread author to receive notifications
|
||||
if ( $subscription->event === self::EVENT_IC_THUMBS_UP ) {
|
||||
if ( $thread && $thread->created_by_user_id == $subscription->user_id ) {
|
||||
return false; // Don't filter out - this is the thread author
|
||||
}
|
||||
return $filter_out;
|
||||
return true; // Filter out everyone else
|
||||
}
|
||||
|
||||
// Check if conversation is public
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue