mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-14 00:35:11 +00:00
[ADD/WIP] XMPP->Matrix user statuses
Still untested because of performance reasons around statuses. Also, how is presence basically a spec feature, and yet somehow manages to be implemented by _no one_? Please, _implement it_ into yall's clients.
This commit is contained in:
parent
e7c44a05e2
commit
e4c6994f61
3 changed files with 92 additions and 2 deletions
42
src/AS.c
42
src/AS.c
|
|
@ -946,3 +946,45 @@ ASRedact(const ParseeConfig *c, char *room, char *user, char *e_id)
|
|||
|
||||
return;
|
||||
}
|
||||
void
|
||||
ASSetStatus(const ParseeConfig *c, char *user, UserStatus status, char *msg)
|
||||
{
|
||||
HttpClientContext *ctx = NULL;
|
||||
HashMap *request;
|
||||
char *path;
|
||||
char *status_str = NULL;
|
||||
if (!c || !user || !msg)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch (status)
|
||||
{
|
||||
case USER_STATUS_ONLINE: status_str = "online"; break;
|
||||
case USER_STATUS_OFFLINE: status_str = "offline"; break;
|
||||
case USER_STATUS_UNAVAILABLE: status_str = "unavailable"; break;
|
||||
default: return;
|
||||
}
|
||||
|
||||
user = HttpUrlEncode(user);
|
||||
path = StrConcat(5,
|
||||
"/_matrix/client/v3/presence/",user,"/status",
|
||||
"?user_id=", user
|
||||
);
|
||||
Free(user);
|
||||
|
||||
request = HashMapCreate();
|
||||
HashMapSet(request, "presence", JsonValueString(status_str));
|
||||
if (msg)
|
||||
{
|
||||
HashMapSet(request, "status_msg", JsonValueString(msg));
|
||||
}
|
||||
|
||||
ctx = ParseeCreateRequest(c, HTTP_PUT, path);
|
||||
ASAuthenticateRequest(c, ctx);
|
||||
ParseeSetRequestJSON(ctx, request);
|
||||
JsonFree(request);
|
||||
|
||||
HttpClientContextFree(ctx);
|
||||
Free(path);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue