mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-15 10:53:09 -06:00
Simplify code
Signed-off-by: Alex Chen <minecnly@gmail.com>
This commit is contained in:
parent
7c72953b8b
commit
e5c542cda9
|
|
@ -103,24 +103,18 @@ func GetEvent(
|
|||
}
|
||||
}
|
||||
|
||||
allowed := false
|
||||
for _, stateEvent := range stateResp.StateEvents {
|
||||
if stateEvent.StateKeyEquals(r.device.UserID) {
|
||||
membership, err := stateEvent.Membership()
|
||||
if err == nil && membership == "join" {
|
||||
allowed = true
|
||||
break
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusOK,
|
||||
JSON: gomatrixserverlib.ToClientEvent(r.requestedEvent, gomatrixserverlib.FormatAll),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if allowed {
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusOK,
|
||||
JSON: gomatrixserverlib.ToClientEvent(r.requestedEvent, gomatrixserverlib.FormatAll),
|
||||
}
|
||||
}
|
||||
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusNotFound,
|
||||
JSON: jsonerror.NotFound("The event was not found or you do not have permission to read this event."),
|
||||
|
|
|
|||
Loading…
Reference in a new issue