mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-13 19:55:10 +00:00
[ADD/MOD] Cleanup cmd, change Matrix user format
This commit is contained in:
parent
9e5e741989
commit
91d373addb
13 changed files with 217 additions and 77 deletions
32
src/XMPPCommands/Cleanup.c
Normal file
32
src/XMPPCommands/Cleanup.c
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
#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
|
||||
CleanCallback(XMPPCommandManager *m, char *from, XMLElement *form, XMLElement *out)
|
||||
{
|
||||
ParseeData *data = XMPPGetManagerCookie(m);
|
||||
char *trimmed = ParseeTrimJID(from);
|
||||
|
||||
if (!ParseeIsAdmin(data, trimmed))
|
||||
{
|
||||
SetNote("error", "User is not authorised to execute command.");
|
||||
|
||||
Free(trimmed);
|
||||
return;
|
||||
}
|
||||
Free(trimmed);
|
||||
|
||||
ParseeCleanup(data);
|
||||
/* TODO: Cleanup old sessions? */
|
||||
SetNote("info", "Parsee data was sucessfully cleant up.");
|
||||
}
|
||||
|
|
@ -22,6 +22,7 @@ StatusCallback(XMPPCommandManager *m, char *from, XMLElement *form, XMLElement *
|
|||
size_t gb = mb >> 10;
|
||||
size_t min = gb ? gb : (mb ? mb : (kb ? kb : alloc));
|
||||
char *unit = gb ? "GB" : (mb ? "MB" : (kb ? "KB" : "B"));
|
||||
|
||||
XMLElement *x;
|
||||
XMLElement *title, *txt;
|
||||
|
||||
|
|
@ -52,6 +53,7 @@ StatusCallback(XMPPCommandManager *m, char *from, XMLElement *form, XMLElement *
|
|||
/* Report */
|
||||
Report("mem-alloc", "Heap allocated with Cytoplasm");
|
||||
Report("xml-congest", "Unprocessed stanzas(congestion)");
|
||||
Report("uptime", "Parsee uptime");
|
||||
|
||||
/* Set */
|
||||
BeginItem();
|
||||
|
|
@ -59,13 +61,16 @@ StatusCallback(XMPPCommandManager *m, char *from, XMLElement *form, XMLElement *
|
|||
char *min_str = StrInt(min);
|
||||
char *congest = StrInt(ParseeCongestion());
|
||||
char *alloc = StrConcat(3, min_str, " ", unit);
|
||||
char *up = ParseeStringifyDate(ParseeUptime());
|
||||
|
||||
SetField("mem-alloc", alloc);
|
||||
SetField("xml-congest", congest);
|
||||
SetField("uptime", up);
|
||||
|
||||
Free(congest);
|
||||
Free(min_str);
|
||||
Free(alloc);
|
||||
Free(up);
|
||||
}
|
||||
EndItem();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue