Software / code / prosody-modules
Comparison
mod_roster_command/mod_roster_command.lua @ 1509:01e37ce7532e
mod_roster_command: Make sure hosts are only initialized once
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sat, 20 Sep 2014 11:33:49 +0200 |
| parent | 1508:f7cb287dd3c7 |
| child | 1565:f9cb09d451c7 |
comparison
equal
deleted
inserted
replaced
| 1508:f7cb287dd3c7 | 1509:01e37ce7532e |
|---|---|
| 31 local contact_username, contact_host = jid.split(contact_jid); | 31 local contact_username, contact_host = jid.split(contact_jid); |
| 32 if not hosts[user_host] then | 32 if not hosts[user_host] then |
| 33 warn("The host '%s' is not configured for this server.", user_host); | 33 warn("The host '%s' is not configured for this server.", user_host); |
| 34 return; | 34 return; |
| 35 end | 35 end |
| 36 storagemanager.initialize_host(user_host); | 36 if hosts[user_host].users.name == "null" then |
| 37 usermanager.initialize_host(user_host); | 37 storagemanager.initialize_host(user_host); |
| 38 usermanager.initialize_host(user_host); | |
| 39 end | |
| 38 -- Update user's roster to say subscription request is pending... | 40 -- Update user's roster to say subscription request is pending... |
| 39 rostermanager.set_contact_pending_out(user_username, user_host, contact_jid); | 41 rostermanager.set_contact_pending_out(user_username, user_host, contact_jid); |
| 40 if hosts[contact_host] then | 42 if hosts[contact_host] then |
| 41 if contact_host ~= user_host then | 43 if contact_host ~= user_host and hosts[contact_host].users.name == "null" then |
| 42 storagemanager.initialize_host(contact_host); | 44 storagemanager.initialize_host(contact_host); |
| 43 usermanager.initialize_host(contact_host); | 45 usermanager.initialize_host(contact_host); |
| 44 end | 46 end |
| 45 -- Update contact's roster to say subscription request is pending... | 47 -- Update contact's roster to say subscription request is pending... |
| 46 rostermanager.set_contact_pending_in(contact_username, contact_host, user_jid); | 48 rostermanager.set_contact_pending_in(contact_username, contact_host, user_jid); |
| 64 local contact_username, contact_host = jid.split(contact_jid); | 66 local contact_username, contact_host = jid.split(contact_jid); |
| 65 if not hosts[user_host] then | 67 if not hosts[user_host] then |
| 66 warn("The host '%s' is not configured for this server.", user_host); | 68 warn("The host '%s' is not configured for this server.", user_host); |
| 67 return; | 69 return; |
| 68 end | 70 end |
| 69 storagemanager.initialize_host(user_host); | 71 if hosts[user_host].users.name == "null" then |
| 70 usermanager.initialize_host(user_host); | 72 storagemanager.initialize_host(user_host); |
| 73 usermanager.initialize_host(user_host); | |
| 74 end | |
| 71 -- Update user's roster to say subscription is cancelled... | 75 -- Update user's roster to say subscription is cancelled... |
| 72 rostermanager.unsubscribe(user_username, user_host, contact_jid); | 76 rostermanager.unsubscribe(user_username, user_host, contact_jid); |
| 73 if hosts[contact_host] then | 77 if hosts[contact_host] then |
| 74 if contact_host ~= user_host then | 78 if contact_host ~= user_host and hosts[contact_host].users.name == "null" then |
| 75 storagemanager.initialize_host(contact_host); | 79 storagemanager.initialize_host(contact_host); |
| 76 usermanager.initialize_host(contact_host); | 80 usermanager.initialize_host(contact_host); |
| 77 end | 81 end |
| 78 -- Update contact's roster to say subscription is cancelled... | 82 -- Update contact's roster to say subscription is cancelled... |
| 79 rostermanager.unsubscribed(contact_username, contact_host, user_jid); | 83 rostermanager.unsubscribed(contact_username, contact_host, user_jid); |
| 91 local user_username, user_host = jid.split(user_jid); | 95 local user_username, user_host = jid.split(user_jid); |
| 92 if not hosts[user_host] then | 96 if not hosts[user_host] then |
| 93 warn("The host '%s' is not configured for this server.", user_host); | 97 warn("The host '%s' is not configured for this server.", user_host); |
| 94 return; | 98 return; |
| 95 end | 99 end |
| 96 storagemanager.initialize_host(user_host); | 100 if hosts[user_host].users.name == "null" then |
| 97 usermanager.initialize_host(user_host); | 101 storagemanager.initialize_host(user_host); |
| 102 usermanager.initialize_host(user_host); | |
| 103 end | |
| 98 | 104 |
| 99 -- Load user's roster and find the contact | 105 -- Load user's roster and find the contact |
| 100 local roster = rostermanager.load_roster(user_username, user_host); | 106 local roster = rostermanager.load_roster(user_username, user_host); |
| 101 local item = roster[contact_jid]; | 107 local item = roster[contact_jid]; |
| 102 if item then | 108 if item then |