Annotate

mod_roster_allinall/mod_roster_allinall.lua @ 1683:cc3fad4198bc

mod_mam: Rename variable
author Kim Alvefur <zash@zash.se>
date Sun, 03 May 2015 13:27:53 +0200
parent 1545:a104a159697d
child 1798:3ae8c81a348b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1545
a104a159697d mod_roster_allinall: Adds all online users to the roster of newly signed in users, for a lazy everyone-in-everyones roster setup
Kim Alvefur <zash@zash.se>
parents:
diff changeset
1 local rostermanager = require"core.rostermanager";
a104a159697d mod_roster_allinall: Adds all online users to the roster of newly signed in users, for a lazy everyone-in-everyones roster setup
Kim Alvefur <zash@zash.se>
parents:
diff changeset
2 local jid_join = require"util.jid".join;
a104a159697d mod_roster_allinall: Adds all online users to the roster of newly signed in users, for a lazy everyone-in-everyones roster setup
Kim Alvefur <zash@zash.se>
parents:
diff changeset
3 local jid_split = require"util.jid".split;
a104a159697d mod_roster_allinall: Adds all online users to the roster of newly signed in users, for a lazy everyone-in-everyones roster setup
Kim Alvefur <zash@zash.se>
parents:
diff changeset
4 local host = module.host;
a104a159697d mod_roster_allinall: Adds all online users to the roster of newly signed in users, for a lazy everyone-in-everyones roster setup
Kim Alvefur <zash@zash.se>
parents:
diff changeset
5 local sessions = hosts[host].sessions;
a104a159697d mod_roster_allinall: Adds all online users to the roster of newly signed in users, for a lazy everyone-in-everyones roster setup
Kim Alvefur <zash@zash.se>
parents:
diff changeset
6
a104a159697d mod_roster_allinall: Adds all online users to the roster of newly signed in users, for a lazy everyone-in-everyones roster setup
Kim Alvefur <zash@zash.se>
parents:
diff changeset
7 -- Make a *one-way* subscription. User will see when contact is online,
a104a159697d mod_roster_allinall: Adds all online users to the roster of newly signed in users, for a lazy everyone-in-everyones roster setup
Kim Alvefur <zash@zash.se>
parents:
diff changeset
8 -- contact will not see when user is online.
a104a159697d mod_roster_allinall: Adds all online users to the roster of newly signed in users, for a lazy everyone-in-everyones roster setup
Kim Alvefur <zash@zash.se>
parents:
diff changeset
9 local function subscribe(user, contact)
a104a159697d mod_roster_allinall: Adds all online users to the roster of newly signed in users, for a lazy everyone-in-everyones roster setup
Kim Alvefur <zash@zash.se>
parents:
diff changeset
10 local user_jid, contact_jid = jid_join(user, host), jid_join(contact, host);
a104a159697d mod_roster_allinall: Adds all online users to the roster of newly signed in users, for a lazy everyone-in-everyones roster setup
Kim Alvefur <zash@zash.se>
parents:
diff changeset
11
a104a159697d mod_roster_allinall: Adds all online users to the roster of newly signed in users, for a lazy everyone-in-everyones roster setup
Kim Alvefur <zash@zash.se>
parents:
diff changeset
12 -- Update user's roster to say subscription request is pending...
a104a159697d mod_roster_allinall: Adds all online users to the roster of newly signed in users, for a lazy everyone-in-everyones roster setup
Kim Alvefur <zash@zash.se>
parents:
diff changeset
13 rostermanager.set_contact_pending_out(user, host, contact_jid);
a104a159697d mod_roster_allinall: Adds all online users to the roster of newly signed in users, for a lazy everyone-in-everyones roster setup
Kim Alvefur <zash@zash.se>
parents:
diff changeset
14 -- Update contact's roster to say subscription request is pending...
a104a159697d mod_roster_allinall: Adds all online users to the roster of newly signed in users, for a lazy everyone-in-everyones roster setup
Kim Alvefur <zash@zash.se>
parents:
diff changeset
15 rostermanager.set_contact_pending_in(contact, host, user_jid);
a104a159697d mod_roster_allinall: Adds all online users to the roster of newly signed in users, for a lazy everyone-in-everyones roster setup
Kim Alvefur <zash@zash.se>
parents:
diff changeset
16 -- Update contact's roster to say subscription request approved...
a104a159697d mod_roster_allinall: Adds all online users to the roster of newly signed in users, for a lazy everyone-in-everyones roster setup
Kim Alvefur <zash@zash.se>
parents:
diff changeset
17 rostermanager.subscribed(contact, host, user_jid);
a104a159697d mod_roster_allinall: Adds all online users to the roster of newly signed in users, for a lazy everyone-in-everyones roster setup
Kim Alvefur <zash@zash.se>
parents:
diff changeset
18 -- Update user's roster to say subscription request approved...
a104a159697d mod_roster_allinall: Adds all online users to the roster of newly signed in users, for a lazy everyone-in-everyones roster setup
Kim Alvefur <zash@zash.se>
parents:
diff changeset
19 rostermanager.process_inbound_subscription_approval(user, host, contact_jid);
a104a159697d mod_roster_allinall: Adds all online users to the roster of newly signed in users, for a lazy everyone-in-everyones roster setup
Kim Alvefur <zash@zash.se>
parents:
diff changeset
20
a104a159697d mod_roster_allinall: Adds all online users to the roster of newly signed in users, for a lazy everyone-in-everyones roster setup
Kim Alvefur <zash@zash.se>
parents:
diff changeset
21 rostermanager.roster_push(user, host, contact_jid);
a104a159697d mod_roster_allinall: Adds all online users to the roster of newly signed in users, for a lazy everyone-in-everyones roster setup
Kim Alvefur <zash@zash.se>
parents:
diff changeset
22 rostermanager.roster_push(contact, host, user_jid);
a104a159697d mod_roster_allinall: Adds all online users to the roster of newly signed in users, for a lazy everyone-in-everyones roster setup
Kim Alvefur <zash@zash.se>
parents:
diff changeset
23 end
a104a159697d mod_roster_allinall: Adds all online users to the roster of newly signed in users, for a lazy everyone-in-everyones roster setup
Kim Alvefur <zash@zash.se>
parents:
diff changeset
24
a104a159697d mod_roster_allinall: Adds all online users to the roster of newly signed in users, for a lazy everyone-in-everyones roster setup
Kim Alvefur <zash@zash.se>
parents:
diff changeset
25
a104a159697d mod_roster_allinall: Adds all online users to the roster of newly signed in users, for a lazy everyone-in-everyones roster setup
Kim Alvefur <zash@zash.se>
parents:
diff changeset
26 module:hook("resource-bind", function(event)
a104a159697d mod_roster_allinall: Adds all online users to the roster of newly signed in users, for a lazy everyone-in-everyones roster setup
Kim Alvefur <zash@zash.se>
parents:
diff changeset
27 local session = event.session;
a104a159697d mod_roster_allinall: Adds all online users to the roster of newly signed in users, for a lazy everyone-in-everyones roster setup
Kim Alvefur <zash@zash.se>
parents:
diff changeset
28 local roster = session.roster;
a104a159697d mod_roster_allinall: Adds all online users to the roster of newly signed in users, for a lazy everyone-in-everyones roster setup
Kim Alvefur <zash@zash.se>
parents:
diff changeset
29 local user = session.username;
a104a159697d mod_roster_allinall: Adds all online users to the roster of newly signed in users, for a lazy everyone-in-everyones roster setup
Kim Alvefur <zash@zash.se>
parents:
diff changeset
30 local user_jid = jid_join(user, host);
a104a159697d mod_roster_allinall: Adds all online users to the roster of newly signed in users, for a lazy everyone-in-everyones roster setup
Kim Alvefur <zash@zash.se>
parents:
diff changeset
31 local contact_jid;
a104a159697d mod_roster_allinall: Adds all online users to the roster of newly signed in users, for a lazy everyone-in-everyones roster setup
Kim Alvefur <zash@zash.se>
parents:
diff changeset
32 for contact, contact_session in pairs(sessions) do
a104a159697d mod_roster_allinall: Adds all online users to the roster of newly signed in users, for a lazy everyone-in-everyones roster setup
Kim Alvefur <zash@zash.se>
parents:
diff changeset
33 if contact ~= user then
a104a159697d mod_roster_allinall: Adds all online users to the roster of newly signed in users, for a lazy everyone-in-everyones roster setup
Kim Alvefur <zash@zash.se>
parents:
diff changeset
34 contact_jid = jid_join(contact, host);
a104a159697d mod_roster_allinall: Adds all online users to the roster of newly signed in users, for a lazy everyone-in-everyones roster setup
Kim Alvefur <zash@zash.se>
parents:
diff changeset
35 if not rostermanager.is_contact_subscribed(user, host, contact_jid) then
a104a159697d mod_roster_allinall: Adds all online users to the roster of newly signed in users, for a lazy everyone-in-everyones roster setup
Kim Alvefur <zash@zash.se>
parents:
diff changeset
36 subscribe(contact, user);
a104a159697d mod_roster_allinall: Adds all online users to the roster of newly signed in users, for a lazy everyone-in-everyones roster setup
Kim Alvefur <zash@zash.se>
parents:
diff changeset
37 end
a104a159697d mod_roster_allinall: Adds all online users to the roster of newly signed in users, for a lazy everyone-in-everyones roster setup
Kim Alvefur <zash@zash.se>
parents:
diff changeset
38 if not rostermanager.is_contact_subscribed(contact, host, user_jid) then
a104a159697d mod_roster_allinall: Adds all online users to the roster of newly signed in users, for a lazy everyone-in-everyones roster setup
Kim Alvefur <zash@zash.se>
parents:
diff changeset
39 subscribe(user, contact);
a104a159697d mod_roster_allinall: Adds all online users to the roster of newly signed in users, for a lazy everyone-in-everyones roster setup
Kim Alvefur <zash@zash.se>
parents:
diff changeset
40 end
a104a159697d mod_roster_allinall: Adds all online users to the roster of newly signed in users, for a lazy everyone-in-everyones roster setup
Kim Alvefur <zash@zash.se>
parents:
diff changeset
41 end
a104a159697d mod_roster_allinall: Adds all online users to the roster of newly signed in users, for a lazy everyone-in-everyones roster setup
Kim Alvefur <zash@zash.se>
parents:
diff changeset
42 end
a104a159697d mod_roster_allinall: Adds all online users to the roster of newly signed in users, for a lazy everyone-in-everyones roster setup
Kim Alvefur <zash@zash.se>
parents:
diff changeset
43 end);
a104a159697d mod_roster_allinall: Adds all online users to the roster of newly signed in users, for a lazy everyone-in-everyones roster setup
Kim Alvefur <zash@zash.se>
parents:
diff changeset
44