140 end |
140 end |
141 end |
141 end |
142 stanza.attr.to = nil; -- reset it |
142 stanza.attr.to = nil; -- reset it |
143 end |
143 end |
144 |
144 |
145 function send_presence_of_available_resources(user, host, jid, recipient_session, core_route_stanza) |
145 function send_presence_of_available_resources(user, host, jid, recipient_session, core_route_stanza, stanza) |
146 local h = hosts[host]; |
146 local h = hosts[host]; |
147 local count = 0; |
147 local count = 0; |
148 if h and h.type == "local" then |
148 if h and h.type == "local" then |
149 local u = h.sessions[user]; |
149 local u = h.sessions[user]; |
150 if u then |
150 if u then |
151 for k, session in pairs(u.sessions) do |
151 for k, session in pairs(u.sessions) do |
152 local pres = session.presence; |
152 local pres = session.presence; |
153 if pres then |
153 if pres then |
|
154 if stanza then pres = stanza; pres.attr.from = session.full_jid; end |
154 pres.attr.to = jid; |
155 pres.attr.to = jid; |
155 core_route_stanza(session, pres); |
156 core_route_stanza(session, pres); |
156 pres.attr.to = nil; |
157 pres.attr.to = nil; |
157 count = count + 1; |
158 count = count + 1; |
158 end |
159 end |
197 -- 2. roster push (subscription = none or to) |
198 -- 2. roster push (subscription = none or to) |
198 if rostermanager.unsubscribed(node, host, to_bare) then |
199 if rostermanager.unsubscribed(node, host, to_bare) then |
199 rostermanager.roster_push(node, host, to_bare); |
200 rostermanager.roster_push(node, host, to_bare); |
200 end |
201 end |
201 core_route_stanza(origin, stanza); |
202 core_route_stanza(origin, stanza); |
|
203 -- COMPAT: Some legacy clients keep displaying unsubscribed contacts as online unless an unavailable presence is sent: |
|
204 send_presence_of_available_resources(node, host, to_bare, origin, core_route_stanza, |
|
205 st.presence({ type="unavailable", from=from_bare, to=to_bare, id=stanza.attr.id })); |
202 end |
206 end |
203 stanza.attr.from, stanza.attr.to = st_from, st_to; |
207 stanza.attr.from, stanza.attr.to = st_from, st_to; |
204 end |
208 end |
205 |
209 |
206 function handle_inbound_presence_subscriptions_and_probes(origin, stanza, from_bare, to_bare, core_route_stanza) |
210 function handle_inbound_presence_subscriptions_and_probes(origin, stanza, from_bare, to_bare, core_route_stanza) |