[ADD/WIP/AYA] Sending errors, voice reqs, Ayawork.

Ayaya!
This commit is contained in:
LDA 2024-08-05 19:45:57 +02:00
commit 8588a6fb5c
7 changed files with 197 additions and 5 deletions

View file

@ -24,7 +24,8 @@ MessageStanza(ParseeData *args, XMLElement *stanza, XMPPThread *thr)
char *retracted = XMPPGetRetractedID(stanza);
char *reply_to = XMPPGetReply(stanza);
char *moderated = XMPPGetModeration(stanza);
bool chat = StrEquals(HashMapGet(stanza->attrs, "type"), "chat");
char *type = HashMapGet(stanza->attrs, "type");
bool chat = StrEquals(type, "chat");
size_t i;
to = NULL;
@ -39,6 +40,45 @@ MessageStanza(ParseeData *args, XMLElement *stanza, XMPPThread *thr)
return false;
}
if (StrEquals(type, "error"))
{
char *type, *text, *user, *parsee;
char *message, *room;
from = HashMapGet(stanza->attrs, "from");
to = HashMapGet(stanza->attrs, "to");
/* Tiny little trick. */
XMLAddAttr(stanza, "type", "groupchat");
parsee = ParseeMXID(args);
type = XMPPGetErrtype(stanza);
text = XMPPGetErrtext(stanza);
user = ParseeDecodeMXID(to);
/* Avoid fun hypothetical cases of looping. */
if (StrEquals(parsee, user))
{
goto end_error;
}
message = StrConcat(3, type, ": ", text);
room = ParseeGetBridgedRoom(args, stanza);
Free(ASSend(
args->config, room, parsee,
"m.room.message",
MatrixCreateNotice(message)
));
end_error:
XMLFreeElement(stanza);
Free(message);
Free(parsee);
Free(room);
Free(user);
return false;
}
if (moderated)
{
/* TODO: Parsee MUST check if it is a valid MUC */