Merge SenderID & Per Room User Key work (#3109)

This commit is contained in:
devonh 2023-06-14 14:23:46 +00:00 committed by GitHub
parent 7a2e325d10
commit e4665979bf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
75 changed files with 801 additions and 379 deletions

View file

@ -54,7 +54,14 @@ func SendRedaction(
JSON: spec.Forbidden("userID doesn't have power level to redact"),
}
}
senderID, queryErr := rsAPI.QuerySenderIDForUser(req.Context(), roomID, *deviceUserID)
validRoomID, err := spec.NewRoomID(roomID)
if err != nil {
return util.JSONResponse{
Code: http.StatusBadRequest,
JSON: spec.BadJSON("RoomID is invalid"),
}
}
senderID, queryErr := rsAPI.QuerySenderIDForUser(req.Context(), *validRoomID, *deviceUserID)
if queryErr != nil {
return util.JSONResponse{
Code: http.StatusForbidden,
@ -103,8 +110,8 @@ func SendRedaction(
JSON: spec.Forbidden("You don't have permission to redact this event, no power_levels event in this room."),
}
}
pl, err := plEvent.PowerLevels()
if err != nil {
pl, plErr := plEvent.PowerLevels()
if plErr != nil {
return util.JSONResponse{
Code: 403,
JSON: spec.Forbidden(
@ -134,7 +141,7 @@ func SendRedaction(
Type: spec.MRoomRedaction,
Redacts: eventID,
}
err := proto.SetContent(r)
err = proto.SetContent(r)
if err != nil {
util.GetLogger(req.Context()).WithError(err).Error("proto.SetContent failed")
return util.JSONResponse{