mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-14 00:35:11 +00:00
[ADD] No-fly, forms
This commit is contained in:
parent
a880769c48
commit
df394172ec
11 changed files with 338 additions and 52 deletions
49
src/XMPPCommands/AddAdmin.c
Normal file
49
src/XMPPCommands/AddAdmin.c
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
#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);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue