Software /
code /
prosody
Comparison
plugins/mod_presence.lua @ 6304:ace08821e4ee
Merge 0.10->trunk
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 04 Jul 2014 23:05:27 +0200 |
parent | 6302:76699a0ae4c4 |
child | 6613:2aae36312eb9 |
comparison
equal
deleted
inserted
replaced
6290:54e748acc07a | 6304:ace08821e4ee |
---|---|
53 | 53 |
54 local ignore_presence_priority = module:get_option("ignore_presence_priority"); | 54 local ignore_presence_priority = module:get_option("ignore_presence_priority"); |
55 | 55 |
56 function handle_normal_presence(origin, stanza) | 56 function handle_normal_presence(origin, stanza) |
57 if ignore_presence_priority then | 57 if ignore_presence_priority then |
58 local priority = stanza:child_with_name("priority"); | 58 local priority = stanza:get_child("priority"); |
59 if priority and priority[1] ~= "0" then | 59 if priority and priority[1] ~= "0" then |
60 for i=#priority.tags,1,-1 do priority.tags[i] = nil; end | 60 for i=#priority.tags,1,-1 do priority.tags[i] = nil; end |
61 for i=#priority,1,-1 do priority[i] = nil; end | 61 for i=#priority,1,-1 do priority[i] = nil; end |
62 priority[1] = "0"; | 62 priority[1] = "0"; |
63 end | 63 end |
64 end | 64 end |
65 local priority = stanza:child_with_name("priority"); | 65 local priority = stanza:get_child("priority"); |
66 if priority and #priority > 0 then | 66 if priority and #priority > 0 then |
67 priority = t_concat(priority); | 67 priority = t_concat(priority); |
68 if s_find(priority, "^[+-]?[0-9]+$") then | 68 if s_find(priority, "^[+-]?[0-9]+$") then |
69 priority = tonumber(priority); | 69 priority = tonumber(priority); |
70 if priority < -128 then priority = -128 end | 70 if priority < -128 then priority = -128 end |
88 stanza.attr.to = jid; | 88 stanza.attr.to = jid; |
89 core_post_stanza(origin, stanza, true); | 89 core_post_stanza(origin, stanza, true); |
90 end | 90 end |
91 end | 91 end |
92 if stanza.attr.type == nil and not origin.presence then -- initial presence | 92 if stanza.attr.type == nil and not origin.presence then -- initial presence |
93 module:fire_event("presence/initial", { origin = origin, stanza = stanza } ); | |
93 origin.presence = stanza; -- FIXME repeated later | 94 origin.presence = stanza; -- FIXME repeated later |
94 local probe = st.presence({from = origin.full_jid, type = "probe"}); | 95 local probe = st.presence({from = origin.full_jid, type = "probe"}); |
95 for jid, item in pairs(roster) do -- probe all contacts we are subscribed to | 96 for jid, item in pairs(roster) do -- probe all contacts we are subscribed to |
96 if item.subscription == "both" or item.subscription == "to" then | 97 if item.subscription == "both" or item.subscription == "to" then |
97 probe.attr.to = jid; | 98 probe.attr.to = jid; |
135 core_post_stanza(origin, stanza, true); | 136 core_post_stanza(origin, stanza, true); |
136 end | 137 end |
137 origin.directed = nil; | 138 origin.directed = nil; |
138 end | 139 end |
139 else | 140 else |
140 if not origin.presence then | |
141 module:fire_event("presence/initial", { origin = origin, stanza = stanza } ); | |
142 end | |
143 origin.presence = stanza; | 141 origin.presence = stanza; |
144 stanza:tag("delay", { xmlns = "urn:xmpp:delay", from = host, stamp = datetime.datetime() }):up(); | 142 stanza:tag("delay", { xmlns = "urn:xmpp:delay", from = host, stamp = datetime.datetime() }):up(); |
145 if origin.priority ~= priority then | 143 if origin.priority ~= priority then |
146 origin.priority = priority; | 144 origin.priority = priority; |
147 recalc_resource_map(user); | 145 recalc_resource_map(user); |