Compare commits

..

No commits in common. "29a298efe273426b2dcf4d5fa1134b25a6a89f24" and "2fd39bfe254d724d11ee7b74c8583af8ce2cd579" have entirely different histories.

6 changed files with 9 additions and 20 deletions

View file

@ -45,9 +45,6 @@
"state_key": { "state_key": {
"type": "string" "type": "string"
}, },
"redacts": {
"type": "string"
},
"type": { "type": {
"type": "string", "type": "string",
"required": true "required": true

View file

@ -67,7 +67,6 @@
"origin_server_ts": { "type": "integer", "required": true }, "origin_server_ts": { "type": "integer", "required": true },
"sender": { "type": "string", "required": true }, "sender": { "type": "string", "required": true },
"state_key": { "type": "string" }, "state_key": { "type": "string" },
"redacts": { "type": "string" },
"type": { "type": "string", "required": true } "type": { "type": "string", "required": true }
}, },
"type": "struct" "type": "struct"

View file

@ -618,13 +618,12 @@ RoomLeave(Room *room, User *user, char **errp)
return ret; return ret;
} }
char * char *
RoomRedact(Room *room, User *user, char *eventID, char *reason, char **errp) RoomRedact(Room *room, User *user, char *eventID, char **errp)
{ {
CommonID *userId = NULL; CommonID *userId = NULL;
char *userString = NULL; char *userString = NULL;
char *server = NULL; char *server = NULL;
HashMap *event = NULL; HashMap *event = NULL;
HashMap *content = NULL;
HashMap *pdu = NULL; HashMap *pdu = NULL;
char *ret = NULL; char *ret = NULL;
@ -658,11 +657,9 @@ RoomRedact(Room *room, User *user, char *eventID, char *reason, char **errp)
goto end; goto end;
} }
content = HashMapCreate();
HashMapSet(content, "reason", JsonValueString(reason));
event = RoomEventCreate(userString, event = RoomEventCreate(userString,
"m.room.redaction", NULL, "m.room.redaction", NULL,
content HashMapCreate()
); );
HashMapSet(event, "redacts", JsonValueString(eventID)); HashMapSet(event, "redacts", JsonValueString(eventID));
pdu = RoomEventSend(room, event, errp); pdu = RoomEventSend(room, event, errp);
@ -764,7 +761,7 @@ RoomEventClientify(HashMap *pdu)
CopyField("type", true); CopyField("type", true);
CopyField("state_key",false); CopyField("state_key",false);
CopyField("redacts", false); CopyField("unsigned", false);
return event; return event;

View file

@ -56,8 +56,6 @@ EventFitsV1(PduV1 pdu)
JsonFree(hm); JsonFree(hm);
return ret; return ret;
} }
/* TODO: Rejection */
static PduV1Status static PduV1Status
RoomGetEventStatusV1(Room *room, PduV1 *pdu, State *prev, bool client, char **errp) RoomGetEventStatusV1(Room *room, PduV1 *pdu, State *prev, bool client, char **errp)
{ {
@ -81,17 +79,17 @@ RoomGetEventStatusV1(Room *room, PduV1 *pdu, State *prev, bool client, char **er
} }
if (!RoomAuthoriseEventV1(room, *pdu, prev, errp)) if (!RoomAuthoriseEventV1(room, *pdu, prev, errp))
{ {
/* Reject this event as the PDU's own state does not allow it. */ /* Reject this event as the current state does not allow it.
* TODO: Make the auth check function return a string showing the
* errorr status to the user. */
return PDUV1_STATUS_DROPPED; return PDUV1_STATUS_DROPPED;
} }
if (!client) if (!client)
{ {
/* Checking for soft-failure is not that useful in that case,
* we're only doing pointless computation. */
State *current = StateCurrent(room); State *current = StateCurrent(room);
if (!RoomAuthoriseEventV1(room, *pdu, current, errp)) if (!RoomAuthoriseEventV1(room, *pdu, current, NULL))
{ {
StateFree(current); StateFree(current);
return PDUV1_STATUS_SOFTFAIL; return PDUV1_STATUS_SOFTFAIL;

View file

@ -57,7 +57,6 @@ ROUTE_IMPL(RouteRedact, path, argp)
char *transId = ArrayGet(path, 2); char *transId = ArrayGet(path, 2);
char *redactId = NULL; char *redactId = NULL;
char *sender = NULL; char *sender = NULL;
char *reason = NULL;
Room *room = NULL; Room *room = NULL;
@ -98,7 +97,6 @@ ROUTE_IMPL(RouteRedact, path, argp)
response = MatrixErrorCreate(M_NOT_JSON, NULL); response = MatrixErrorCreate(M_NOT_JSON, NULL);
goto finish; goto finish;
} }
reason = JsonValueAsString(HashMapGet(request, "reason"));
user = UserAuthenticate(db, token); user = UserAuthenticate(db, token);
if (!user) if (!user)
@ -125,7 +123,7 @@ ROUTE_IMPL(RouteRedact, path, argp)
goto finish; goto finish;
} }
if (!(redactId = RoomRedact(room, user, eventId, reason, &err))) if (!(redactId = RoomRedact(room, user, eventId, &err)))
{ {
HttpResponseStatus(args->context, HTTP_UNAUTHORIZED); HttpResponseStatus(args->context, HTTP_UNAUTHORIZED);
response = MatrixErrorCreate(M_FORBIDDEN, err); response = MatrixErrorCreate(M_FORBIDDEN, err);

View file

@ -234,7 +234,7 @@ extern bool RoomCanJoin(Room *, char *);
/** /**
* Makes a local user redact an event(from it's ID). * Makes a local user redact an event(from it's ID).
*/ */
extern char * RoomRedact(Room *, User *, char *, char *, char **); extern char * RoomRedact(Room *, User *, char *, char **);
/** /**
* Makes a local user join a room, and returns true if * Makes a local user join a room, and returns true if