every group member receive email notification when only mention one member in group discussion reply

I have run into a weird bug. I have created a group and set the group email notification to be on by default when the user joins the group. When I mentioned only one group member in the group discussion reply, every member in the group get email notified saying: 'admin mentioned you in a group discussion reply.'. 

I have tried in group blog reply, group news reply and other content types and this issue doesn't appear. It seems it only happens in group discussion reply. I tried to disable my custom theme and use elgg default theme but the issue persists. 

Any suggestions that where should I look into? Thanks. 

  • I found that the issue is probably not with mention plugin, but rather in discussion plugin.
    in `discussions/start.php`, there is a function returns the subscription users:
     
    function discussion_get_subscriptions($hook, $type, $subscriptions, $params) {
    
    $reply = $params['event']->getObject();
    
    
    if (!elgg_instanceof($reply, 'object', 'discussion_reply')) {
    
    return $subscriptions;
    
    }
    
    
    $container_guid = $reply->getContainerEntity()->container_guid;
    
    $container_subscriptions = elgg_get_subscriptions_for_container($container_guid);
    
    
    return ($subscriptions + $container_subscriptions);
    
    }
     
     
    It seems it gets all of the group members subscribed to the group content and notify them. Is there any way we can get around this?