Comparison

plugins/mod_blocklist.lua @ 10434:8f709577fe8e

Merge 0.11->trunk
author Kim Alvefur <zash@zash.se>
date Sat, 23 Nov 2019 23:12:01 +0100
parent 10111:0f335815244f
child 12775:1dd468c63a3d
child 13487:84fa880bf476
comparison
equal deleted inserted replaced
10433:7777f25d5266 10434:8f709577fe8e
65 module:log("info", "Migrating blocklist from mod_privacy storage for user '%s'", username); 65 module:log("info", "Migrating blocklist from mod_privacy storage for user '%s'", username);
66 for _, item in ipairs(default_list.items) do 66 for _, item in ipairs(default_list.items) do
67 if item.type == "jid" and item.action == "deny" then 67 if item.type == "jid" and item.action == "deny" then
68 local jid = jid_prep(item.value); 68 local jid = jid_prep(item.value);
69 if not jid then 69 if not jid then
70 module:log("warn", "Invalid JID in privacy store for user '%s' not migrated: %s", username, tostring(item.value)); 70 module:log("warn", "Invalid JID in privacy store for user '%s' not migrated: %s", username, item.value);
71 else 71 else
72 migrated_data[jid] = true; 72 migrated_data[jid] = true;
73 end 73 end
74 end 74 end
75 end 75 end
160 end 160 end
161 161
162 local blocklist = cache[username] or get_blocklist(username); 162 local blocklist = cache[username] or get_blocklist(username);
163 163
164 local new_blocklist = { 164 local new_blocklist = {
165 -- We set the [false] key to someting as a signal not to migrate privacy lists 165 -- We set the [false] key to something as a signal not to migrate privacy lists
166 [false] = blocklist[false] or { created = now; }; 166 [false] = blocklist[false] or { created = now; };
167 }; 167 };
168 if type(blocklist[false]) == "table" then 168 if type(blocklist[false]) == "table" then
169 new_blocklist[false].modified = now; 169 new_blocklist[false].modified = now;
170 end 170 end
187 return true; 187 return true;
188 end 188 end
189 189
190 if is_blocking then 190 if is_blocking then
191 for jid in pairs(send_unavailable) do 191 for jid in pairs(send_unavailable) do
192 -- Check that this JID isn't already blocked, i.e. this is not a change
192 if not blocklist[jid] then 193 if not blocklist[jid] then
193 for _, session in pairs(sessions[username].sessions) do 194 for _, session in pairs(sessions[username].sessions) do
194 if session.presence then 195 if session.presence then
195 module:send(st.presence({ type = "unavailable", to = jid, from = session.full_jid })); 196 module:send(st.presence({ type = "unavailable", to = jid, from = session.full_jid }));
196 end 197 end