mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-17 11:53:09 -06:00
Don't repeat join events into the roomserver
This commit is contained in:
parent
a281bb4538
commit
07a89c4e6b
|
|
@ -139,7 +139,24 @@ func (r *RoomserverInternalAPI) performJoinRoomByID(
|
|||
switch err {
|
||||
case nil:
|
||||
// The room join is local. Send the new join event into the
|
||||
// roomserver.
|
||||
// roomserver. First of all check that the user isn't already
|
||||
// a member of the room.
|
||||
alreadyJoined := false
|
||||
for _, se := range buildRes.StateEvents {
|
||||
if se.Type() == gomatrixserverlib.MRoomMember {
|
||||
if se.StateKey() != nil && *se.StateKey() == userID {
|
||||
var content map[string]interface{}
|
||||
if membership, ok := content["membership"]; ok {
|
||||
alreadyJoined = (membership == "join")
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If we haven't already joined the room then send an event
|
||||
// into the room changing our membership status.
|
||||
if !alreadyJoined {
|
||||
inputReq := api.InputRoomEventsRequest{
|
||||
InputRoomEvents: []api.InputRoomEvent{
|
||||
api.InputRoomEvent{
|
||||
|
|
@ -154,6 +171,7 @@ func (r *RoomserverInternalAPI) performJoinRoomByID(
|
|||
if err = r.InputRoomEvents(ctx, &inputReq, &inputRes); err != nil {
|
||||
return fmt.Errorf("r.InputRoomEvents: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
case common.ErrRoomNoExists:
|
||||
// The room doesn't exist. First of all check if the room is a local
|
||||
|
|
|
|||
Loading…
Reference in a new issue