mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-13 15:05:11 +00:00
[ADD/WIP] Basic support for opting-out of bridging
This commit is contained in:
parent
0f3253a385
commit
749df0feb1
2 changed files with 33 additions and 4 deletions
|
|
@ -416,6 +416,7 @@ ParseeMessageHandler(ParseeData *data, HashMap *event)
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* TODO: Avoid using the AS endpoints */
|
||||||
name = ASGetName(data->config, id, m_sender);
|
name = ASGetName(data->config, id, m_sender);
|
||||||
Free(JoinMUC(data, event, encoded_from, muc_id, name));
|
Free(JoinMUC(data, event, encoded_from, muc_id, name));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -109,6 +109,7 @@ PresenceStanza(ParseeData *args, XMLElement *stanza, XMPPThread *thr)
|
||||||
char *role = HashMapGet(item->attrs, "role");
|
char *role = HashMapGet(item->attrs, "role");
|
||||||
int power_level = 0;
|
int power_level = 0;
|
||||||
char *parsee = ParseeMXID(args);
|
char *parsee = ParseeMXID(args);
|
||||||
|
char *parsee_j = ParseeJID(args);
|
||||||
|
|
||||||
Free(trim);
|
Free(trim);
|
||||||
|
|
||||||
|
|
@ -144,8 +145,7 @@ PresenceStanza(ParseeData *args, XMLElement *stanza, XMPPThread *thr)
|
||||||
|
|
||||||
if (StrEquals(role, "visitor"))
|
if (StrEquals(role, "visitor"))
|
||||||
{
|
{
|
||||||
char *parsee = ParseeJID(args);
|
if (!StrEquals(HashMapGet(stanza->attrs, "to"), parsee_j) &&
|
||||||
if (!StrEquals(HashMapGet(stanza->attrs, "to"), parsee) &&
|
|
||||||
IsStatus(110))
|
IsStatus(110))
|
||||||
{
|
{
|
||||||
char *muc = ParseeTrimJID(HashMapGet(stanza->attrs, "from"));
|
char *muc = ParseeTrimJID(HashMapGet(stanza->attrs, "from"));
|
||||||
|
|
@ -158,8 +158,6 @@ PresenceStanza(ParseeData *args, XMLElement *stanza, XMPPThread *thr)
|
||||||
|
|
||||||
Free(muc);
|
Free(muc);
|
||||||
}
|
}
|
||||||
|
|
||||||
Free(parsee);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set the user's PL
|
/* Set the user's PL
|
||||||
|
|
@ -213,12 +211,42 @@ PresenceStanza(ParseeData *args, XMLElement *stanza, XMPPThread *thr)
|
||||||
ASLeave(args->config, room, real_matrix);
|
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(from);
|
||||||
Free(decode_from);
|
Free(decode_from);
|
||||||
Free(real_matrix);
|
Free(real_matrix);
|
||||||
Free(matrix_user_pl);
|
Free(matrix_user_pl);
|
||||||
|
Free(parsee_j);
|
||||||
Free(parsee);
|
Free(parsee);
|
||||||
Free(room);
|
Free(room);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue