Comparison

mod_invites_tracking/mod_invites_tracking.lua @ 4394:32f1f18f4874

mod_invites_tracking: simple module to store who created an invite
author Jonas Schäfer <jonas@wielicki.name>
date Tue, 26 Jan 2021 16:05:49 +0100
child 5924:cb3b2fbf57e7
comparison
equal deleted inserted replaced
4393:ae1d1e352504 4394:32f1f18f4874
1 local tracking_store = module:open_store("invites_tracking");
2
3 module:hook("user-registered", function(event)
4 local validated_invite = event.validated_invite or (event.session and event.session.validated_invite);
5 local new_username = event.username;
6
7 local invite_id = nil;
8 local invite_source = nil;
9 if validated_invite then
10 invite_source = validated_invite.additional_data and validated_invite.additional_data.source;
11 invite_id = validated_invite.token;
12 end
13
14 tracking_store:set(new_username, {invite_id = validated_invite.token, invite_source = invite_source});
15 module:log("debug", "recorded that invite from %s was used to create %s", invite_source, new_username)
16 end);
17
18 -- " " is an invalid localpart -> we can safely use it for store metadata
19 tracking_store:set(" ", {version="1"});