Mercurial > prosody-modules
annotate mod_roster_allinall/mod_roster_allinall.lua @ 3470:c0fc739a1b81
mod_delay: Remove this module, it is never useful
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Sun, 24 Feb 2019 01:02:30 +0100 |
parents | 3ae8c81a348b |
children |
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 host = module.host; |
1798
3ae8c81a348b
mod_roster_allinall: Cleanup, remove unused variables [luacheck]
Kim Alvefur <zash@zash.se>
parents:
1545
diff
changeset
|
4 local sessions = prosody.hosts[host].sessions; |
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
|
5 |
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 -- 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
|
7 -- 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
|
8 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
|
9 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
|
10 |
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 -- 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
|
12 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
|
13 -- 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
|
14 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
|
15 -- 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
|
16 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
|
17 -- 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
|
18 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
|
19 |
1798
3ae8c81a348b
mod_roster_allinall: Cleanup, remove unused variables [luacheck]
Kim Alvefur <zash@zash.se>
parents:
1545
diff
changeset
|
20 -- Push updates to both rosters |
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
|
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 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
|
29 local user_jid = jid_join(user, host); |
1798
3ae8c81a348b
mod_roster_allinall: Cleanup, remove unused variables [luacheck]
Kim Alvefur <zash@zash.se>
parents:
1545
diff
changeset
|
30 for contact in pairs(sessions) do |
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
|
31 if contact ~= user then |
1798
3ae8c81a348b
mod_roster_allinall: Cleanup, remove unused variables [luacheck]
Kim Alvefur <zash@zash.se>
parents:
1545
diff
changeset
|
32 local contact_jid = jid_join(contact, host); |
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
|
33 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
|
34 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
|
35 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
|
36 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
|
37 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
|
38 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
|
39 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
|
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 |