[MOD] Remove the last [p]based nicks, table moving

This commit is contained in:
LDA 2024-08-18 23:52:47 +02:00
commit c975dba852
9 changed files with 344 additions and 208 deletions

View file

@ -17,7 +17,8 @@ JoinMUC(ParseeData *data, HashMap *event, char *jid, char *muc, char *name)
{
char *sender = GrabString(event, 1, "sender");
char *rev = StrConcat(3, muc, "/", name);
char *nick = StrDuplicate(name);
char *rev = StrConcat(3, muc, "/", nick);
int nonce = 0;
while (!XMPPJoinMUC(data->jabber, jid, rev, true) && nonce < 20)
@ -32,8 +33,11 @@ JoinMUC(ParseeData *data, HashMap *event, char *jid, char *muc, char *name)
hex[8] = '\0';
}
Free(nick);
Free(rev);
rev = StrConcat(6, muc, "/", name, "[", hex, "]");
nick = StrConcat(4, name, "[", hex, "]");
rev = StrConcat(3, muc, "/", nick);
nonce++;
Free(nonce_str);
@ -41,6 +45,9 @@ JoinMUC(ParseeData *data, HashMap *event, char *jid, char *muc, char *name)
Free(input);
Free(hex);
}
ParseePushNickTable(muc, sender, nick);
Free(nick);
Free(rev);
}
@ -118,11 +125,15 @@ ParseeMemberHandler(ParseeData *data, HashMap *event)
goto end;
}
/* TODO: Check the name's validity */
name = ASGetName(data->config, room_id, state_key);
rev = StrConcat(4, muc_id, "/", name, "[p]");
/* TODO: We need to deal with the nick properly, as XMPP
* requires us to provide it whenever we want to even think
* about leaving...
* I love how this is the last place victim of the dreaded [p]... */
name = StrDuplicate(ParseeLookupNick(muc_id, sender));
rev = StrConcat(3, muc_id, "/", name);
XMPPLeaveMUC(jabber, jid, rev, reason);
ParseePushNickTable(muc_id, sender, NULL);
end:
Free(chat_id);
Free(muc_id);
@ -239,13 +250,7 @@ GetXMPPInformation(ParseeData *data, HashMap *event, char **from, char **to)
}
matrix_name = ASGetName(data->config, room_id, matrix_sender);
/* TODO: Manage name conflicts. That would have been an easy
* task(try the original one, and use a counter if it fails),
* but that'd involve modifying the rest of the code, which
* I'm not doing at 01:39 ... */
JoinMUC(data, event, *from, muc_id, matrix_name);
*to = muc_id;
Free(matrix_name);