mirror of
https://github.com/element-hq/dendrite.git
synced 2025-09-14 21:32:23 +03:00
Cleanup remaining statekey usage for senderIDs (#3106)
This commit is contained in:
parent
832ccc32f6
commit
77d9e4e93d
62 changed files with 760 additions and 455 deletions
|
@ -47,7 +47,22 @@ func SendRedaction(
|
|||
txnID *string,
|
||||
txnCache *transactions.Cache,
|
||||
) util.JSONResponse {
|
||||
resErr := checkMemberInRoom(req.Context(), rsAPI, device.UserID, roomID)
|
||||
deviceUserID, userIDErr := spec.NewUserID(device.UserID, true)
|
||||
if userIDErr != nil {
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusForbidden,
|
||||
JSON: spec.Forbidden("userID doesn't have power level to redact"),
|
||||
}
|
||||
}
|
||||
senderID, queryErr := rsAPI.QuerySenderIDForUser(req.Context(), roomID, *deviceUserID)
|
||||
if queryErr != nil {
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusForbidden,
|
||||
JSON: spec.Forbidden("userID doesn't have power level to redact"),
|
||||
}
|
||||
}
|
||||
|
||||
resErr := checkMemberInRoom(req.Context(), rsAPI, *deviceUserID, roomID)
|
||||
if resErr != nil {
|
||||
return *resErr
|
||||
}
|
||||
|
@ -73,25 +88,10 @@ func SendRedaction(
|
|||
}
|
||||
}
|
||||
|
||||
fullUserID, userIDErr := spec.NewUserID(device.UserID, true)
|
||||
if userIDErr != nil {
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusForbidden,
|
||||
JSON: spec.Forbidden("userID doesn't have power level to redact"),
|
||||
}
|
||||
}
|
||||
senderID, queryErr := rsAPI.QuerySenderIDForUser(req.Context(), roomID, *fullUserID)
|
||||
if queryErr != nil {
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusForbidden,
|
||||
JSON: spec.Forbidden("userID doesn't have power level to redact"),
|
||||
}
|
||||
}
|
||||
|
||||
// "Users may redact their own events, and any user with a power level greater than or equal
|
||||
// to the redact power level of the room may redact events there"
|
||||
// https://matrix.org/docs/spec/client_server/r0.6.1#put-matrix-client-r0-rooms-roomid-redact-eventid-txnid
|
||||
allowedToRedact := ev.SenderID() == senderID // TODO: Should replace device.UserID with device...PerRoomKey
|
||||
allowedToRedact := ev.SenderID() == senderID
|
||||
if !allowedToRedact {
|
||||
plEvent := roomserverAPI.GetStateEvent(req.Context(), rsAPI, roomID, gomatrixserverlib.StateKeyTuple{
|
||||
EventType: spec.MRoomPowerLevels,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue