[ADD/WIP] Two-way replies

Call me Seija Kijin the way I apply my Reverse Ideology.
This commit is contained in:
LDA 2024-06-29 22:00:29 +02:00
commit c5df636bdb
5 changed files with 44 additions and 1 deletions

View file

@ -90,6 +90,7 @@ MessageStanza(ParseeData *args, XMLElement *stanza)
char *id_str = HashMapGet(stanza->attrs, "id");
char *event_id = NULL;
char *replaced = XMPPGetReplacedID(stanza);
char *reply_to = XMPPGetReply(stanza);
if (ParseeVerifyStanza(args, chat_id, s_id_str) && !replaced)
{
@ -145,9 +146,23 @@ MessageStanza(ParseeData *args, XMLElement *stanza)
}
else
{
/* TODO: Use HTML-formatted bodies, and respect the fallback
* trims the stanza provides us if possible. Element does
* not like raw bodies on replies. Go figure. */
size_t off =
reply_to ? ParseeFindDatastart(data->data) : 0;
HashMap *ev = MatrixCreateMessage(data->data + off);
if (reply_to)
{
char *reply_id = ParseeEventFromSID(
args, chat_id, reply_to
);
MatrixSetReply(ev, reply_id);
Free(reply_id);
}
event_id = ASSend(
args->config, mroom_id, encoded,
"m.room.message", MatrixCreateMessage(data->data)
"m.room.message", ev
);
}
ParseePushStanza(args, chat_id, s_id_str, id_str, event_id, from);