mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-13 18:25:10 +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 && \
|
||||
StrEquals(HashMapGet(status->attrs, "code"), #code))
|
||||
char *jid = item ? HashMapGet(item->attrs, "jid") : NULL;
|
||||
char *trim = ParseeTrimJID(jid);
|
||||
char *from = NULL;
|
||||
char *type = HashMapGet(stanza->attrs, "type");
|
||||
char *room = ParseeGetBridgedRoom(args, stanza);
|
||||
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");
|
||||
int power_level = 0;
|
||||
char *parsee = ParseeMXID(args);
|
||||
|
||||
if (!from_matrix || *from_matrix != '@')
|
||||
Free(trim);
|
||||
|
||||
if (!real_matrix || *real_matrix != '@')
|
||||
{
|
||||
Free(from_matrix);
|
||||
from_matrix = ParseeEncodeJID(args->config, decode_from, false);
|
||||
Free(real_matrix);
|
||||
real_matrix = ParseeEncodeJID(args->config, decode_from, false);
|
||||
}
|
||||
|
||||
if (StrEquals(affiliation, "owner"))
|
||||
{
|
||||
power_level = 98;
|
||||
|
|
@ -1165,52 +1171,51 @@ PresenceStanza(ParseeData *args, XMLElement *stanza)
|
|||
if (room)
|
||||
{
|
||||
HashMap *powers = ASGetPL(args->config, room);
|
||||
int64_t level = GrabInteger(powers, 2, "users", from_matrix);
|
||||
char *parsee = ParseeMXID(args);
|
||||
HashMap *users = GrabObject(powers, 1, "users");
|
||||
int64_t level = GrabInteger(powers, 2, "users", matrix_user_pl);
|
||||
|
||||
/* I may or may not have fucked up the state hard with this
|
||||
* lacking any checking. (--gen) */
|
||||
if (StrEquals(parsee, from_matrix))
|
||||
if (StrEquals(parsee, matrix_user_pl))
|
||||
{
|
||||
/* TODO: Give the user an achievement, this is goofy. */
|
||||
Log(LOG_ERR, "BAD PL DOWNGRADE (%d->%d)", level, power_level);
|
||||
}
|
||||
if (powers && level != power_level &&
|
||||
!StrEquals(parsee, from_matrix))
|
||||
if (users && level != power_level &&
|
||||
!StrEquals(parsee, matrix_user_pl) &&
|
||||
matrix_user_pl)
|
||||
{
|
||||
HashMap *users = GrabObject(powers, 1, "users");
|
||||
JsonValue *val = JsonValueInteger(power_level);
|
||||
JsonValueFree(HashMapSet(users,
|
||||
from_matrix, val
|
||||
));
|
||||
JsonValueFree(JsonSet(users, val, 1, matrix_user_pl));
|
||||
ASSetPL(args->config, room, powers);
|
||||
JsonValueFree(val);
|
||||
}
|
||||
else
|
||||
{
|
||||
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 (IsStatus(301))
|
||||
{
|
||||
ASBan(args->config, room, from_matrix);
|
||||
ASBan(args->config, room, real_matrix);
|
||||
}
|
||||
else if (IsStatus(307))
|
||||
{
|
||||
ASKick(args->config, room, from_matrix);
|
||||
ASKick(args->config, room, real_matrix);
|
||||
}
|
||||
else if (IsStatus(303))
|
||||
{
|
||||
char *nick = HashMapGet(item->attrs, "nick");
|
||||
ASSetName(args->config, from_matrix, nick);
|
||||
ASSetName(args->config, real_matrix, nick);
|
||||
}
|
||||
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(decode_from);
|
||||
Free(from_matrix);
|
||||
Free(real_matrix);
|
||||
Free(matrix_user_pl);
|
||||
Free(parsee);
|
||||
Free(room);
|
||||
}
|
||||
else if (vc)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue