mod_invites_adhoc/mod_invites_adhoc.lua
changeset 4413 44f6537f6427
parent 4401 6e0aa163298f
child 4414 d1230d32d709
equal deleted inserted replaced
4412:2c47b8110c48 4413: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 {