mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-14 00:45:10 +00:00
[ADD/FIX/WIP] "Fix" concurrency, prepare XEP-0421
I'll need to break down my commits more...
This commit is contained in:
parent
a686449a4d
commit
63c1bc819e
14 changed files with 356 additions and 162 deletions
|
|
@ -1,6 +1,10 @@
|
|||
#include "XMPPThread/internal.h"
|
||||
|
||||
#include <Cytoplasm/Memory.h>
|
||||
#include <Cytoplasm/Str.h>
|
||||
#include <Cytoplasm/Log.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
char *
|
||||
ParseeGetBridgedRoom(ParseeData *data, XMLElement *stanza)
|
||||
|
|
@ -111,3 +115,70 @@ ParseeVerifyAllStanza(ParseeData *args, XMLElement *stanza)
|
|||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool
|
||||
ServerHasXEP421(ParseeData *data, char *from)
|
||||
{
|
||||
char *server = NULL, *parsee;
|
||||
XMLElement *disco;
|
||||
bool ret;
|
||||
if (!data || !from)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
server = strchr(from, '@');
|
||||
if (!server)
|
||||
{
|
||||
server = from;
|
||||
}
|
||||
else
|
||||
{
|
||||
server++;
|
||||
}
|
||||
server = StrDuplicate(server);
|
||||
|
||||
if (strchr(server, '/'))
|
||||
{
|
||||
*(strchr(server, '/')) = '\0';
|
||||
}
|
||||
|
||||
parsee = ParseeJID(data);
|
||||
disco = XMPPSendDisco(data->jabber, parsee, server);
|
||||
|
||||
ret = XMPPDiscoAdvertises(disco, "urn:xmpp:occupant-id:0");
|
||||
|
||||
XMLFreeElement(disco);
|
||||
Free(parsee);
|
||||
Free(server);
|
||||
return ret;
|
||||
}
|
||||
char *
|
||||
ParseeGetBridgedUser(ParseeData *data, XMLElement *stanza)
|
||||
{
|
||||
char *user, *xmpp_from, *type;
|
||||
char *decode_from;
|
||||
|
||||
if (!data || !stanza)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
xmpp_from = HashMapGet(stanza->attrs, "from");
|
||||
type = HashMapGet(stanza->attrs, "type");
|
||||
decode_from = ParseeLookupJID(xmpp_from);
|
||||
|
||||
/* TODO: On semi-anonymous MUCs, it might be preferable to use a
|
||||
* form of the occupant ID as the base, as it is more unique, and
|
||||
* less prone to trigger the character limit on Matrix.
|
||||
* I'll need to detect these first....
|
||||
*
|
||||
* See: https://xmpp.org/extensions/xep-0421.html */
|
||||
user = ParseeEncodeJID(
|
||||
data->config,
|
||||
decode_from,
|
||||
StrEquals(type, "chat")
|
||||
);
|
||||
Free(decode_from);
|
||||
return user;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue