Mercurial > prosody-modules
comparison mod_carbons/mod_carbons.lua @ 836:a86131581180
mod_carbons: Less complicated assignments (thanks waqas)
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 22 Sep 2012 01:56:59 +0200 |
parents | 07cc1efde2f8 |
children | 0ef11dee7050 |
comparison
equal
deleted
inserted
replaced
835:07cc1efde2f8 | 836:a86131581180 |
---|---|
5 | 5 |
6 local st = require "util.stanza"; | 6 local st = require "util.stanza"; |
7 local jid_bare = require "util.jid".bare; | 7 local jid_bare = require "util.jid".bare; |
8 local xmlns_carbons = "urn:xmpp:carbons:1"; | 8 local xmlns_carbons = "urn:xmpp:carbons:1"; |
9 local xmlns_forward = "urn:xmpp:forward:0"; | 9 local xmlns_forward = "urn:xmpp:forward:0"; |
10 local host_sessions = hosts[module.host].sessions; | |
11 local full_sessions, bare_sessions = full_sessions, bare_sessions; | 10 local full_sessions, bare_sessions = full_sessions, bare_sessions; |
12 | 11 |
13 local function toggle_carbons(event) | 12 local function toggle_carbons(event) |
14 local origin, stanza = event.origin, event.stanza; | 13 local origin, stanza = event.origin, event.stanza; |
15 if stanza.attr.type == "set" then | 14 if stanza.attr.type == "set" then |
34 or orig_type == "chat") then | 33 or orig_type == "chat") then |
35 return -- No carbons for messages of type error or headline | 34 return -- No carbons for messages of type error or headline |
36 end | 35 end |
37 | 36 |
38 -- Stanza sent by a local client | 37 -- Stanza sent by a local client |
39 local bare_jid = origin.type == "c2s" and origin.username .. "@" .. origin.host or jid_bare(orig_from); | 38 local bare_jid = jid_bare(orig_from); |
40 local target_session = origin; | 39 local target_session = origin; |
41 local top_priority = false; | 40 local top_priority = false; |
42 local user_sessions = host_sessions[origin.username]; | 41 local user_sessions = bare_sessions[bare_jid]; |
43 | 42 |
44 -- Stanza about to be delivered to a local client | 43 -- Stanza about to be delivered to a local client |
45 if not c2s then | 44 if not c2s then |
46 bare_jid = jid_bare(orig_to); | 45 bare_jid = jid_bare(orig_to); |
47 target_session = full_sessions[orig_to] | 46 target_session = full_sessions[orig_to]; |
48 user_sessions = bare_sessions[bare_jid]; | 47 user_sessions = bare_sessions[bare_jid]; |
49 if not target_session and user_sessions then | 48 if not target_session and user_sessions then |
50 -- The top resources will already receive this message per normal routing rules, | 49 -- The top resources will already receive this message per normal routing rules, |
51 -- so we are going to skip them in order to avoid sending duplicated messages. | 50 -- so we are going to skip them in order to avoid sending duplicated messages. |
52 local top_resources = user_sessions.top_resources; | 51 local top_resources = user_sessions.top_resources; |