Software / code / prosody
Comparison
core/rostermanager.lua @ 5060:b0e36777f715
mod_presence, rostermanager: Bring outbound subscription cancellation in line with RFC6121.
| author | Waqas Hussain <waqas20@gmail.com> |
|---|---|
| date | Wed, 01 Aug 2012 01:36:16 +0500 |
| parent | 5024:d25e1b9332cc |
| child | 5348:ca0d820e9318 |
comparison
equal
deleted
inserted
replaced
| 5059:246ba539a5cd | 5060:b0e36777f715 |
|---|---|
| 276 end | 276 end |
| 277 function unsubscribed(username, host, jid) | 277 function unsubscribed(username, host, jid) |
| 278 local roster = load_roster(username, host); | 278 local roster = load_roster(username, host); |
| 279 local item = roster[jid]; | 279 local item = roster[jid]; |
| 280 local pending = is_contact_pending_in(username, host, jid); | 280 local pending = is_contact_pending_in(username, host, jid); |
| 281 local changed = nil; | 281 if pending then |
| 282 if is_contact_pending_in(username, host, jid) then | |
| 283 roster.pending[jid] = nil; -- TODO maybe delete roster.pending if empty? | 282 roster.pending[jid] = nil; -- TODO maybe delete roster.pending if empty? |
| 284 changed = true; | 283 end |
| 285 end | 284 local subscribed; |
| 286 if item then | 285 if item then |
| 287 if item.subscription == "from" then | 286 if item.subscription == "from" then |
| 288 item.subscription = "none"; | 287 item.subscription = "none"; |
| 289 changed = true; | 288 subscribed = true; |
| 290 elseif item.subscription == "both" then | 289 elseif item.subscription == "both" then |
| 291 item.subscription = "to"; | 290 item.subscription = "to"; |
| 292 changed = true; | 291 subscribed = true; |
| 293 end | 292 end |
| 294 end | 293 end |
| 295 if changed then | 294 local success = (pending or subscribed) and save_roster(username, host, roster); |
| 296 return save_roster(username, host, roster); | 295 return success, pending, subscribed; |
| 297 end | |
| 298 end | 296 end |
| 299 | 297 |
| 300 function process_outbound_subscription_request(username, host, jid) | 298 function process_outbound_subscription_request(username, host, jid) |
| 301 local roster = load_roster(username, host); | 299 local roster = load_roster(username, host); |
| 302 local item = roster[jid]; | 300 local item = roster[jid]; |