diff 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
parents 6e0aa163298f
children d1230d32d709
line wrap: on
line diff
--- a/mod_invites_adhoc/mod_invites_adhoc.lua	Wed Jan 27 16:10:08 2021 +0000
+++ b/mod_invites_adhoc/mod_invites_adhoc.lua	Thu Jan 28 07:04:11 2021 +0000
@@ -44,7 +44,15 @@
 -- subscription.
 module:provides("adhoc", new_adhoc("Create new contact invite", "urn:xmpp:invite#invite",
 		function (_, data)
-			local username = split_jid(data.from);
+			local username, host = split_jid(data.from);
+			if host ~= module.host then
+				return {
+					status = "completed";
+					error = {
+						message = "This command is only available to users of "..module.host;
+					};
+				};
+			end
 			local invite = invites.create_contact(username, allow_user_invites, {
 				source = data.from
 			});