Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
DisableKey.cs
1using System.Text.RegularExpressions;
2using System.Threading.Tasks;
4
6{
10 public class DisableKey : CommandRegEx
11 {
15 public DisableKey()
16 : base(@"^disable\s+key\s+(?'Key'[^\s]+)$")
17 {
18 }
19
23 public override string Name => "Disable";
24
33 public override async Task Execute(ChatState State, string[] Arguments, string OrgMessage, Match Details,
34 ResponseCallbackHandler ResponseCallback)
35 {
36 int c = Arguments.Length;
37 string Key = c < 2 ? string.Empty : Arguments[1];
38
39 ApiKey ApiKey = await XmppServerModule.PersistenceLayer.GetApiKey(Key);
40
41 if (ApiKey is null)
42 await XmppServerModule.SendErrorMessage("An API key with key `" + Key + "` does not exist.", string.Empty, ResponseCallback);
43 else
44 {
45 ApiKey.MaxAccounts = 0;
46 await Persistence.Database.Update(ApiKey);
47 await ResponseCallback("API key `" + Key + "` has been disabled.", string.Empty);
48 }
49 }
50
55 public override HelpItem[] GetHelp()
56 {
57 return new HelpItem[]
58 {
59 new HelpItem("disable key KEY", "Disables an existing API Key `KEY`. It is not possible to create more accounts using this key. Created accounts will continue to work however.")
60 };
61 }
62 }
63}
override async Task Execute(ChatState State, string[] Arguments, string OrgMessage, Match Details, ResponseCallbackHandler ResponseCallback)
Executes the command.
Definition: DisableKey.cs:33
override HelpItem[] GetHelp()
Gets help about the command.
Definition: DisableKey.cs:55
An administrative command whose syntax is validated with a regular expression.
Definition: CommandRegEx.cs:12
Contains an item of information about a command.
Definition: HelpItem.cs:9
Service Module hosting the XMPP broker and its components.
delegate Task< string > ResponseCallbackHandler(string Markdown, string MessageId)
Delegate for response callback handler methods.