[MOD] Add x-parsee tag with metadata, global nicks

Still need to grab it on the room-level from the room state if possible,
otherwise just rollback to the MXID.

I also need to consider profile pictures and bridging media, and check
if the nick was present XMPP-side first, as that can and will cause
issues, especially around semi-anonymous MUCs.
This commit is contained in:
LDA 2024-06-22 22:43:58 +02:00
commit b820a441ed
9 changed files with 102 additions and 6 deletions

View file

@ -9,7 +9,7 @@
void
XMPPSendPlain(XMPPComponent *comp, char *fr, char *to, char *msg, char *type)
{
XMLElement *message, *body, *data;
XMLElement *message, *body, *data, *parsee;
char *from;
if (!comp || !fr || !to || !msg)
{
@ -24,7 +24,32 @@ XMPPSendPlain(XMPPComponent *comp, char *fr, char *to, char *msg, char *type)
body = XMLCreateTag("body");
data = XMLCreateText(msg);
/* TODO: Add Parsee specific fields here */
parsee = XMLCreateTag("x-parsee");
{
XMLElement *parsee_version, *ver_elem;
XMLElement *parsee_link, *link_elem;
XMLElement *parsee_text, *text_elem;
parsee_version = XMLCreateTag("version");
ver_elem = XMLCreateText(VERSION);
XMLAddChild(parsee_version, ver_elem);
XMLAddChild(parsee, parsee_version);
parsee_link = XMLCreateTag("repository");
link_elem = XMLCreateText(REPOSITORY);
XMLAddChild(parsee_link, link_elem);
XMLAddChild(parsee, parsee_link);
parsee_text = XMLCreateTag("zayds-note");
text_elem = XMLCreateText("\"LDA HANG YOURSELF\" - Zayd");
XMLAddChild(parsee_text, text_elem);
XMLAddChild(parsee, parsee_text);
/* TODO: Add custom fields depending on the caller's wishes */
}
XMLAddChild(message, body);
XMLAddChild(message, parsee);
XMLAddChild(body, data);
XMLEncode(comp->stream, message);
@ -122,3 +147,13 @@ XMPPIsKiller(XMLElement *stanza)
return StrEquals( HashMapGet(stanza->attrs, "from"),
HashMapGet(stanza->attrs, "to"));
}
bool
XMPPIsParseeStanza(XMLElement *stanza)
{
if (!stanza)
{
return false;
}
return !!XMLookForUnique(stanza, "x-parsee");
}