mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-13 18:25:10 +00:00
48 lines
1 KiB
C
48 lines
1 KiB
C
#include <Cytoplasm/HashMap.h>
|
|
#include <Cytoplasm/Memory.h>
|
|
#include <Cytoplasm/Json.h>
|
|
#include <Cytoplasm/Util.h>
|
|
#include <Cytoplasm/Str.h>
|
|
#include <Cytoplasm/Log.h>
|
|
|
|
#include <XMPPFormTool.h>
|
|
#include <XMPPCommand.h>
|
|
#include <Parsee.h>
|
|
#include <XMPP.h>
|
|
#include <XML.h>
|
|
|
|
void
|
|
AddAdminCallback(XMPPCommandManager *m, char *from, XMLElement *form, XMLElement *out)
|
|
{
|
|
ParseeData *data = XMPPGetManagerCookie(m);
|
|
char *trimmed = ParseeTrimJID(from);
|
|
char *glob = NULL;
|
|
|
|
DbRef *ref;
|
|
Array *admins;
|
|
|
|
GetFieldValue(glob, "glob", form);
|
|
|
|
if (!ParseeIsAdmin(data, trimmed))
|
|
{
|
|
SetNote("error", "User is not authorised to execute command.");
|
|
|
|
Free(trimmed);
|
|
return;
|
|
}
|
|
if (!glob)
|
|
{
|
|
SetNote("error", "No glob found.");
|
|
Free(trimmed);
|
|
return;
|
|
}
|
|
|
|
Free(trimmed);
|
|
|
|
SetNote("info", "Glob sucessfully added.");
|
|
|
|
ref = DbLock(data->db, 1, "admins");
|
|
admins = GrabArray(DbJson(ref), 1, "admins");
|
|
ArrayAdd(admins, JsonValueString(glob));
|
|
DbUnlock(data->db, ref);
|
|
}
|