[FIX] Somewhat fix semianon avatars

This commit is contained in:
LDA 2024-07-16 18:32:08 +02:00
commit a4b8141f4a

View file

@ -802,7 +802,6 @@ IQGenerateQuery(void)
} \ } \
while (0); while (0);
/* TODO: Advertise more things */
IQ_ADVERT IQ_ADVERT
#undef AdvertiseSimple #undef AdvertiseSimple
} }
@ -953,15 +952,7 @@ IQResult(ParseeData *args, XMLElement *stanza, XMPPThread *thr)
if (vcard) if (vcard)
{ {
XMLElement *photo = XMLookForUnique(vcard, "PHOTO"); XMLElement *photo = XMLookForUnique(vcard, "PHOTO");
XMLElement *nickname = XMLookForUnique(vcard, "NICKNAME");
if (nickname)
{
XMLElement *data = ArrayGet(nickname->children, 0);
/* TODO: Use the nickname for something.
* And the rest of the vCard, somewhere. */
(void) data;
}
if (photo) if (photo)
{ {
XMLElement *binval = XMLookForUnique(photo, "BINVAL"); XMLElement *binval = XMLookForUnique(photo, "BINVAL");
@ -974,7 +965,8 @@ IQResult(ParseeData *args, XMLElement *stanza, XMPPThread *thr)
size_t length, b64len; size_t length, b64len;
Stream *datastream; Stream *datastream;
char *mxc = NULL, *from_matrix = NULL, *jid = NULL; char *mxc = NULL, *from_matrix = NULL, *jid = NULL;
char *room = NULL; char *room = NULL, *resource;
char *from = HashMapGet(stanza->attrs, "from");
if (!data || !data->data) if (!data || !data->data)
{ {
Log(LOG_ERR, "%s NOT FOUND", HashMapGet(stanza->attrs, "from")); Log(LOG_ERR, "%s NOT FOUND", HashMapGet(stanza->attrs, "from"));
@ -1000,17 +992,18 @@ IQResult(ParseeData *args, XMLElement *stanza, XMPPThread *thr)
room = ParseeGetBridgedRoom(args, stanza); room = ParseeGetBridgedRoom(args, stanza);
jid = ParseeLookupJID(HashMapGet(stanza->attrs, "from")); jid = ParseeLookupJID(HashMapGet(stanza->attrs, "from"));
if (jid && !StrEquals(jid, HashMapGet(stanza->attrs, "from")))
resource = ParseeTrimJID(from);
/* TODO: More reliable system for telling the difference appart */
if (jid && !StrEquals(from, resource))
{ {
from_matrix = ParseeEncodeJID(args->config, jid, false); from_matrix = ParseeEncodeJID(args->config, jid, false);
ASSetAvatar(args->config, from_matrix, mxc); ASSetAvatar(args->config, from_matrix, mxc);
} }
else if (room) else if (room)
{ {
char *mask = StrConcat(4, char *mask = ParseeMXID(args);
"@", args->config->sender_localpart,
":", args->config->homeserver_host
);
HashMap *obj = HashMapCreate(); HashMap *obj = HashMapCreate();
HashMapSet(obj, "url", JsonValueString(mxc)); HashMapSet(obj, "url", JsonValueString(mxc));
@ -1023,6 +1016,7 @@ IQResult(ParseeData *args, XMLElement *stanza, XMPPThread *thr)
} }
Free(from_matrix); Free(from_matrix);
Free(resource);
Free(room); Free(room);
Free(jid); Free(jid);
Free(mxc); Free(mxc);