Comparison

mod_block_strangers/mod_block_strangers.lua @ 2419:045d594a3707

mod_block_strangers: Check that the table of directed presence exists before indexing it (fixes traceback)
author Kim Alvefur <zash@zash.se>
date Mon, 19 Dec 2016 07:43:28 +0100
parent 2196:09f6e1a09b2b
child 3023:38365c1f1fe4
comparison
equal deleted inserted replaced
2418:ef95853cf900 2419:045d594a3707
5 local is_contact_subscribed = require "core.rostermanager".is_contact_subscribed; 5 local is_contact_subscribed = require "core.rostermanager".is_contact_subscribed;
6 local full_sessions = prosody.full_sessions; 6 local full_sessions = prosody.full_sessions;
7 7
8 local function has_directed_presence(user, jid) 8 local function has_directed_presence(user, jid)
9 local session = full_sessions[user]; 9 local session = full_sessions[user];
10 return session and session.directed[jid]; 10 if session then
11 local directed = session.directed;
12 if directed then
13 return directed[jid];
14 end
15 end
11 end 16 end
12 17
13 function check_subscribed(event) 18 function check_subscribed(event)
14 local stanza = event.stanza; 19 local stanza = event.stanza;
15 local to_user, to_host, to_resource = jid_split(stanza.attr.to); 20 local to_user, to_host, to_resource = jid_split(stanza.attr.to);