Software /
code /
prosody
Comparison
plugins/mod_carbons.lua @ 7776:63f50a84318f
mod_carbons: Rename some variables for clarity
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 08 Dec 2016 17:51:23 +0100 |
parent | 7718:c58075c4d375 |
child | 8354:b41947a0fc0c |
comparison
equal
deleted
inserted
replaced
7775:3733bdbe0b22 | 7776:63f50a84318f |
---|---|
22 | 22 |
23 local function message_handler(event, c2s) | 23 local function message_handler(event, c2s) |
24 local origin, stanza = event.origin, event.stanza; | 24 local origin, stanza = event.origin, event.stanza; |
25 local orig_type = stanza.attr.type or "normal"; | 25 local orig_type = stanza.attr.type or "normal"; |
26 local orig_from = stanza.attr.from; | 26 local orig_from = stanza.attr.from; |
27 local bare_from = jid_bare(orig_from); | |
27 local orig_to = stanza.attr.to; | 28 local orig_to = stanza.attr.to; |
28 | 29 local bare_to = jid_bare(orig_to); |
30 | |
29 if not(orig_type == "chat" or (orig_type == "normal" and stanza:get_child("body"))) then | 31 if not(orig_type == "chat" or (orig_type == "normal" and stanza:get_child("body"))) then |
30 return -- Only chat type messages | 32 return -- Only chat type messages |
31 end | 33 end |
32 | 34 |
33 -- Stanza sent by a local client | 35 -- Stanza sent by a local client |
34 local bare_jid = jid_bare(orig_from); | 36 local bare_jid = bare_from; -- JID of the local user |
35 local target_session = origin; | 37 local target_session = origin; |
36 local top_priority = false; | 38 local top_priority = false; |
37 local user_sessions = bare_sessions[bare_jid]; | 39 local user_sessions = bare_sessions[bare_from]; |
38 | 40 |
39 -- Stanza about to be delivered to a local client | 41 -- Stanza about to be delivered to a local client |
40 if not c2s then | 42 if not c2s then |
41 bare_jid = jid_bare(orig_to); | 43 bare_jid = bare_to; |
42 target_session = full_sessions[orig_to]; | 44 target_session = full_sessions[orig_to]; |
43 user_sessions = bare_sessions[bare_jid]; | 45 user_sessions = bare_sessions[bare_jid]; |
44 if not target_session and user_sessions then | 46 if not target_session and user_sessions then |
45 -- The top resources will already receive this message per normal routing rules, | 47 -- The top resources will already receive this message per normal routing rules, |
46 -- so we are going to skip them in order to avoid sending duplicated messages. | 48 -- so we are going to skip them in order to avoid sending duplicated messages. |