diff --git a/federationapi/routing/join.go b/federationapi/routing/join.go index 9fa0794ef..c637116f7 100644 --- a/federationapi/routing/join.go +++ b/federationapi/routing/join.go @@ -192,9 +192,7 @@ func SendJoin( if event.StateKey() == nil || event.StateKeyEquals("") { return util.JSONResponse{ Code: http.StatusBadRequest, - JSON: jsonerror.BadJSON( - fmt.Sprintf("No state key was provided in the join event."), - ), + JSON: jsonerror.BadJSON("No state key was provided in the join event."), } } diff --git a/roomserver/state/state.go b/roomserver/state/state.go index 9ee6f40d4..0663499e7 100644 --- a/roomserver/state/state.go +++ b/roomserver/state/state.go @@ -717,11 +717,7 @@ func ResolveConflictsAdhoc( // Append the events if there is already a conflicted list for // this tuple key, create it if not. tuple := stateKeyTuple{event.Type(), *event.StateKey()} - if _, ok := eventMap[tuple]; ok { - eventMap[tuple] = append(eventMap[tuple], event) - } else { - eventMap[tuple] = []gomatrixserverlib.Event{event} - } + eventMap[tuple] = append(eventMap[tuple], event) } // Split out the events in the map into conflicted and unconflicted diff --git a/syncapi/storage/storage_test.go b/syncapi/storage/storage_test.go index 0e827c95d..8f16642f0 100644 --- a/syncapi/storage/storage_test.go +++ b/syncapi/storage/storage_test.go @@ -81,7 +81,7 @@ func SimpleRoom(t *testing.T, roomID, userA, userB string) (msgs []gomatrixserve })) state = append(state, events[len(events)-1]) events = append(events, MustCreateEvent(t, roomID, []gomatrixserverlib.HeaderedEvent{events[len(events)-1]}, &gomatrixserverlib.EventBuilder{ - Content: []byte(fmt.Sprintf(`{"membership":"join"}`)), + Content: []byte(`{"membership":"join"}`), Type: "m.room.member", StateKey: &userA, Sender: userA, @@ -97,7 +97,7 @@ func SimpleRoom(t *testing.T, roomID, userA, userB string) (msgs []gomatrixserve })) } events = append(events, MustCreateEvent(t, roomID, []gomatrixserverlib.HeaderedEvent{events[len(events)-1]}, &gomatrixserverlib.EventBuilder{ - Content: []byte(fmt.Sprintf(`{"membership":"join"}`)), + Content: []byte(`{"membership":"join"}`), Type: "m.room.member", StateKey: &userB, Sender: userB, @@ -348,7 +348,7 @@ func TestGetEventsInRangeWithEventsSameDepth(t *testing.T) { Depth: int64(len(events) + 1), })) events = append(events, MustCreateEvent(t, testRoomID, []gomatrixserverlib.HeaderedEvent{events[len(events)-1]}, &gomatrixserverlib.EventBuilder{ - Content: []byte(fmt.Sprintf(`{"membership":"join"}`)), + Content: []byte(`{"membership":"join"}`), Type: "m.room.member", StateKey: &testUserIDA, Sender: testUserIDA, @@ -367,7 +367,7 @@ func TestGetEventsInRangeWithEventsSameDepth(t *testing.T) { } // merge the fork, prev_events are all 3 messages, depth is increased by 1. events = append(events, MustCreateEvent(t, testRoomID, events[len(events)-3:], &gomatrixserverlib.EventBuilder{ - Content: []byte(fmt.Sprintf(`{"body":"Message merge"}`)), + Content: []byte(`{"body":"Message merge"}`), Type: "m.room.message", Sender: testUserIDA, Depth: depth + 1, @@ -438,7 +438,7 @@ func TestGetEventsInTopologicalRangeMultiRoom(t *testing.T) { Depth: int64(len(events) + 1), })) events = append(events, MustCreateEvent(t, roomID, []gomatrixserverlib.HeaderedEvent{events[len(events)-1]}, &gomatrixserverlib.EventBuilder{ - Content: []byte(fmt.Sprintf(`{"membership":"join"}`)), + Content: []byte(`{"membership":"join"}`), Type: "m.room.member", StateKey: &testUserIDA, Sender: testUserIDA, @@ -484,7 +484,7 @@ func TestGetEventsInRangeWithEventsInsertedLikeBackfill(t *testing.T) { // "federation" join userC := fmt.Sprintf("@radiance:%s", testOrigin) joinEvent := MustCreateEvent(t, testRoomID, []gomatrixserverlib.HeaderedEvent{events[len(events)-1]}, &gomatrixserverlib.EventBuilder{ - Content: []byte(fmt.Sprintf(`{"membership":"join"}`)), + Content: []byte(`{"membership":"join"}`), Type: "m.room.member", StateKey: &userC, Sender: userC, @@ -615,14 +615,14 @@ func TestInviteBehaviour(t *testing.T) { db := MustCreateDatabase(t) inviteRoom1 := "!inviteRoom1:somewhere" inviteEvent1 := MustCreateEvent(t, inviteRoom1, nil, &gomatrixserverlib.EventBuilder{ - Content: []byte(fmt.Sprintf(`{"membership":"invite"}`)), + Content: []byte(`{"membership":"invite"}`), Type: "m.room.member", StateKey: &testUserIDA, Sender: "@inviteUser1:somewhere", }) inviteRoom2 := "!inviteRoom2:somewhere" inviteEvent2 := MustCreateEvent(t, inviteRoom2, nil, &gomatrixserverlib.EventBuilder{ - Content: []byte(fmt.Sprintf(`{"membership":"invite"}`)), + Content: []byte(`{"membership":"invite"}`), Type: "m.room.member", StateKey: &testUserIDA, Sender: "@inviteUser2:somewhere",