From 075618833f788015930957f6fc0d7d0a23496dc4 Mon Sep 17 00:00:00 2001 From: Till Faelligen Date: Tue, 14 Jun 2022 11:48:38 +0200 Subject: [PATCH] Use newly added GMSL HistoryVisibility --- syncapi/internal/history_visibility.go | 4 ++-- syncapi/syncapi_test.go | 10 +--------- test/room.go | 8 ++++---- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/syncapi/internal/history_visibility.go b/syncapi/internal/history_visibility.go index 3fbb24052..52a816f89 100644 --- a/syncapi/internal/history_visibility.go +++ b/syncapi/internal/history_visibility.go @@ -162,7 +162,7 @@ func getStateForEvents(ctx context.Context, db storage.Database, events []*gomat return nil, fmt.Errorf("initial event does not exist: %w", err) } // By default if no history_visibility is set, or if the value is not understood, the visibility is assumed to be shared - var hisVis = "shared" + var hisVis = gomatrixserverlib.HistoryVisibilityShared historyEvent, _, err := db.SelectTopologicalEvent(ctx, int(pos.Depth), "m.room.history_visibility", ev.RoomID()) if err != nil { if err != sql.ErrNoRows { @@ -172,7 +172,7 @@ func getStateForEvents(ctx context.Context, db storage.Database, events []*gomat } else { hisVis, err = historyEvent.HistoryVisibility() if err != nil { - hisVis = "shared" + hisVis = gomatrixserverlib.HistoryVisibilityShared } } // get the membership event diff --git a/syncapi/syncapi_test.go b/syncapi/syncapi_test.go index 0c0b53d17..ef1f87d3d 100644 --- a/syncapi/syncapi_test.go +++ b/syncapi/syncapi_test.go @@ -345,7 +345,7 @@ func testHistoryVisibility(t *testing.T, dbType test.DBType) { // check guest and normal user accounts for _, accType := range []userapi.AccountType{userapi.AccountTypeGuest, userapi.AccountTypeUser} { testCases := []struct { - historyVisibility string + historyVisibility gomatrixserverlib.HistoryVisibility wantResult result }{ { @@ -380,14 +380,6 @@ func testHistoryVisibility(t *testing.T, dbType test.DBType) { seeAfterInvite: false, }, }, - { - historyVisibility: "default", - wantResult: result{ - seeWithoutJoin: false, - seeBeforeJoin: true, - seeAfterInvite: true, - }, - }, } bobDev.AccountType = accType diff --git a/test/room.go b/test/room.go index c34d0b7d2..d310625d1 100644 --- a/test/room.go +++ b/test/room.go @@ -40,7 +40,7 @@ type Room struct { ID string Version gomatrixserverlib.RoomVersion preset Preset - visibility string + visibility gomatrixserverlib.HistoryVisibility creator *User authEvents gomatrixserverlib.AuthEvents @@ -98,10 +98,10 @@ func (r *Room) insertCreateEvents(t *testing.T) { fallthrough case PresetPrivateChat: joinRule.JoinRule = "invite" - hisVis.HistoryVisibility = "shared" + hisVis.HistoryVisibility = gomatrixserverlib.HistoryVisibilityShared case PresetPublicChat: joinRule.JoinRule = "public" - hisVis.HistoryVisibility = "shared" + hisVis.HistoryVisibility = gomatrixserverlib.HistoryVisibilityShared } if r.visibility != "" { @@ -247,7 +247,7 @@ func RoomPreset(p Preset) roomModifier { } } -func RoomHistoryVisibility(vis string) roomModifier { +func RoomHistoryVisibility(vis gomatrixserverlib.HistoryVisibility) roomModifier { return func(t *testing.T, r *Room) { r.visibility = vis }