aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_blocklist.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2018-02-15 03:00:32 +0100
committerKim Alvefur <zash@zash.se>2018-02-15 03:00:32 +0100
commitc27e8e8bceece625b9078bc8329136f32299b7b5 (patch)
tree4db3c3756ff94a178a8f335fa532084a333401f0 /plugins/mod_blocklist.lua
parent7346b176730c52b633f308c0425060f4d898f0c3 (diff)
downloadprosody-c27e8e8bceece625b9078bc8329136f32299b7b5.tar.gz
prosody-c27e8e8bceece625b9078bc8329136f32299b7b5.zip
mod_blocklist: Store timestamp of blocking to allow age to be determined
Diffstat (limited to 'plugins/mod_blocklist.lua')
-rw-r--r--plugins/mod_blocklist.lua12
1 files changed, 7 insertions, 5 deletions
diff --git a/plugins/mod_blocklist.lua b/plugins/mod_blocklist.lua
index 3c6708f0..8aca7332 100644
--- a/plugins/mod_blocklist.lua
+++ b/plugins/mod_blocklist.lua
@@ -114,12 +114,14 @@ end, -1);
-- Add or remove some jid(s) from the blocklist
-- We want this to be atomic and not do a partial update
local function edit_blocklist(event)
+ local now = os.time();
local origin, stanza = event.origin, event.stanza;
local username = origin.username;
local action = stanza.tags[1]; -- "block" or "unblock"
- local is_blocking = action.name == "block" or nil; -- nil if unblocking
+ local is_blocking = action.name == "block" and now or nil; -- nil if unblocking
local new = {}; -- JIDs to block depending or unblock on action
+
-- XEP-0191 sayeth:
-- > When the user blocks communications with the contact, the user's
-- > server MUST send unavailable presence information to the contact (but
@@ -158,15 +160,15 @@ local function edit_blocklist(event)
local new_blocklist = {
-- We set the [false] key to someting as a signal not to migrate privacy lists
- [false] = blocklist[false] or { created = os.time(); };
+ [false] = blocklist[false] or { created = now; };
};
if type(blocklist[false]) == "table" then
- new_blocklist[false].modified = os.time();
+ new_blocklist[false].modified = now;
end
if is_blocking or next(new) then
- for jid in pairs(blocklist) do
- if jid then new_blocklist[jid] = true; end
+ for jid, t in pairs(blocklist) do
+ if jid then new_blocklist[jid] = t; end
end
for jid in pairs(new) do
new_blocklist[jid] = is_blocking;