Software /
code /
prosody-modules
Comparison
mod_muc_room_mention_notifications/mod_muc_room_mention_notifications.lua @ 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 |
parent | 4280:278f2998ce49 |
child | 4306:747a14017d00 |
comparison
equal
deleted
inserted
replaced
4304:aec8148df26a | 4305:2ca55a4da3ea |
---|---|
1 local jid = require "util.jid"; | 1 local jid = require "util.jid"; |
2 local st = require "util.stanza"; | 2 local st = require "util.stanza"; |
3 local datetime = require "util.datetime"; | 3 local datetime = require "util.datetime"; |
4 local jid_resource = require "util.jid".resource; | |
4 | 5 |
5 local notify_unaffiliated_users = module:get_option("muc_rmn_notify_unaffiliated_users", false) | 6 local notify_unaffiliated_users = module:get_option("muc_rmn_notify_unaffiliated_users", false) |
6 | 7 |
7 local muc_affiliation_store = module:open_store("config", "map"); | 8 local muc_affiliation_store = module:open_store("config", "map"); |
8 | 9 |
48 return module:send(notification); | 49 return module:send(notification); |
49 end | 50 end |
50 | 51 |
51 local function notify_mentioned_users(room, client_mentions, mention_stanza) | 52 local function notify_mentioned_users(room, client_mentions, mention_stanza) |
52 module:log("debug", "NOTIFYING FOR %s", room.jid) | 53 module:log("debug", "NOTIFYING FOR %s", room.jid) |
53 for user_bare_jid in pairs(client_mentions) do | 54 for mentioned_jid in pairs(client_mentions) do |
55 local user_bare_jid = mentioned_jid; | |
56 if (string.match(mentioned_jid, room.jid)) then | |
57 local nick = jid_resource(mentioned_jid); | |
58 user_bare_jid = room:get_registered_jid(nick); | |
59 end | |
54 if is_eligible(user_bare_jid, room) then | 60 if is_eligible(user_bare_jid, room) then |
55 send_single_notification(user_bare_jid, room.jid, mention_stanza); | 61 send_single_notification(user_bare_jid, room.jid, mention_stanza); |
56 end | 62 end |
57 end | 63 end |
58 end | 64 end |