Software / code / prosody
Comparison
plugins/mod_register.lua @ 2262:83823ba8de40
Merge with 0.6.
| author | Waqas Hussain <waqas20@gmail.com> |
|---|---|
| date | Sun, 29 Nov 2009 18:29:19 +0500 |
| parent | 2260:67b64995ae1e |
| child | 2448:542335c8a5bc |
comparison
equal
deleted
inserted
replaced
| 2258:e4c5d0d21ac7 | 2262:83823ba8de40 |
|---|---|
| 41 local roster = session.roster; | 41 local roster = session.roster; |
| 42 for _, session in pairs(hosts[host].sessions[username].sessions) do -- disconnect all resources | 42 for _, session in pairs(hosts[host].sessions[username].sessions) do -- disconnect all resources |
| 43 session:close({condition = "not-authorized", text = "Account deleted"}); | 43 session:close({condition = "not-authorized", text = "Account deleted"}); |
| 44 end | 44 end |
| 45 -- TODO datamanager should be able to delete all user data itself | 45 -- TODO datamanager should be able to delete all user data itself |
| 46 datamanager.store(username, host, "roster", nil); | |
| 47 datamanager.store(username, host, "vcard", nil); | 46 datamanager.store(username, host, "vcard", nil); |
| 48 datamanager.store(username, host, "private", nil); | 47 datamanager.store(username, host, "private", nil); |
| 49 datamanager.store(username, host, "offline", nil); | 48 datamanager.store(username, host, "offline", nil); |
| 50 --local bare = username.."@"..host; | 49 local bare = username.."@"..host; |
| 51 for jid, item in pairs(roster) do | 50 for jid, item in pairs(roster) do |
| 52 if jid ~= "pending" then | 51 if jid and jid ~= "pending" then |
| 53 if item.subscription == "both" or item.subscription == "to" then | 52 if item.subscription == "both" or item.subscription == "from" or (roster.pending and roster.pending[jid]) then |
| 54 -- TODO unsubscribe | 53 core_post_stanza(hosts[host], st.presence({type="unsubscribed", from=bare, to=jid})); |
| 55 end | 54 end |
| 56 if item.subscription == "both" or item.subscription == "from" then | 55 if item.subscription == "both" or item.subscription == "to" or item.ask then |
| 57 -- TODO unsubscribe | 56 core_post_stanza(hosts[host], st.presence({type="unsubscribe", from=bare, to=jid})); |
| 58 end | 57 end |
| 59 end | 58 end |
| 60 end | 59 end |
| 60 datamanager.store(username, host, "roster", nil); | |
| 61 datamanager.store(username, host, "accounts", nil); -- delete accounts datastore at the end | 61 datamanager.store(username, host, "accounts", nil); -- delete accounts datastore at the end |
| 62 module:log("info", "User removed their account: %s@%s", username, host); | 62 module:log("info", "User removed their account: %s@%s", username, host); |
| 63 module:fire_event("user-deregistered", { username = username, host = host, source = "mod_register", session = session }); | 63 module:fire_event("user-deregistered", { username = username, host = host, source = "mod_register", session = session }); |
| 64 else | 64 else |
| 65 local username = query:child_with_name("username"); | 65 local username = query:child_with_name("username"); |