[FIX] BMP for MUC nicks, dip toes in vCard avatars

Can, your, Bifrost, Do, That. -lh
This commit is contained in:
LDA 2024-09-21 13:18:59 +02:00
commit 6167732e83
6 changed files with 378 additions and 17 deletions

View file

@ -356,14 +356,14 @@ IQGet(ParseeData *args, XMLElement *stanza, XMPPThread *thr)
}
else if (XMLookForTKV(stanza, "vCard", "xmlns", "vcard-temp"))
{
Log(LOG_INFO, "vCard information GET for %s", to);
char *to_matrix = ParseeGetBridgedUser(args, stanza);
char *name = ASGetName(args->config, NULL, to_matrix);
XMLElement *iqVCard;
Log(LOG_DEBUG, "vCard information GET for %s", to);
/* TODO: "a compliant server MUST respond on behalf of the
* requestor and not forward the IQ to the requestee's
* connected resource". */
if (!strncmp(to, "parsee@", 7))
{
XMLElement *iqVCard = XMLCreateTag("iq");
iqVCard = XMLCreateTag("iq");
XMLAddAttr(iqVCard, "from", to);
XMLAddAttr(iqVCard, "to", from);
XMLAddAttr(iqVCard, "id", id);
@ -394,7 +394,49 @@ IQGet(ParseeData *args, XMLElement *stanza, XMPPThread *thr)
StreamFlush(jabber->stream);
pthread_mutex_unlock(&jabber->write_lock);
XMLFreeElement(iqVCard);
Free(to_matrix);
Free(name);
return;
}
iqVCard = XMLCreateTag("iq");
XMLAddAttr(iqVCard, "from", to);
XMLAddAttr(iqVCard, "to", from);
XMLAddAttr(iqVCard, "id", id);
XMLAddAttr(iqVCard, "type", "result");
{
XMLElement *vCard = XMLCreateTag("vCard");
char *mto_link = ParseeGenerateMTO(to_matrix);
XMLAddAttr(vCard, "xmlns", "vcard-temp");
{
XMLElement *fn = CreateTagWithText(
"FN", name ? name : to_matrix
);
XMLElement *nick = CreateTagWithText(
"NICKNAME", to_matrix
);
XMLElement *url = CreateTagWithText(
"URL", mto_link
);
/* TODO: Maybe abstract the vCard code. */
/* TODO: Make a function to just get a user's avatar
* automatically. */
XMLAddChild(vCard, nick);
XMLAddChild(vCard, url);
XMLAddChild(vCard, fn);
Free(mto_link);
}
XMLAddChild(iqVCard, vCard);
}
pthread_mutex_lock(&jabber->write_lock);
XMLEncode(jabber->stream, iqVCard);
StreamFlush(jabber->stream);
pthread_mutex_unlock(&jabber->write_lock);
Free(to_matrix);
Free(name);
}
#define PS "http://jabber.org/protocol/pubsub"
else if ((pubsub = XMLookForTKV(stanza, "pubsub", "xmlns", PS)))
@ -417,8 +459,7 @@ IQGet(ParseeData *args, XMLElement *stanza, XMPPThread *thr)
b64 = Base64Encode(buf, len);
Free(buf);
Log(LOG_INFO, "FM=%s", to_matrix);
Log(LOG_INFO, "B=%s (%dB)", b64, (int) len);
Log(LOG_DEBUG, "IQ-GET: PUBSUB AVATAR OF=%s", to_matrix);
/* Strike back with a response */
reply = XMLCreateTag("iq");
XMLAddAttr(reply, "type", "result");