[MOD] Make no-fly follow globs

Just that.
This commit is contained in:
LDA 2024-07-06 19:33:35 +02:00
commit 5da9743cb1
2 changed files with 30 additions and 10 deletions

View file

@ -45,3 +45,7 @@ Not XEPs, but ideas that _needs_ to be added:
- "GIVE THE PUPPETS APPROPRIATE PLS/ROLES" - Hydro/t4d
"also it [Bifrost] doesn't respect voice either"
- https://www.youtube.com/watch?v=InL414iDZmY
------------------------- MSC LAND -------------------------
- MSC2346: Bridged metadata is useful, at least for other bridges.

View file

@ -9,6 +9,7 @@
#include <string.h>
#include <Routes.h>
#include <Glob.h>
#include <AS.h>
ParseeData *
@ -758,11 +759,11 @@ end:
}
void
ParseeGlobalBan(ParseeData *data, char *user, char *reason)
ParseeGlobalBan(ParseeData *data, char *glob, char *reason)
{
DbRef *ref;
HashMap *j, *obj;
if (!data || !user)
if (!data || !glob)
{
return;
}
@ -781,7 +782,7 @@ ParseeGlobalBan(ParseeData *data, char *user, char *reason)
HashMapSet(obj, "reason", JsonValueString(reason));
}
HashMapSet(obj, "date", JsonValueInteger(UtilTsMillis()));
JsonValueFree(HashMapSet(j, user, JsonValueObject(obj)));
JsonValueFree(HashMapSet(j, glob, JsonValueObject(obj)));
DbUnlock(data->db, ref);
}
@ -790,7 +791,9 @@ ParseeManageBan(ParseeData *data, char *user, char *room)
{
DbRef *ref;
HashMap *j;
bool banned;
char *key;
JsonValue *val;
bool banned = false , matches = false;
if (!data || !user)
{
return false;
@ -798,13 +801,26 @@ ParseeManageBan(ParseeData *data, char *user, char *room)
ref = DbLock(data->db, 1, "global_bans");
j = DbJson(ref);
banned = !!HashMapGet(j, user);
DbUnlock(data->db, ref);
if (banned && room)
while (HashMapIterate(j, &key, (void **) &val))
{
ASBan(data->config, room, user);
HashMap *obj = JsonValueAsObject(val);
if (matches)
{
continue;
}
if (GlobMatches(key, user))
{
banned = true;
matches = true;
if (room)
{
/* TODO: Use the object to set the reason */
ASBan(data->config, room, user);
(void) obj;
}
}
}
DbUnlock(data->db, ref);
return banned;
}