mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-08-02 06:12:45 +00:00
[readability] use event.StateKeyEquals where relevant and minor for-loop refactoring (#1339)
* use event.StateKeyEquals where relevant Signed-off-by: Olivier Charvin <git@olivier.pfad.fr> * use userID
This commit is contained in:
parent
55498c8deb
commit
3205b9212d
10 changed files with 60 additions and 84 deletions
|
@ -165,7 +165,7 @@ func SendJoin(
|
|||
}
|
||||
|
||||
// Check that a state key is provided.
|
||||
if event.StateKey() == nil || (event.StateKey() != nil && *event.StateKey() == "") {
|
||||
if event.StateKey() == nil || event.StateKeyEquals("") {
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusBadRequest,
|
||||
JSON: jsonerror.BadJSON(
|
||||
|
@ -253,11 +253,12 @@ func SendJoin(
|
|||
// there isn't much point in sending another join event into the room.
|
||||
alreadyJoined := false
|
||||
for _, se := range stateAndAuthChainResponse.StateEvents {
|
||||
if !se.StateKeyEquals(*event.StateKey()) {
|
||||
continue
|
||||
}
|
||||
if membership, merr := se.Membership(); merr == nil {
|
||||
if se.StateKey() != nil && *se.StateKey() == *event.StateKey() {
|
||||
alreadyJoined = (membership == "join")
|
||||
break
|
||||
}
|
||||
alreadyJoined = (membership == gomatrixserverlib.Join)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue