comparison mod_cloud_notify_filters/mod_cloud_notify_filters.lua @ 5302:ba94a5301985

mod_cloud_notify_filters: Fix traceback when invalid JIDs are submitted
author Matthew Wild <mwild1@gmail.com>
date Tue, 04 Apr 2023 18:09:48 +0100
parents 6872e55cfb92
children
comparison
equal deleted inserted replaced
5301:8ef197cccd74 5302:ba94a5301985
26 26
27 local filter_muted = enable:get_child("muted", xmlns_push_filter_muted); 27 local filter_muted = enable:get_child("muted", xmlns_push_filter_muted);
28 if filter_muted then 28 if filter_muted then
29 local muted_jids = {}; 29 local muted_jids = {};
30 for item in filter_muted:childtags("item") do 30 for item in filter_muted:childtags("item") do
31 muted_jids[jid.prep(item.attr.jid)] = true; 31 local room_jid = jid.prep(item.attr.jid);
32 if not room_jid then
33 module:log("warn", "Skipping invalid JID: <%s>", room_jid);
34 else
35 muted_jids[room_jid] = true;
36 end
32 end 37 end
33 event.push_info.muted_jids = muted_jids; 38 event.push_info.muted_jids = muted_jids;
34 end 39 end
35 40
36 local filter_groupchat = enable:get_child("groupchat", xmlns_push_filter_groupchat); 41 local filter_groupchat = enable:get_child("groupchat", xmlns_push_filter_groupchat);
37 if filter_groupchat then 42 if filter_groupchat then
38 local groupchat_rules = {}; 43 local groupchat_rules = {};
39 for item in filter_groupchat:childtags("room") do 44 for item in filter_groupchat:childtags("room") do
40 groupchat_rules[jid.prep(item.attr.jid)] = { 45 local room_jid = jid.prep(item.attr.jid);
41 when = item.attr.allow; 46 if not room_jid then
42 nick = item.attr.nick; 47 module:log("warn", "Skipping invalid JID: <%s>", item.attr.jid);
43 }; 48 else
49 groupchat_rules[room_jid] = {
50 when = item.attr.allow;
51 nick = item.attr.nick;
52 };
53 end
44 end 54 end
45 event.push_info.groupchat_rules = groupchat_rules; 55 event.push_info.groupchat_rules = groupchat_rules;
46 end 56 end
47 end 57 end
48 58