Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add posibility to request room heroes #304

Merged
merged 8 commits into from
Sep 19, 2023
Merged

Add posibility to request room heroes #304

merged 8 commits into from
Sep 19, 2023

Conversation

S7evinK
Copy link
Collaborator

@S7evinK S7evinK commented Sep 15, 2023

Fixes #241

This adds a heroes flag to RoomSubscriptions. If the room name was calculated using room heroes, the response for the room also contains an array of heroes, containing the user_id, and optionally the fields displayname and avatar_url.

@S7evinK S7evinK added the enhancement New feature or request label Sep 15, 2023
@S7evinK S7evinK marked this pull request as ready for review September 18, 2023 14:13
// subscription which should return heroes.
func (s *connStateLive) shouldIncludeHeroes(roomID string) bool {
roomIDsToLists := s.lists.ListsByVisibleRoomIDs(s.muxedReq.Lists)
subscriptionInclude := s.roomSubscriptions[roomID].IncludeHeroes()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rejig this so it's faster. Checking the lists is expensive.

if s.roomSubscriptions[roomID].IncludeHeroes() {
    return true
}
// rest of list checks

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, that's easier.

@@ -263,7 +263,7 @@ func (s *connStateLive) processLiveUpdate(ctx context.Context, up caches.Update,

thisRoom.Name = roomName

if s.roomSubscriptions[roomUpdate.RoomID()].IncludeHeroes() && calculated {
if calculated && s.shouldIncludeHeroes(roomUpdate.RoomID()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks better, but where's the tests?! :D

if !ok {
return fmt.Errorf("room %q not in response", listRoomID)
}
// wait for bob to be joined
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't you just use res := alice.SlidingSyncUntilMembership(t, "", listRoomID, bob, "join")?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the previous test yes, but this test should use a list instead of a room subscription (used in SlidingSyncUntilMembership)

@S7evinK S7evinK merged commit 7d127e2 into main Sep 19, 2023
7 checks passed
@S7evinK S7evinK deleted the s7evink/heroes branch September 19, 2023 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Room Heroes
2 participants