Use newly added GMSL HistoryVisibility

This commit is contained in:
Till Faelligen 2022-06-14 11:48:38 +02:00
parent 888297f831
commit 075618833f
3 changed files with 7 additions and 15 deletions

View file

@ -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) 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 // 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()) historyEvent, _, err := db.SelectTopologicalEvent(ctx, int(pos.Depth), "m.room.history_visibility", ev.RoomID())
if err != nil { if err != nil {
if err != sql.ErrNoRows { if err != sql.ErrNoRows {
@ -172,7 +172,7 @@ func getStateForEvents(ctx context.Context, db storage.Database, events []*gomat
} else { } else {
hisVis, err = historyEvent.HistoryVisibility() hisVis, err = historyEvent.HistoryVisibility()
if err != nil { if err != nil {
hisVis = "shared" hisVis = gomatrixserverlib.HistoryVisibilityShared
} }
} }
// get the membership event // get the membership event

View file

@ -345,7 +345,7 @@ func testHistoryVisibility(t *testing.T, dbType test.DBType) {
// check guest and normal user accounts // check guest and normal user accounts
for _, accType := range []userapi.AccountType{userapi.AccountTypeGuest, userapi.AccountTypeUser} { for _, accType := range []userapi.AccountType{userapi.AccountTypeGuest, userapi.AccountTypeUser} {
testCases := []struct { testCases := []struct {
historyVisibility string historyVisibility gomatrixserverlib.HistoryVisibility
wantResult result wantResult result
}{ }{
{ {
@ -380,14 +380,6 @@ func testHistoryVisibility(t *testing.T, dbType test.DBType) {
seeAfterInvite: false, seeAfterInvite: false,
}, },
}, },
{
historyVisibility: "default",
wantResult: result{
seeWithoutJoin: false,
seeBeforeJoin: true,
seeAfterInvite: true,
},
},
} }
bobDev.AccountType = accType bobDev.AccountType = accType

View file

@ -40,7 +40,7 @@ type Room struct {
ID string ID string
Version gomatrixserverlib.RoomVersion Version gomatrixserverlib.RoomVersion
preset Preset preset Preset
visibility string visibility gomatrixserverlib.HistoryVisibility
creator *User creator *User
authEvents gomatrixserverlib.AuthEvents authEvents gomatrixserverlib.AuthEvents
@ -98,10 +98,10 @@ func (r *Room) insertCreateEvents(t *testing.T) {
fallthrough fallthrough
case PresetPrivateChat: case PresetPrivateChat:
joinRule.JoinRule = "invite" joinRule.JoinRule = "invite"
hisVis.HistoryVisibility = "shared" hisVis.HistoryVisibility = gomatrixserverlib.HistoryVisibilityShared
case PresetPublicChat: case PresetPublicChat:
joinRule.JoinRule = "public" joinRule.JoinRule = "public"
hisVis.HistoryVisibility = "shared" hisVis.HistoryVisibility = gomatrixserverlib.HistoryVisibilityShared
} }
if r.visibility != "" { 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) { return func(t *testing.T, r *Room) {
r.visibility = vis r.visibility = vis
} }