mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-13 18:35:11 +00:00
[ADD/FIX/WIP] Allow reverting noflys, ignore MUC DMs (for now)
This commit is contained in:
parent
5e1931a19f
commit
0facbaa5e5
6 changed files with 74 additions and 11 deletions
|
|
@ -28,6 +28,25 @@ CommandHead(CmdBanUser, cmd, argp)
|
||||||
|
|
||||||
BotDestroy();
|
BotDestroy();
|
||||||
}
|
}
|
||||||
|
CommandHead(CmdNoFlyListDel, cmd, argp)
|
||||||
|
{
|
||||||
|
ParseeCmdArg *args = argp;
|
||||||
|
ParseeData *data = args->data;
|
||||||
|
HashMap *event = args->event;
|
||||||
|
char *user = HashMapGet(cmd->arguments, "user");
|
||||||
|
BotInitialise();
|
||||||
|
|
||||||
|
if (!user)
|
||||||
|
{
|
||||||
|
BotDestroy();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ReplySprintf("Unbanning %s", user);
|
||||||
|
ParseeGlobalUnban(data, user);
|
||||||
|
|
||||||
|
BotDestroy();
|
||||||
|
}
|
||||||
CommandHead(CmdNoFlyList, cmd, argp)
|
CommandHead(CmdNoFlyList, cmd, argp)
|
||||||
{
|
{
|
||||||
ParseeCmdArg *args = argp;
|
ParseeCmdArg *args = argp;
|
||||||
|
|
|
||||||
|
|
@ -291,10 +291,10 @@ GetXMPPInformation(ParseeData *data, HashMap *event, char **from, char **to)
|
||||||
char *room_id = GrabString(event, 1, "room_id");
|
char *room_id = GrabString(event, 1, "room_id");
|
||||||
char *matrix_sender = GrabString(event, 1, "sender");
|
char *matrix_sender = GrabString(event, 1, "sender");
|
||||||
char *chat_id = NULL, *muc_id = NULL;
|
char *chat_id = NULL, *muc_id = NULL;
|
||||||
char *user;
|
char *user = NULL;
|
||||||
|
|
||||||
DbRef *room_data;
|
DbRef *room_data = NULL;
|
||||||
HashMap *data_json;
|
HashMap *data_json = NULL;
|
||||||
|
|
||||||
bool direct = false;
|
bool direct = false;
|
||||||
if (!data || !event || !from || !to)
|
if (!data || !event || !from || !to)
|
||||||
|
|
@ -326,8 +326,8 @@ GetXMPPInformation(ParseeData *data, HashMap *event, char **from, char **to)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char *matrix_name, *matrix_avatar;
|
char *matrix_name = NULL, *matrix_avatar = NULL;
|
||||||
char *mime, *sha;
|
char *mime = NULL, *sha = NULL;
|
||||||
|
|
||||||
muc_id = ParseeGetMUCID(data, chat_id);
|
muc_id = ParseeGetMUCID(data, chat_id);
|
||||||
if (!chat_id)
|
if (!chat_id)
|
||||||
|
|
@ -361,9 +361,9 @@ static void
|
||||||
ParseeMessageHandler(ParseeData *data, HashMap *event)
|
ParseeMessageHandler(ParseeData *data, HashMap *event)
|
||||||
{
|
{
|
||||||
XMPPComponent *jabber = data->jabber;
|
XMPPComponent *jabber = data->jabber;
|
||||||
StanzaBuilder *builder;
|
StanzaBuilder *builder = NULL;
|
||||||
DbRef *ref = NULL;
|
DbRef *ref = NULL;
|
||||||
HashMap *json;
|
HashMap *json = NULL;
|
||||||
|
|
||||||
char *unedited_id = MatrixGetEdit(event);
|
char *unedited_id = MatrixGetEdit(event);
|
||||||
char *body = GrabString(event, 2, "content", "body");
|
char *body = GrabString(event, 2, "content", "body");
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,28 @@
|
||||||
#include <Glob.h>
|
#include <Glob.h>
|
||||||
#include <AS.h>
|
#include <AS.h>
|
||||||
|
|
||||||
|
void
|
||||||
|
ParseeGlobalUnban(ParseeData *data, char *glob)
|
||||||
|
{
|
||||||
|
DbRef *ref;
|
||||||
|
HashMap *j;
|
||||||
|
if (!data || !glob)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ref = DbLock(data->db, 1, "global_bans");
|
||||||
|
if (!ref)
|
||||||
|
{
|
||||||
|
ref = DbCreate(data->db, 1, "global_bans");
|
||||||
|
}
|
||||||
|
|
||||||
|
j = DbJson(ref);
|
||||||
|
|
||||||
|
JsonValueFree(HashMapDelete(j, glob));
|
||||||
|
|
||||||
|
DbUnlock(data->db, ref);
|
||||||
|
}
|
||||||
void
|
void
|
||||||
ParseeGlobalBan(ParseeData *data, char *glob, char *reason)
|
ParseeGlobalBan(ParseeData *data, char *glob, char *reason)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -394,11 +394,17 @@ end_error:
|
||||||
bool media_enabled = chat_id ?
|
bool media_enabled = chat_id ?
|
||||||
ParseeIsMediaEnabled(args, chat_id) :
|
ParseeIsMediaEnabled(args, chat_id) :
|
||||||
true ;
|
true ;
|
||||||
|
bool is_parsee;
|
||||||
|
/* Note that chat_id still has meaningful info as a boolean
|
||||||
|
* despite being freed */
|
||||||
Free(chat_id);
|
Free(chat_id);
|
||||||
|
|
||||||
pthread_mutex_unlock(&thr->info->chk_lock);
|
pthread_mutex_unlock(&thr->info->chk_lock);
|
||||||
|
|
||||||
|
parsee = ParseeJID(args);
|
||||||
|
is_parsee = StrEquals(to, parsee);
|
||||||
|
Free(parsee);
|
||||||
|
parsee = NULL;
|
||||||
|
|
||||||
LazyRegister(args, encoded, !chat ? res : NULL);
|
LazyRegister(args, encoded, !chat ? res : NULL);
|
||||||
if (args->verbosity >= PARSEE_VERBOSE_TIMINGS)
|
if (args->verbosity >= PARSEE_VERBOSE_TIMINGS)
|
||||||
{
|
{
|
||||||
|
|
@ -411,7 +417,12 @@ end_error:
|
||||||
|
|
||||||
/* Check if it is a media link */
|
/* Check if it is a media link */
|
||||||
oob = XMLookForTKV(stanza, "x", "xmlns", "jabber:x:oob");
|
oob = XMLookForTKV(stanza, "x", "xmlns", "jabber:x:oob");
|
||||||
if (oob && data && media_enabled)
|
if (chat_id && StrEquals(type, "chat") && !is_parsee)
|
||||||
|
{
|
||||||
|
/* Very clearly a MUC DM. */
|
||||||
|
event_id = NULL;
|
||||||
|
}
|
||||||
|
else if (oob && data && media_enabled)
|
||||||
{
|
{
|
||||||
char *mxc, *mime = NULL;
|
char *mxc, *mime = NULL;
|
||||||
HashMap *content = NULL;
|
HashMap *content = NULL;
|
||||||
|
|
|
||||||
|
|
@ -397,10 +397,17 @@ extern void ParseeDestroyNickTable(void);
|
||||||
* to ban them from rooms where Parsee has the ability to do so ("noflying").
|
* to ban them from rooms where Parsee has the ability to do so ("noflying").
|
||||||
* ---------------
|
* ---------------
|
||||||
* Returns: NOTHING
|
* Returns: NOTHING
|
||||||
* See-Also: ParseeManageBan
|
* See-Also: ParseeManageBan, ParseeGlobalUnban
|
||||||
* Modifies: the database */
|
* Modifies: the database */
|
||||||
extern void ParseeGlobalBan(ParseeData *, char *user, char *reason);
|
extern void ParseeGlobalBan(ParseeData *, char *user, char *reason);
|
||||||
|
|
||||||
|
/** Revokes a user/room/MUC's nofly status
|
||||||
|
* ---------------
|
||||||
|
* Returns: NOTHING
|
||||||
|
* See-Also: ParseeManageBan, ParseeGlobalBan
|
||||||
|
* Modifies: the database */
|
||||||
|
extern void ParseeGlobalUnban(ParseeData *, char *user);
|
||||||
|
|
||||||
/** Verifies if a user was banned globally. If so (and if {room} is set),
|
/** Verifies if a user was banned globally. If so (and if {room} is set),
|
||||||
* tries to ban the user from it.
|
* tries to ban the user from it.
|
||||||
* ---------------
|
* ---------------
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,10 @@ typedef struct ParseeCmdArg {
|
||||||
"ban-list", CmdNoFlyList, \
|
"ban-list", CmdNoFlyList, \
|
||||||
"Globally bans a user from using Parsee" \
|
"Globally bans a user from using Parsee" \
|
||||||
) \
|
) \
|
||||||
|
X_COMMAND( \
|
||||||
|
"unban-list", CmdNoFlyListDel, \
|
||||||
|
"Globally unbans a user from using Parsee" \
|
||||||
|
) \
|
||||||
X_COMMAND( \
|
X_COMMAND( \
|
||||||
"nuke-muc", CmdUnlinkMUC, \
|
"nuke-muc", CmdUnlinkMUC, \
|
||||||
"Removes a MUC. Users should then run " \
|
"Removes a MUC. Users should then run " \
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue