mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-13 22:55:11 +00:00
[MOD] Add x-parsee tag with metadata, global nicks
Still need to grab it on the room-level from the room state if possible, otherwise just rollback to the MXID. I also need to consider profile pictures and bridging media, and check if the nick was present XMPP-side first, as that can and will cause issues, especially around semi-anonymous MUCs.
This commit is contained in:
parent
2b16ccbaf8
commit
b820a441ed
9 changed files with 102 additions and 6 deletions
41
src/AS.c
41
src/AS.c
|
|
@ -280,3 +280,44 @@ ASSetName(const ParseeConfig *conf, char *user, char *name)
|
|||
JsonFree(json);
|
||||
Free(user);
|
||||
}
|
||||
char *
|
||||
ASGetName(const ParseeConfig *c, char *room, char *user)
|
||||
{
|
||||
HttpClientContext *ctx;
|
||||
HashMap *reply;
|
||||
char *path, *ret;
|
||||
if (!c || !user)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!room)
|
||||
{
|
||||
user = HttpUrlEncode(user);
|
||||
path = StrConcat(3,
|
||||
"/_matrix/client/v3/profile/", user, "/displayname"
|
||||
);
|
||||
ctx = ParseeCreateRequest(c, HTTP_GET, path);
|
||||
Free(user);
|
||||
ASAuthenticateRequest(c, ctx);
|
||||
HttpRequestSendHeaders(ctx);
|
||||
HttpRequestSend(ctx);
|
||||
|
||||
reply = JsonDecode(HttpClientStream(ctx));
|
||||
|
||||
JsonFree(reply);
|
||||
ret = StrDuplicate(
|
||||
JsonValueAsString(HashMapGet(reply, "displayname"))
|
||||
);
|
||||
HttpClientContextFree(ctx);
|
||||
Free(path);
|
||||
|
||||
if (!ret)
|
||||
{
|
||||
ret = StrDuplicate(user);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue