mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-13 21:35:10 +00:00
[MOD] Actually redact
This commit is contained in:
parent
a167d5d724
commit
47823ba56b
3 changed files with 53 additions and 7 deletions
50
src/AS.c
50
src/AS.c
|
|
@ -858,7 +858,6 @@ ASGetUserConfig(const ParseeConfig *c, char *user, char *key)
|
||||||
void
|
void
|
||||||
ASSetUserConfig(const ParseeConfig *c, char *user, char *key, HashMap *map)
|
ASSetUserConfig(const ParseeConfig *c, char *user, char *key, HashMap *map)
|
||||||
{
|
{
|
||||||
|
|
||||||
HttpClientContext *ctx = NULL;
|
HttpClientContext *ctx = NULL;
|
||||||
char *path;
|
char *path;
|
||||||
if (!c || !key || !map)
|
if (!c || !key || !map)
|
||||||
|
|
@ -898,3 +897,52 @@ ASSetUserConfig(const ParseeConfig *c, char *user, char *key, HashMap *map)
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
void
|
||||||
|
ASRedact(const ParseeConfig *c, char *room, char *user, char *e_id)
|
||||||
|
{
|
||||||
|
HttpClientContext *ctx = NULL;
|
||||||
|
HashMap *request;
|
||||||
|
char *path, *txn;
|
||||||
|
if (!c || !room || !e_id)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!user)
|
||||||
|
{
|
||||||
|
char *raw = StrConcat(4,
|
||||||
|
"@", c->sender_localpart,
|
||||||
|
":", c->homeserver_host
|
||||||
|
);
|
||||||
|
user = HttpUrlEncode(raw);
|
||||||
|
Free(raw);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
user = HttpUrlEncode(user);
|
||||||
|
}
|
||||||
|
room = HttpUrlEncode(room);
|
||||||
|
e_id = HttpUrlEncode(e_id);
|
||||||
|
txn = StrRandom(16);
|
||||||
|
|
||||||
|
path = StrConcat(9,
|
||||||
|
"/_matrix/client/v3/rooms/",
|
||||||
|
room, "/redact/", e_id, "/", txn,
|
||||||
|
"?", "user_id=", user
|
||||||
|
);
|
||||||
|
|
||||||
|
request = HashMapCreate();
|
||||||
|
ctx = ParseeCreateRequest(c, HTTP_PUT, path);
|
||||||
|
Free(path);
|
||||||
|
ASAuthenticateRequest(c, ctx);
|
||||||
|
ParseeSetRequestJSON(ctx, request);
|
||||||
|
JsonFree(request);
|
||||||
|
|
||||||
|
HttpClientContextFree(ctx);
|
||||||
|
Free(user);
|
||||||
|
Free(room);
|
||||||
|
Free(e_id);
|
||||||
|
Free(txn);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -621,13 +621,8 @@ MessageStanza(ParseeData *args, XMLElement *stanza, XMPPThread *thr)
|
||||||
}
|
}
|
||||||
else if (retracted)
|
else if (retracted)
|
||||||
{
|
{
|
||||||
/* TODO: Use an actual redact. Not doing it now because it's not
|
|
||||||
* fun to do at the moment... */
|
|
||||||
event_id = ParseeGetEventFromID(args, stanza, retracted);
|
event_id = ParseeGetEventFromID(args, stanza, retracted);
|
||||||
Free(ASSend(
|
ASRedact(args->config, mroom_id, encoded, event_id);
|
||||||
args->config, mroom_id, encoded, "m.room.message",
|
|
||||||
MatrixCreateReplace(event_id, "[Retracted]")
|
|
||||||
));
|
|
||||||
ParseePushAllStanza(args, stanza, event_id);
|
ParseePushAllStanza(args, stanza, event_id);
|
||||||
pthread_mutex_unlock(&thr->info->chk_lock);
|
pthread_mutex_unlock(&thr->info->chk_lock);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,9 @@ extern char * ASSend(const ParseeConfig *, char *, char *, char *, HashMap *);
|
||||||
extern void ASType(const ParseeConfig *, char *, char *, bool);
|
extern void ASType(const ParseeConfig *, char *, char *, bool);
|
||||||
extern void ASPresence(const ParseeConfig *, char *, char *, char *);
|
extern void ASPresence(const ParseeConfig *, char *, char *, char *);
|
||||||
|
|
||||||
|
/* Redacts an event from a room with a specific user */
|
||||||
|
extern void ASRedact(const ParseeConfig *, char *room, char *user, char *e_id);
|
||||||
|
|
||||||
/* Sets a state event with a specific type and body */
|
/* Sets a state event with a specific type and body */
|
||||||
extern void ASSetState(const ParseeConfig *conf, char *id, char *type, char *key, char *mask, HashMap *event);
|
extern void ASSetState(const ParseeConfig *conf, char *id, char *type, char *key, char *mask, HashMap *event);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue