[MOD/FIX] Licensewerk, start counting by codepoint

XEP-0426 came out of the blue, and it *hit* me!
This commit is contained in:
LDA 2024-09-21 18:26:35 +02:00
commit c2ea3807ec
7 changed files with 100 additions and 8 deletions

View file

@ -9,6 +9,20 @@
#include <string.h>
static void
LazyRegister(ParseeData *data, char *mxid, char *name)
{
if (!DbExists(data->db, 2, "users", mxid))
{
ASRegisterUser(data->config, mxid);
DbUnlock(data->db, DbCreate(data->db, 2, "users", mxid));
}
if (name)
{
ASSetName(data->config, mxid, name);
}
}
static void
ProcessChatstates(ParseeData *args, XMLElement *stanza)
{
@ -211,7 +225,7 @@ end_error:
HashMap *room_json;
char *from = HashMapGet(stanza->attrs, "from");
ASRegisterUser(args->config, from_matrix);
LazyRegister(args, from_matrix, NULL);
room = ASCreateDM(args->config, from_matrix, to);
mroom_id = StrDuplicate(room);
Log(LOG_INFO, "Creating a DM to '%s'(%s)...", to, mroom_id);
@ -273,11 +287,10 @@ end_error:
XMLElement *oob, *oob_data;
pthread_mutex_unlock(&thr->info->chk_lock);
ASRegisterUser(args->config, encoded);
if (!chat)
{
ASSetName(args->config, encoded, res);
}
LazyRegister(args, encoded, !chat ? res : NULL);
/* TODO: I don't think we can quite remove that. Maybe
* the user was kicked and the bridge is unaware? */
ASInvite(args->config, mroom_id, encoded);
Free(ASJoin(args->config, mroom_id, encoded));