[MOD] Make vcard-avatars XEP-0421 tier

This commit is contained in:
LDA 2024-07-21 16:31:32 +02:00
commit db10a70313
6 changed files with 89 additions and 4 deletions

View file

@ -5,6 +5,8 @@
#include <Cytoplasm/Log.h>
#include <Cytoplasm/Sha.h>
#include <Parsee.h>
#include <string.h>
char *
@ -193,7 +195,7 @@ char *
ParseeGetBridgedUserI(ParseeData *data, XMLElement *stanza, char *force)
{
char *user, *xmpp_from, *type;
char *decode_from, *occ_id = NULL;
char *decode_from, *occ_id = NULL, *looked = NULL;
bool is_chat, has_anon = false, is_anon = false;
if (!data || !stanza)
@ -209,10 +211,10 @@ ParseeGetBridgedUserI(ParseeData *data, XMLElement *stanza, char *force)
if (!is_chat)
{
has_anon = ServerHasXEP421(data, xmpp_from);
is_anon = has_anon && StrEquals(xmpp_from, decode_from);
is_anon = has_anon;// && StrEquals(xmpp_from, decode_from);
}
if (is_anon)
if (is_anon || force)
{
XMLElement *occupant;
occupant = XMLookForTKV(
@ -220,6 +222,15 @@ ParseeGetBridgedUserI(ParseeData *data, XMLElement *stanza, char *force)
"xmlns", "urn:xmpp:occupant-id:0"
);
occ_id = occupant ? HashMapGet(occupant->attrs, "id") : NULL;
if (!occ_id)
{
occ_id = ParseeLookupOID(xmpp_from);
looked = occ_id;
}
else
{
ParseePushOIDTable(xmpp_from, occ_id);
}
}
if (!occ_id)
@ -230,9 +241,11 @@ ParseeGetBridgedUserI(ParseeData *data, XMLElement *stanza, char *force)
type ? is_chat : false
);
Free(decode_from);
Free(looked);
return user;
}
Free(decode_from);
Free(looked);
return ScrambleOID(data, occ_id);
}

View file

@ -248,7 +248,7 @@ IQResult(ParseeData *args, XMLElement *stanza, XMPPThread *thr)
/* TODO: More reliable system for telling the difference appart */
if (jid && !StrEquals(from, resource))
{
from_matrix = ParseeEncodeJID(args->config, jid, false);
from_matrix = ParseeGetBridgedUserI(args, stanza, jid);
ASSetAvatar(args->config, from_matrix, mxc);
}
else if (room)