comparison mod_invites/mod_invites.lua @ 4347:0ec482e617bb

mod_invites: Add public API method for creating group invites
author Matthew Wild <mwild1@gmail.com>
date Sun, 17 Jan 2021 17:43:53 +0000
parents 671bc55f0fc9
children a49ca492e621
comparison
equal deleted inserted replaced
4346:671bc55f0fc9 4347:0ec482e617bb
77 end 77 end
78 78
79 -- Create invitation to become a contact of a local user 79 -- Create invitation to become a contact of a local user
80 function create_contact(username, allow_registration, additional_data) --luacheck: ignore 131/create_contact 80 function create_contact(username, allow_registration, additional_data) --luacheck: ignore 131/create_contact
81 return create_invite("roster", username.."@"..module.host, allow_registration, additional_data); 81 return create_invite("roster", username.."@"..module.host, allow_registration, additional_data);
82 end
83
84 -- Create invitation to register an account and join a user group
85 -- If explicit ttl is passed, invite is valid for multiple signups
86 -- during that time period
87 function create_group(group_id, ttl, additional_data) --luacheck: ignore 131/create_group
88 local merged_additional_data = {
89 groups = { group_id };
90 };
91 if merged_additional_data then
92 for k, v in pairs(additional_data) do
93 merged_additional_data[k] = v;
94 end
95 end
96 return create_invite("register", module.host, true, merged_additional_data, ttl, not not ttl);
82 end 97 end
83 98
84 -- Iterates pending (non-expired, unused) invites that allow registration 99 -- Iterates pending (non-expired, unused) invites that allow registration
85 function pending_account_invites() --luacheck: ignore 131/pending_account_invites 100 function pending_account_invites() --luacheck: ignore 131/pending_account_invites
86 local store = module:open_store("invite_token"); 101 local store = module:open_store("invite_token");