[ADD/FIX] XMPP->Matrix mod, fix PL issue

This commit is contained in:
LDA 2024-07-09 12:35:43 +02:00
commit e7c44a05e2
7 changed files with 106 additions and 21 deletions

View file

@ -416,3 +416,39 @@ XMPPAnnotatePresence(XMLElement *presence)
Free(ver);
XMLAddChild(presence, c);
}
char *
XMPPGetModeration(XMLElement *stanza)
{
#define MOD_BASE "urn:xmpp:message-moderate"
XMLElement *moderate;
XMLElement *fasten;
if (!stanza)
{
return NULL;
}
/* 0.3.0 version of XEP-0425: Bare look at the moderate element */
moderate = XMLookForTKV(stanza, "moderate", "xmlns", MOD_BASE ":1");
if (moderate)
{
Log(LOG_WARNING, "0.3.0 moderation");
return HashMapGet(moderate->attrs, "id");
}
/* Earlier versions, which still depend on fastening. */
fasten = XMLookForTKV(
stanza, "apply-to",
"xmlns", "urn:xmpp:fasten:0"
);
moderate = XMLookForTKV(
fasten, "moderated",
"xmlns", MOD_BASE ":0"
);
if (moderate)
{
return HashMapGet(fasten->attrs, "id");
}
return NULL;
#undef MOD_BASE
}