Annotate

mod_invites_tracking/mod_invites_tracking.lua @ 5931:d194d1012fd3

Updating dox for mod_rest. Ideas expressed / clarified: 1) Making clear that mod_rest isn't to be installed under VirtualHosts AND as a component. 2) Understanding some of the implications of this choice: A) Changes to user authentication B) How it affects subdomains 3) More consistent use of domain names for clarity. 4) Using different heading sizes to show scope of section. Essentially, I added all the tidbits I had to clarify in getting this to work in my own example.
author Ben Smith <bens@effortlessis.com>
date Mon, 13 May 2024 13:25:13 -0700
parent 5925:9ed02a4f6ff4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
5925
9ed02a4f6ff4 mod_invites_tracking: Don't bother storing anything for non-invite IBR
Matthew Wild <mwild1@gmail.com>
parents: 5924
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: 5924
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: 5924
diff changeset
9 return;
9ed02a4f6ff4 mod_invites_tracking: Don't bother storing anything for non-invite IBR
Matthew Wild <mwild1@gmail.com>
parents: 5924
diff changeset
10 end
9ed02a4f6ff4 mod_invites_tracking: Don't bother storing anything for non-invite IBR
Matthew Wild <mwild1@gmail.com>
parents: 5924
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
5924
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"});