mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-13 12:15:12 +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();
|
||||
}
|
||||
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)
|
||||
{
|
||||
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 *matrix_sender = GrabString(event, 1, "sender");
|
||||
char *chat_id = NULL, *muc_id = NULL;
|
||||
char *user;
|
||||
char *user = NULL;
|
||||
|
||||
DbRef *room_data;
|
||||
HashMap *data_json;
|
||||
DbRef *room_data = NULL;
|
||||
HashMap *data_json = NULL;
|
||||
|
||||
bool direct = false;
|
||||
if (!data || !event || !from || !to)
|
||||
|
|
@ -326,8 +326,8 @@ GetXMPPInformation(ParseeData *data, HashMap *event, char **from, char **to)
|
|||
}
|
||||
else
|
||||
{
|
||||
char *matrix_name, *matrix_avatar;
|
||||
char *mime, *sha;
|
||||
char *matrix_name = NULL, *matrix_avatar = NULL;
|
||||
char *mime = NULL, *sha = NULL;
|
||||
|
||||
muc_id = ParseeGetMUCID(data, chat_id);
|
||||
if (!chat_id)
|
||||
|
|
@ -361,9 +361,9 @@ static void
|
|||
ParseeMessageHandler(ParseeData *data, HashMap *event)
|
||||
{
|
||||
XMPPComponent *jabber = data->jabber;
|
||||
StanzaBuilder *builder;
|
||||
StanzaBuilder *builder = NULL;
|
||||
DbRef *ref = NULL;
|
||||
HashMap *json;
|
||||
HashMap *json = NULL;
|
||||
|
||||
char *unedited_id = MatrixGetEdit(event);
|
||||
char *body = GrabString(event, 2, "content", "body");
|
||||
|
|
|
|||
|
|
@ -6,6 +6,28 @@
|
|||
#include <Glob.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
|
||||
ParseeGlobalBan(ParseeData *data, char *glob, char *reason)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -394,11 +394,17 @@ end_error:
|
|||
bool media_enabled = chat_id ?
|
||||
ParseeIsMediaEnabled(args, chat_id) :
|
||||
true ;
|
||||
|
||||
bool is_parsee;
|
||||
/* Note that chat_id still has meaningful info as a boolean
|
||||
* despite being freed */
|
||||
Free(chat_id);
|
||||
|
||||
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);
|
||||
if (args->verbosity >= PARSEE_VERBOSE_TIMINGS)
|
||||
{
|
||||
|
|
@ -411,7 +417,12 @@ end_error:
|
|||
|
||||
/* Check if it is a media link */
|
||||
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;
|
||||
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").
|
||||
* ---------------
|
||||
* Returns: NOTHING
|
||||
* See-Also: ParseeManageBan
|
||||
* See-Also: ParseeManageBan, ParseeGlobalUnban
|
||||
* Modifies: the database */
|
||||
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),
|
||||
* tries to ban the user from it.
|
||||
* ---------------
|
||||
|
|
|
|||
|
|
@ -27,6 +27,10 @@ typedef struct ParseeCmdArg {
|
|||
"ban-list", CmdNoFlyList, \
|
||||
"Globally bans a user from using Parsee" \
|
||||
) \
|
||||
X_COMMAND( \
|
||||
"unban-list", CmdNoFlyListDel, \
|
||||
"Globally unbans a user from using Parsee" \
|
||||
) \
|
||||
X_COMMAND( \
|
||||
"nuke-muc", CmdUnlinkMUC, \
|
||||
"Removes a MUC. Users should then run " \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue