mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-13 22:55:11 +00:00
[MOD] Timestamp Matrix messages
This commit is contained in:
parent
ca5f8fd5c5
commit
55ac682d26
9 changed files with 48 additions and 19 deletions
|
|
@ -1,21 +1,38 @@
|
|||
#include <AS.h>
|
||||
|
||||
#include <Cytoplasm/Memory.h>
|
||||
#include <Cytoplasm/Util.h>
|
||||
#include <Cytoplasm/Str.h>
|
||||
#include <Cytoplasm/Log.h>
|
||||
#include <Cytoplasm/Uri.h>
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <Matrix.h>
|
||||
|
||||
static char *
|
||||
TSToStr(uint64_t ts)
|
||||
{
|
||||
size_t len;
|
||||
char *str;
|
||||
|
||||
len = snprintf(NULL, 0, "%"PRIu64, ts);
|
||||
str = Malloc(len+1);
|
||||
snprintf(str, len+1, "%"PRIu64, ts);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
char *
|
||||
ASSend(const ParseeConfig *conf, char *id, char *user, char *type, HashMap *c)
|
||||
ASSend(const ParseeConfig *conf, char *id, char *user, char *type, HashMap *c, uint64_t ts)
|
||||
{
|
||||
HttpClientContext *ctx = NULL;
|
||||
char *path;
|
||||
char *txn, *ret;
|
||||
char *ts_str;
|
||||
HashMap *reply;
|
||||
if (!conf || !id || !type || !user || !c)
|
||||
{
|
||||
|
|
@ -23,13 +40,20 @@ ASSend(const ParseeConfig *conf, char *id, char *user, char *type, HashMap *c)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (!ts)
|
||||
{
|
||||
ts = UtilTsMillis();
|
||||
}
|
||||
ts_str = TSToStr(ts);
|
||||
|
||||
txn = StrRandom(16);
|
||||
path = StrConcat(9,
|
||||
path = StrConcat(11,
|
||||
"/_matrix/client/v3/rooms/",
|
||||
id, "/send/", type, "/", txn, "?",
|
||||
"user_id=", user
|
||||
"user_id=", user, "&ts=", ts_str
|
||||
);
|
||||
Free(txn);
|
||||
Free(ts_str);
|
||||
|
||||
ctx = ParseeCreateRequest(conf, HTTP_PUT, path);
|
||||
Free(path);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue