Software /
code /
prosody-modules
Comparison
mod_roster_allinall/mod_roster_allinall.lua @ 1798:3ae8c81a348b
mod_roster_allinall: Cleanup, remove unused variables [luacheck]
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 28 Aug 2015 00:16:39 +0200 |
parent | 1545:a104a159697d |
comparison
equal
deleted
inserted
replaced
1797:a946aa422503 | 1798:3ae8c81a348b |
---|---|
1 local rostermanager = require"core.rostermanager"; | 1 local rostermanager = require"core.rostermanager"; |
2 local jid_join = require"util.jid".join; | 2 local jid_join = require"util.jid".join; |
3 local jid_split = require"util.jid".split; | |
4 local host = module.host; | 3 local host = module.host; |
5 local sessions = hosts[host].sessions; | 4 local sessions = prosody.hosts[host].sessions; |
6 | 5 |
7 -- Make a *one-way* subscription. User will see when contact is online, | 6 -- Make a *one-way* subscription. User will see when contact is online, |
8 -- contact will not see when user is online. | 7 -- contact will not see when user is online. |
9 local function subscribe(user, contact) | 8 local function subscribe(user, contact) |
10 local user_jid, contact_jid = jid_join(user, host), jid_join(contact, host); | 9 local user_jid, contact_jid = jid_join(user, host), jid_join(contact, host); |
16 -- Update contact's roster to say subscription request approved... | 15 -- Update contact's roster to say subscription request approved... |
17 rostermanager.subscribed(contact, host, user_jid); | 16 rostermanager.subscribed(contact, host, user_jid); |
18 -- Update user's roster to say subscription request approved... | 17 -- Update user's roster to say subscription request approved... |
19 rostermanager.process_inbound_subscription_approval(user, host, contact_jid); | 18 rostermanager.process_inbound_subscription_approval(user, host, contact_jid); |
20 | 19 |
20 -- Push updates to both rosters | |
21 rostermanager.roster_push(user, host, contact_jid); | 21 rostermanager.roster_push(user, host, contact_jid); |
22 rostermanager.roster_push(contact, host, user_jid); | 22 rostermanager.roster_push(contact, host, user_jid); |
23 end | 23 end |
24 | 24 |
25 | 25 |
26 module:hook("resource-bind", function(event) | 26 module:hook("resource-bind", function(event) |
27 local session = event.session; | 27 local session = event.session; |
28 local roster = session.roster; | |
29 local user = session.username; | 28 local user = session.username; |
30 local user_jid = jid_join(user, host); | 29 local user_jid = jid_join(user, host); |
31 local contact_jid; | 30 for contact in pairs(sessions) do |
32 for contact, contact_session in pairs(sessions) do | |
33 if contact ~= user then | 31 if contact ~= user then |
34 contact_jid = jid_join(contact, host); | 32 local contact_jid = jid_join(contact, host); |
35 if not rostermanager.is_contact_subscribed(user, host, contact_jid) then | 33 if not rostermanager.is_contact_subscribed(user, host, contact_jid) then |
36 subscribe(contact, user); | 34 subscribe(contact, user); |
37 end | 35 end |
38 if not rostermanager.is_contact_subscribed(contact, host, user_jid) then | 36 if not rostermanager.is_contact_subscribed(contact, host, user_jid) then |
39 subscribe(user, contact); | 37 subscribe(user, contact); |