Skip to content

Commit 680e22a

Browse files
committed
Make the timeline logic more straight-forward
1 parent 9cc6af9 commit 680e22a

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

client/sync.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"net/http"
66
"net/url"
77
"reflect"
8+
"slices"
89
"sort"
910
"strings"
1011
"time"
@@ -349,11 +350,11 @@ func syncMembershipIn(userID, roomID, membership string, checks ...func(gjson.Re
349350
// appear in the `leave` `roomTypeKey` and we need to specifically check the
350351
// timeline for the membership event to differentiate them.
351352
var secondErr error
352-
// We assume the passively observing client user is joined to the room
353-
if clientUserID != userID ||
354-
// Otherwise, if the client is the user whose membership we are checking,
355-
// `timeline` is only available for join/leave/ban memberships.
356-
membership == "join" || membership == "leave" || membership == "ban" {
353+
// The `timeline` is only available for join/leave/ban memberships.
354+
if slices.Contains([]string{"join", "leave", "ban"}, membership) ||
355+
// We assume the passively observing client user is joined to the room (therefore
356+
// has `timeline`).
357+
clientUserID != userID {
357358
secondErr = checkArrayElements(
358359
topLevelSyncJSON, "rooms."+roomTypeKey+"."+GjsonEscape(roomID)+".timeline.events", checkMembership,
359360
)

0 commit comments

Comments
 (0)