Software /
code /
prosody
Comparison
plugins/mod_presence.lua @ 10563:e8db377a2983
Merge 0.11->trunk
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 24 Dec 2019 00:39:45 +0100 |
parent | 10556:79fe4ed1332b |
child | 10694:0cda5d597607 |
comparison
equal
deleted
inserted
replaced
10562:670afc079f68 | 10563:e8db377a2983 |
---|---|
79 res.presence.attr.to = origin.full_jid; | 79 res.presence.attr.to = origin.full_jid; |
80 core_post_stanza(res, res.presence, true); | 80 core_post_stanza(res, res.presence, true); |
81 res.presence.attr.to = nil; | 81 res.presence.attr.to = nil; |
82 end | 82 end |
83 end | 83 end |
84 for jid in pairs(roster[false].pending) do -- resend incoming subscription requests | 84 for jid, pending_request in pairs(roster[false].pending) do -- resend incoming subscription requests |
85 origin.send(st.presence({type="subscribe", from=jid})); -- TODO add to attribute? Use original? | 85 if type(pending_request) == "table" then |
86 local subscribe = st.deserialize(pending_request); | |
87 subscribe.attr.type, subscribe.attr.from = "subscribe", jid; | |
88 origin.send(subscribe); | |
89 else | |
90 origin.send(st.presence({type="subscribe", from=jid})); | |
91 end | |
86 end | 92 end |
87 local request = st.presence({type="subscribe", from=origin.username.."@"..origin.host}); | 93 local request = st.presence({type="subscribe", from=origin.username.."@"..origin.host}); |
88 for jid, item in pairs(roster) do -- resend outgoing subscription requests | 94 for jid, item in pairs(roster) do -- resend outgoing subscription requests |
89 if item.ask then | 95 if item.ask then |
90 request.attr.to = jid; | 96 request.attr.to = jid; |
173 -- 2. roster_push () | 179 -- 2. roster_push () |
174 -- 3. send_presence_of_available_resources | 180 -- 3. send_presence_of_available_resources |
175 if rostermanager.subscribed(node, host, to_bare) then | 181 if rostermanager.subscribed(node, host, to_bare) then |
176 rostermanager.roster_push(node, host, to_bare); | 182 rostermanager.roster_push(node, host, to_bare); |
177 end | 183 end |
178 core_post_stanza(origin, stanza); | 184 if rostermanager.is_contact_subscribed(node, host, to_bare) then |
179 send_presence_of_available_resources(node, host, to_bare, origin); | 185 core_post_stanza(origin, stanza); |
186 send_presence_of_available_resources(node, host, to_bare, origin); | |
187 end | |
180 if rostermanager.is_user_subscribed(node, host, to_bare) then | 188 if rostermanager.is_user_subscribed(node, host, to_bare) then |
181 core_post_stanza(origin, st.presence({ type = "probe", from = from_bare, to = to_bare })); | 189 core_post_stanza(origin, st.presence({ type = "probe", from = from_bare, to = to_bare })); |
182 end | 190 end |
183 elseif stanza.attr.type == "unsubscribed" then | 191 elseif stanza.attr.type == "unsubscribed" then |
184 -- 1. send unavailable | 192 -- 1. send unavailable |
185 -- 2. route stanza | 193 -- 2. route stanza |
186 -- 3. roster push (subscription = from or both) | 194 -- 3. roster push (subscription = from or both) |
195 -- luacheck: ignore 211/pending_in | |
196 -- Is pending_in meant to be used? | |
187 local success, pending_in, subscribed = rostermanager.unsubscribed(node, host, to_bare); | 197 local success, pending_in, subscribed = rostermanager.unsubscribed(node, host, to_bare); |
188 if success then | 198 if success then |
189 if subscribed then | 199 if subscribed then |
190 rostermanager.roster_push(node, host, to_bare); | 200 rostermanager.roster_push(node, host, to_bare); |
191 end | 201 end |
221 core_post_stanza(hosts[host], st.presence({from=to_bare, to=from_bare, type="subscribed"}), true); -- already subscribed | 231 core_post_stanza(hosts[host], st.presence({from=to_bare, to=from_bare, type="subscribed"}), true); -- already subscribed |
222 -- Sending presence is not clearly stated in the RFC, but it seems appropriate | 232 -- Sending presence is not clearly stated in the RFC, but it seems appropriate |
223 if 0 == send_presence_of_available_resources(node, host, from_bare, origin) then | 233 if 0 == send_presence_of_available_resources(node, host, from_bare, origin) then |
224 core_post_stanza(hosts[host], st.presence({from=to_bare, to=from_bare, type="unavailable"}), true); -- TODO send last activity | 234 core_post_stanza(hosts[host], st.presence({from=to_bare, to=from_bare, type="unavailable"}), true); -- TODO send last activity |
225 end | 235 end |
236 elseif rostermanager.is_contact_preapproved(node, host, from_bare) then | |
237 if not rostermanager.is_contact_pending_in(node, host, from_bare) then | |
238 if rostermanager.set_contact_pending_in(node, host, from_bare, stanza) then | |
239 core_post_stanza(hosts[host], st.presence({from=to_bare, to=from_bare, type="subscribed"}), true); | |
240 end -- TODO else return error, unable to save | |
241 end | |
226 else | 242 else |
227 core_post_stanza(hosts[host], st.presence({from=to_bare, to=from_bare, type="unavailable"}), true); -- acknowledging receipt | 243 core_post_stanza(hosts[host], st.presence({from=to_bare, to=from_bare, type="unavailable"}), true); -- acknowledging receipt |
228 if not rostermanager.is_contact_pending_in(node, host, from_bare) then | 244 if not rostermanager.is_contact_pending_in(node, host, from_bare) then |
229 if rostermanager.set_contact_pending_in(node, host, from_bare) then | 245 if rostermanager.set_contact_pending_in(node, host, from_bare, stanza) then |
230 sessionmanager.send_to_available_resources(node, host, stanza); | 246 sessionmanager.send_to_available_resources(node, host, stanza); |
231 end -- TODO else return error, unable to save | 247 end -- TODO else return error, unable to save |
232 end | 248 end |
233 end | 249 end |
234 elseif stanza.attr.type == "unsubscribe" then | 250 elseif stanza.attr.type == "unsubscribe" then |