Mercurial > prosody-modules
annotate mod_invites_tracking/mod_invites_tracking.lua @ 6029:cc665f343690
mod_firewall: SUBSCRIBED: Flip subscription check to match documentation
The documentation claims that this condition checks whether the recipient is
subscribed to the sender.
However, it was using the wrong method, and actually checking whether the
sender was subscribed to the recipient.
A quick poll of folk suggested that the documentation's approach is the right
one, so this should fix the code to match the documentation.
This should also fix the bundled anti-spam rules from blocking presence from
JIDs that you subscribe do (but don't have a mutual subscription with).
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Fri, 22 Nov 2024 13:50:48 +0000 |
| parents | 9ed02a4f6ff4 |
| children |
| rev | line source |
|---|---|
|
4394
32f1f18f4874
mod_invites_tracking: simple module to store who created an invite
Jonas Schäfer <jonas@wielicki.name>
parents:
diff
changeset
|
1 local tracking_store = module:open_store("invites_tracking"); |
|
32f1f18f4874
mod_invites_tracking: simple module to store who created an invite
Jonas Schäfer <jonas@wielicki.name>
parents:
diff
changeset
|
2 |
|
32f1f18f4874
mod_invites_tracking: simple module to store who created an invite
Jonas Schäfer <jonas@wielicki.name>
parents:
diff
changeset
|
3 module:hook("user-registered", function(event) |
|
32f1f18f4874
mod_invites_tracking: simple module to store who created an invite
Jonas Schäfer <jonas@wielicki.name>
parents:
diff
changeset
|
4 local validated_invite = event.validated_invite or (event.session and event.session.validated_invite); |
|
32f1f18f4874
mod_invites_tracking: simple module to store who created an invite
Jonas Schäfer <jonas@wielicki.name>
parents:
diff
changeset
|
5 local new_username = event.username; |
|
32f1f18f4874
mod_invites_tracking: simple module to store who created an invite
Jonas Schäfer <jonas@wielicki.name>
parents:
diff
changeset
|
6 |
|
5901
9ed02a4f6ff4
mod_invites_tracking: Don't bother storing anything for non-invite IBR
Matthew Wild <mwild1@gmail.com>
parents:
5900
diff
changeset
|
7 if not validated_invite then |
|
9ed02a4f6ff4
mod_invites_tracking: Don't bother storing anything for non-invite IBR
Matthew Wild <mwild1@gmail.com>
parents:
5900
diff
changeset
|
8 module:log("debug", "No invitation found for registration of %s", new_username); |
|
9ed02a4f6ff4
mod_invites_tracking: Don't bother storing anything for non-invite IBR
Matthew Wild <mwild1@gmail.com>
parents:
5900
diff
changeset
|
9 return; |
|
9ed02a4f6ff4
mod_invites_tracking: Don't bother storing anything for non-invite IBR
Matthew Wild <mwild1@gmail.com>
parents:
5900
diff
changeset
|
10 end |
|
9ed02a4f6ff4
mod_invites_tracking: Don't bother storing anything for non-invite IBR
Matthew Wild <mwild1@gmail.com>
parents:
5900
diff
changeset
|
11 |
|
4394
32f1f18f4874
mod_invites_tracking: simple module to store who created an invite
Jonas Schäfer <jonas@wielicki.name>
parents:
diff
changeset
|
12 local invite_id = nil; |
|
32f1f18f4874
mod_invites_tracking: simple module to store who created an invite
Jonas Schäfer <jonas@wielicki.name>
parents:
diff
changeset
|
13 local invite_source = nil; |
|
32f1f18f4874
mod_invites_tracking: simple module to store who created an invite
Jonas Schäfer <jonas@wielicki.name>
parents:
diff
changeset
|
14 if validated_invite then |
|
32f1f18f4874
mod_invites_tracking: simple module to store who created an invite
Jonas Schäfer <jonas@wielicki.name>
parents:
diff
changeset
|
15 invite_source = validated_invite.additional_data and validated_invite.additional_data.source; |
|
32f1f18f4874
mod_invites_tracking: simple module to store who created an invite
Jonas Schäfer <jonas@wielicki.name>
parents:
diff
changeset
|
16 invite_id = validated_invite.token; |
|
32f1f18f4874
mod_invites_tracking: simple module to store who created an invite
Jonas Schäfer <jonas@wielicki.name>
parents:
diff
changeset
|
17 end |
|
32f1f18f4874
mod_invites_tracking: simple module to store who created an invite
Jonas Schäfer <jonas@wielicki.name>
parents:
diff
changeset
|
18 |
|
5900
cb3b2fbf57e7
mod_invites_tracking: Fix traceback when not registering via invite (thanks Link Mauve)
Matthew Wild <mwild1@gmail.com>
parents:
4394
diff
changeset
|
19 tracking_store:set(new_username, {invite_id = invite_id, invite_source = invite_source}); |
|
4394
32f1f18f4874
mod_invites_tracking: simple module to store who created an invite
Jonas Schäfer <jonas@wielicki.name>
parents:
diff
changeset
|
20 module:log("debug", "recorded that invite from %s was used to create %s", invite_source, new_username) |
|
32f1f18f4874
mod_invites_tracking: simple module to store who created an invite
Jonas Schäfer <jonas@wielicki.name>
parents:
diff
changeset
|
21 end); |
|
32f1f18f4874
mod_invites_tracking: simple module to store who created an invite
Jonas Schäfer <jonas@wielicki.name>
parents:
diff
changeset
|
22 |
|
32f1f18f4874
mod_invites_tracking: simple module to store who created an invite
Jonas Schäfer <jonas@wielicki.name>
parents:
diff
changeset
|
23 -- " " is an invalid localpart -> we can safely use it for store metadata |
|
32f1f18f4874
mod_invites_tracking: simple module to store who created an invite
Jonas Schäfer <jonas@wielicki.name>
parents:
diff
changeset
|
24 tracking_store:set(" ", {version="1"}); |
