Software /
code /
prosody-modules
Comparison
mod_invites_api/mod_invites_api.lua @ 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 |
parent | 5637:38783b8acbc9 |
child | 5639:1664bd4c274b |
comparison
equal
deleted
inserted
replaced
5637:38783b8acbc9 | 5638:4379e0e84ee5 |
---|---|
451 if not found then | 451 if not found then |
452 date = datetime.datetime(os_time); | 452 date = datetime.datetime(os_time); |
453 print("Error: Could not find "..arg_name_orig.." in "..domain); | 453 print("Error: Could not find "..arg_name_orig.." in "..domain); |
454 print(""); | 454 print(""); |
455 print("To make this API key, run:"); | 455 print("To make this API key, run:"); |
456 print("prosodyctl "..module.name.." create "..domain.." "..arg_name_orig); | 456 print("> prosodyctl "..module.name.." create "..domain.." "..arg_name_orig); |
457 return 1; | 457 return 1; |
458 end | 458 end |
459 return; | 459 return; |
460 end | 460 end |
461 elseif command == "renew" then | 461 elseif command == "renew" then |
482 end); | 482 end); |
483 if not found then | 483 if not found then |
484 print("Error: Could not find the key for "..username.."@"..domain); | 484 print("Error: Could not find the key for "..username.."@"..domain); |
485 print(""); | 485 print(""); |
486 print("To make this API key, run:"); | 486 print("To make this API key, run:"); |
487 print("prosodyctl "..module.name.." create "..username.."@"..domain); | 487 print("> prosodyctl "..module.name.." create "..username.."@"..domain); |
488 return 1; | 488 return 1; |
489 end | 489 end |
490 return; | 490 return; |
491 else | 491 else |
492 print("Error: "..username.."@"..domain.." does not exists."); | 492 print("Error: "..username.."@"..domain.." does not exists."); |
514 print(date, id.."/"..util_token, info.jid, info.name); | 514 print(date, id.."/"..util_token, info.jid, info.name); |
515 found = true; | 515 found = true; |
516 end | 516 end |
517 end); | 517 end); |
518 if not found then | 518 if not found then |
519 date = datetime.datetime(os_time); | |
520 print("Error: Could not find "..arg_name.." in "..domain); | 519 print("Error: Could not find "..arg_name.." in "..domain); |
521 print(""); | 520 print(""); |
522 print("To make this API key, run:"); | 521 print("To make this API key, run:"); |
523 print("prosodyctl "..module.name.." create "..domain.." "..arg_name); | 522 print("> prosodyctl "..module.name.." create "..domain.." "..arg_name); |
524 return 1; | 523 return 1; |
525 end | 524 end |
526 return; | 525 return; |
527 end | 526 end |
528 elseif command == "get" then | 527 elseif command == "get" then |
649 end | 648 end |
650 end); | 649 end); |
651 return; | 650 return; |
652 end | 651 end |
653 elseif command == "url" then | 652 elseif command == "url" then |
653 found = false; | |
654 local name = table.remove(arg, 1); | 654 local name = table.remove(arg, 1); |
655 if name and not username then | 655 if name and not username then |
656 get_value(function (id, info) | 656 get_value(function (id, info) |
657 if info.name == name then | 657 if info.name == name then |
658 print(get_url(id, info.token)); | 658 print(get_url(id, info.token)); |
659 end | 659 found = true; |
660 end); | 660 end |
661 end); | |
662 if not found then | |
663 date = datetime.datetime(os_time); | |
664 print("Error: Could not find "..name.." in "..domain); | |
665 print(""); | |
666 print("To make this API key, run:"); | |
667 print("> prosodyctl "..module.name.." create "..domain.." "..name); | |
668 return 1; | |
669 end | |
661 return; | 670 return; |
662 elseif username then | 671 elseif username then |
663 get_value(function (id, info) | 672 get_value(function (id, info) |
664 local j = jid.prepped_split(info.jid); | 673 local j = jid.prepped_split(info.jid); |
665 if j == username then | 674 if j == username then |
666 print(get_url(id, info.token)); | 675 print(get_url(id, info.token)); |
667 end | 676 found = true; |
668 end); | 677 end |
678 end); | |
679 if not found then | |
680 date = datetime.datetime(os_time); | |
681 print("Error: Could not find "..username.."@"..domain); | |
682 print(""); | |
683 print("To make this API key, run:"); | |
684 print("> prosodyctl "..module.name.." create "..username.."@"..domain); | |
685 return 1; | |
686 end | |
669 return; | 687 return; |
670 else | 688 else |
671 get_value(function (id, info) | 689 get_value(function (id, info) |
672 if info.jid == module.host then | 690 if info.jid == module.host then |
673 print(get_url(id, info.token), info.jid, info.name or "<unknown>"); | 691 print(get_url(id, info.token), info.jid, info.name or "<unknown>"); |