Mercurial > prosody-modules
annotate mod_roster_allinall/mod_roster_allinall.lua @ 5173:460f78654864
mod_muc_rtbl: also filter messages
This was a bit tricky because we don't want to run the JIDs
through SHA256 on each message. Took a while to come up with this
simple plan of just caching the SHA256 of the JIDs on the
occupants.
This will leave some dirt in the occupants after unloading the
module, but that should be ok; once they cycle the room, the
hashes will be gone.
This is direly needed, otherwise, there is a tight race between
the moderation activities and the actors joining the room.
author | Jonas Schäfer <jonas@wielicki.name> |
---|---|
date | Tue, 21 Feb 2023 21:37:27 +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 |