Changeset

4305:2ca55a4da3ea

muc_room_mention_notifications: Handle referenced JID being a MUC nickname JID instead of assuming that we'll always receive the user's real JID
author JC Brand <jc@opkode.com>
date Mon, 21 Dec 2020 15:39:56 +0100
parents 4304:aec8148df26a
children 4306:747a14017d00
files mod_muc_room_mention_notifications/mod_muc_room_mention_notifications.lua
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mod_muc_room_mention_notifications/mod_muc_room_mention_notifications.lua	Fri Dec 18 16:31:01 2020 +0100
+++ b/mod_muc_room_mention_notifications/mod_muc_room_mention_notifications.lua	Mon Dec 21 15:39:56 2020 +0100
@@ -1,6 +1,7 @@
 local jid = require "util.jid";
 local st = require "util.stanza";
 local datetime = require "util.datetime";
+local jid_resource = require "util.jid".resource;
 
 local notify_unaffiliated_users = module:get_option("muc_rmn_notify_unaffiliated_users", false)
 
@@ -50,7 +51,12 @@
 
 local function notify_mentioned_users(room, client_mentions, mention_stanza)
 	module:log("debug", "NOTIFYING FOR %s", room.jid)
-	for user_bare_jid in pairs(client_mentions) do
+	for mentioned_jid in pairs(client_mentions) do
+		local user_bare_jid = mentioned_jid;
+		if (string.match(mentioned_jid, room.jid)) then
+			local nick = jid_resource(mentioned_jid);
+			user_bare_jid = room:get_registered_jid(nick);
+		end
 		if is_eligible(user_bare_jid, room) then
 			send_single_notification(user_bare_jid, room.jid, mention_stanza);
 		end