[ADD/WIP] Basic support for opting-out of bridging

This commit is contained in:
LDA 2024-09-25 22:09:11 +02:00
commit 749df0feb1
2 changed files with 33 additions and 4 deletions

View file

@ -416,6 +416,7 @@ ParseeMessageHandler(ParseeData *data, HashMap *event)
goto end;
}
/* TODO: Avoid using the AS endpoints */
name = ASGetName(data->config, id, m_sender);
Free(JoinMUC(data, event, encoded_from, muc_id, name));

View file

@ -109,6 +109,7 @@ PresenceStanza(ParseeData *args, XMLElement *stanza, XMPPThread *thr)
char *role = HashMapGet(item->attrs, "role");
int power_level = 0;
char *parsee = ParseeMXID(args);
char *parsee_j = ParseeJID(args);
Free(trim);
@ -144,8 +145,7 @@ PresenceStanza(ParseeData *args, XMLElement *stanza, XMPPThread *thr)
if (StrEquals(role, "visitor"))
{
char *parsee = ParseeJID(args);
if (!StrEquals(HashMapGet(stanza->attrs, "to"), parsee) &&
if (!StrEquals(HashMapGet(stanza->attrs, "to"), parsee_j) &&
IsStatus(110))
{
char *muc = ParseeTrimJID(HashMapGet(stanza->attrs, "from"));
@ -158,8 +158,6 @@ PresenceStanza(ParseeData *args, XMLElement *stanza, XMPPThread *thr)
Free(muc);
}
Free(parsee);
}
/* Set the user's PL
@ -213,12 +211,42 @@ PresenceStanza(ParseeData *args, XMLElement *stanza, XMPPThread *thr)
ASLeave(args->config, room, real_matrix);
}
}
if (StrEquals(type, "unavailable") &&
StrEquals(dst, parsee_j) &&
(IsStatus(301) || IsStatus(307)))
{
char *chat_id = ParseeGetFromRoomID(args, room);
char *muc = ParseeTrimJID(oid);
DbRef *ref;
ref = DbLock(args->db, 1, "chats");
JsonValueFree(HashMapDelete(
GrabObject(DbJson(ref), 1, "rooms"),
room
));
JsonValueFree(HashMapDelete(
GrabObject(DbJson(ref), 1, "mucs"),
muc
));
DbUnlock(args->db, ref);
DbDelete(args->db, 2, "chats", chat_id);
Free(ASSend(
args->config, room, parsee,
"m.room.message",
MatrixCreateNotice("This room has been unlinked.")
));
ASLeave(args->config, room, parsee);
Free(chat_id);
Free(muc);
}
Free(from);
Free(decode_from);
Free(real_matrix);
Free(matrix_user_pl);
Free(parsee_j);
Free(parsee);
Free(room);
}