Comparison

mod_invites_adhoc/mod_invites_adhoc.lua @ 4409:44f6537f6427

mod_invites_adhoc: Fail contact invite if user is not on current host Only the username was being used, and the host of the requester ignored. Luckily this only affects admins of the host. If they want to create an account they can use the other command. If they want to create a contact they should request from their account on this host.
author Matthew Wild <mwild1@gmail.com>
date Thu, 28 Jan 2021 07:04:11 +0000
parent 4397:6e0aa163298f
child 4410:d1230d32d709
comparison
equal deleted inserted replaced
4408:2c47b8110c48 4409:44f6537f6427
42 -- If allow_user_invites is false, creating an invite still works, but the invite will 42 -- If allow_user_invites is false, creating an invite still works, but the invite will
43 -- not be valid for registration on the current server, only for establishing a roster 43 -- not be valid for registration on the current server, only for establishing a roster
44 -- subscription. 44 -- subscription.
45 module:provides("adhoc", new_adhoc("Create new contact invite", "urn:xmpp:invite#invite", 45 module:provides("adhoc", new_adhoc("Create new contact invite", "urn:xmpp:invite#invite",
46 function (_, data) 46 function (_, data)
47 local username = split_jid(data.from); 47 local username, host = split_jid(data.from);
48 if host ~= module.host then
49 return {
50 status = "completed";
51 error = {
52 message = "This command is only available to users of "..module.host;
53 };
54 };
55 end
48 local invite = invites.create_contact(username, allow_user_invites, { 56 local invite = invites.create_contact(username, allow_user_invites, {
49 source = data.from 57 source = data.from
50 }); 58 });
51 --TODO: check errors 59 --TODO: check errors
52 return { 60 return {