mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-13 21:15:11 +00:00
[MOD] Make PL changes not point the real user
This commit is contained in:
parent
1035603b9f
commit
80ed79402a
1 changed files with 27 additions and 20 deletions
|
|
@ -1127,19 +1127,25 @@ PresenceStanza(ParseeData *args, XMLElement *stanza)
|
||||||
#define IsStatus(code) (status && \
|
#define IsStatus(code) (status && \
|
||||||
StrEquals(HashMapGet(status->attrs, "code"), #code))
|
StrEquals(HashMapGet(status->attrs, "code"), #code))
|
||||||
char *jid = item ? HashMapGet(item->attrs, "jid") : NULL;
|
char *jid = item ? HashMapGet(item->attrs, "jid") : NULL;
|
||||||
|
char *trim = ParseeTrimJID(jid);
|
||||||
char *from = NULL;
|
char *from = NULL;
|
||||||
char *type = HashMapGet(stanza->attrs, "type");
|
char *type = HashMapGet(stanza->attrs, "type");
|
||||||
char *room = ParseeGetBridgedRoom(args, stanza);
|
char *room = ParseeGetBridgedRoom(args, stanza);
|
||||||
char *decode_from = ParseeLookupJID(oid);
|
char *decode_from = ParseeLookupJID(oid);
|
||||||
char *from_matrix = ParseeDecodeMXID(decode_from);
|
char *real_matrix = ParseeDecodeMXID(decode_from);
|
||||||
|
char *matrix_user_pl = ParseeEncodeJID(args->config, trim, false);
|
||||||
char *affiliation = HashMapGet(item->attrs, "affiliation");
|
char *affiliation = HashMapGet(item->attrs, "affiliation");
|
||||||
int power_level = 0;
|
int power_level = 0;
|
||||||
|
char *parsee = ParseeMXID(args);
|
||||||
|
|
||||||
if (!from_matrix || *from_matrix != '@')
|
Free(trim);
|
||||||
|
|
||||||
|
if (!real_matrix || *real_matrix != '@')
|
||||||
{
|
{
|
||||||
Free(from_matrix);
|
Free(real_matrix);
|
||||||
from_matrix = ParseeEncodeJID(args->config, decode_from, false);
|
real_matrix = ParseeEncodeJID(args->config, decode_from, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StrEquals(affiliation, "owner"))
|
if (StrEquals(affiliation, "owner"))
|
||||||
{
|
{
|
||||||
power_level = 98;
|
power_level = 98;
|
||||||
|
|
@ -1165,52 +1171,51 @@ PresenceStanza(ParseeData *args, XMLElement *stanza)
|
||||||
if (room)
|
if (room)
|
||||||
{
|
{
|
||||||
HashMap *powers = ASGetPL(args->config, room);
|
HashMap *powers = ASGetPL(args->config, room);
|
||||||
int64_t level = GrabInteger(powers, 2, "users", from_matrix);
|
HashMap *users = GrabObject(powers, 1, "users");
|
||||||
char *parsee = ParseeMXID(args);
|
int64_t level = GrabInteger(powers, 2, "users", matrix_user_pl);
|
||||||
|
|
||||||
/* I may or may not have fucked up the state hard with this
|
/* I may or may not have fucked up the state hard with this
|
||||||
* lacking any checking. (--gen) */
|
* lacking any checking. (--gen) */
|
||||||
if (StrEquals(parsee, from_matrix))
|
if (StrEquals(parsee, matrix_user_pl))
|
||||||
{
|
{
|
||||||
/* TODO: Give the user an achievement, this is goofy. */
|
/* TODO: Give the user an achievement, this is goofy. */
|
||||||
Log(LOG_ERR, "BAD PL DOWNGRADE (%d->%d)", level, power_level);
|
Log(LOG_ERR, "BAD PL DOWNGRADE (%d->%d)", level, power_level);
|
||||||
}
|
}
|
||||||
if (powers && level != power_level &&
|
if (users && level != power_level &&
|
||||||
!StrEquals(parsee, from_matrix))
|
!StrEquals(parsee, matrix_user_pl) &&
|
||||||
|
matrix_user_pl)
|
||||||
{
|
{
|
||||||
HashMap *users = GrabObject(powers, 1, "users");
|
|
||||||
JsonValue *val = JsonValueInteger(power_level);
|
JsonValue *val = JsonValueInteger(power_level);
|
||||||
JsonValueFree(HashMapSet(users,
|
JsonValueFree(JsonSet(users, val, 1, matrix_user_pl));
|
||||||
from_matrix, val
|
|
||||||
));
|
|
||||||
ASSetPL(args->config, room, powers);
|
ASSetPL(args->config, room, powers);
|
||||||
|
JsonValueFree(val);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
JsonFree(powers);
|
JsonFree(powers);
|
||||||
}
|
}
|
||||||
Free(parsee);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StrEquals(type, "unavailable"))
|
|
||||||
|
if (StrEquals(type, "unavailable") && !StrEquals(parsee, real_matrix))
|
||||||
{
|
{
|
||||||
/* If not an MXID, use the Parsee user */
|
/* If not an MXID, use the Parsee user */
|
||||||
if (IsStatus(301))
|
if (IsStatus(301))
|
||||||
{
|
{
|
||||||
ASBan(args->config, room, from_matrix);
|
ASBan(args->config, room, real_matrix);
|
||||||
}
|
}
|
||||||
else if (IsStatus(307))
|
else if (IsStatus(307))
|
||||||
{
|
{
|
||||||
ASKick(args->config, room, from_matrix);
|
ASKick(args->config, room, real_matrix);
|
||||||
}
|
}
|
||||||
else if (IsStatus(303))
|
else if (IsStatus(303))
|
||||||
{
|
{
|
||||||
char *nick = HashMapGet(item->attrs, "nick");
|
char *nick = HashMapGet(item->attrs, "nick");
|
||||||
ASSetName(args->config, from_matrix, nick);
|
ASSetName(args->config, real_matrix, nick);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ASLeave(args->config, room, from_matrix);
|
ASLeave(args->config, room, real_matrix);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1221,7 +1226,9 @@ PresenceStanza(ParseeData *args, XMLElement *stanza)
|
||||||
|
|
||||||
Free(from);
|
Free(from);
|
||||||
Free(decode_from);
|
Free(decode_from);
|
||||||
Free(from_matrix);
|
Free(real_matrix);
|
||||||
|
Free(matrix_user_pl);
|
||||||
|
Free(parsee);
|
||||||
Free(room);
|
Free(room);
|
||||||
}
|
}
|
||||||
else if (vc)
|
else if (vc)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue