Mercurial > prosody-modules
comparison mod_invites/mod_invites.lua @ 4079:b68b917e568f
mod_invites: Include invite type and uri in validated invites (from Snikket)
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Mon, 07 Sep 2020 13:02:51 +0100 |
| parents | 2f0c8670d2fa |
| children | 14a3f5223074 |
comparison
equal
deleted
inserted
replaced
| 4078:2f0c8670d2fa | 4079:b68b917e568f |
|---|---|
| 99 return nil, "no-token"; | 99 return nil, "no-token"; |
| 100 end | 100 end |
| 101 | 101 |
| 102 local valid_until, inviter; | 102 local valid_until, inviter; |
| 103 | 103 |
| 104 -- Fetch from host store (account invite) | |
| 105 local token_info = token_storage:get(nil, token); | |
| 106 | |
| 104 if username then -- token being used for subscription | 107 if username then -- token being used for subscription |
| 105 -- Fetch from user store (subscription invite) | 108 -- Fetch from user store (subscription invite) |
| 106 valid_until = token_storage:get(username, token); | 109 valid_until = token_storage:get(username, token); |
| 107 else -- token being used for account creation | 110 else -- token being used for account creation |
| 108 -- Fetch from host store (account invite) | |
| 109 local token_info = token_storage:get(nil, token); | |
| 110 valid_until = token_info and token_info.expires; | 111 valid_until = token_info and token_info.expires; |
| 111 if token_info.type == "roster" then | 112 if token_info.type == "roster" then |
| 112 username = jid_node(token_info.jid); | 113 username = jid_node(token_info.jid); |
| 113 inviter = username; | 114 inviter = username; |
| 114 end | 115 end |
| 124 | 125 |
| 125 return setmetatable({ | 126 return setmetatable({ |
| 126 token = token; | 127 token = token; |
| 127 username = username; | 128 username = username; |
| 128 inviter = inviter; | 129 inviter = inviter; |
| 130 type = token_info and token_info.type or "roster"; | |
| 131 uri = token_info and token_info.uri or get_uri("roster", username.."@"..module.host, token); | |
| 129 additional_data = token_info and token_info.additional_data or nil; | 132 additional_data = token_info and token_info.additional_data or nil; |
| 130 }, valid_invite_mt); | 133 }, valid_invite_mt); |
| 131 end | 134 end |
| 132 | 135 |
| 133 function use(token) --luacheck: ignore 131/use | 136 function use(token) --luacheck: ignore 131/use |
