Changeset

5638:4379e0e84ee5

mod_invites_api: fix error messages when not `found`.
author Trần H. Trung <xmpp:trần.h.trung@trung.fun>
date Mon, 31 Jul 2023 13:15:54 +0700
parents 5637:38783b8acbc9
children 5639:1664bd4c274b
files mod_invites_api/mod_invites_api.lua
diffstat 1 files changed, 22 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mod_invites_api/mod_invites_api.lua	Mon Jul 31 12:49:04 2023 +0700
+++ b/mod_invites_api/mod_invites_api.lua	Mon Jul 31 13:15:54 2023 +0700
@@ -453,7 +453,7 @@
 				print("Error: Could not find "..arg_name_orig.." in "..domain);
 				print("");
 				print("To make this API key, run:");
-				print("prosodyctl "..module.name.." create "..domain.." "..arg_name_orig);
+				print("> prosodyctl "..module.name.." create "..domain.." "..arg_name_orig);
 				return 1;
 			end
 			return;
@@ -484,7 +484,7 @@
 					print("Error: Could not find the key for "..username.."@"..domain);
 					print("");
 					print("To make this API key, run:");
-					print("prosodyctl "..module.name.." create "..username.."@"..domain);
+					print("> prosodyctl "..module.name.." create "..username.."@"..domain);
 					return 1;
 				end
 				return;
@@ -516,11 +516,10 @@
 				end
 			end);
 			if not found then
-				date = datetime.datetime(os_time);
 				print("Error: Could not find "..arg_name.." in "..domain);
 				print("");
 				print("To make this API key, run:");
-				print("prosodyctl "..module.name.." create "..domain.." "..arg_name);
+				print("> prosodyctl "..module.name.." create "..domain.." "..arg_name);
 				return 1;
 			end
 			return;
@@ -651,21 +650,40 @@
 			return;
 		end
 	elseif command == "url" then
+		found = false;
 		local name = table.remove(arg, 1);
 		if name and not username then
 			get_value(function (id, info)
 				if info.name == name then
 					print(get_url(id, info.token));
+					found = true;
 				end
 			end);
+			if not found then
+				date = datetime.datetime(os_time);
+				print("Error: Could not find "..name.." in "..domain);
+				print("");
+				print("To make this API key, run:");
+				print("> prosodyctl "..module.name.." create "..domain.." "..name);
+				return 1;
+			end
 			return;
 		elseif username then
 			get_value(function (id, info)
 				local j = jid.prepped_split(info.jid);
 				if j == username then
 					print(get_url(id, info.token));
+					found = true;
 				end
 			end);
+			if not found then
+				date = datetime.datetime(os_time);
+				print("Error: Could not find "..username.."@"..domain);
+				print("");
+				print("To make this API key, run:");
+				print("> prosodyctl "..module.name.." create "..username.."@"..domain);
+				return 1;
+			end
 			return;
 		else
 			get_value(function (id, info)