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

Move /send_leave to GMSL #387

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open

Move /send_leave to GMSL #387

wants to merge 13 commits into from

Conversation

S7evinK
Copy link
Contributor

@S7evinK S7evinK commented May 25, 2023

No description provided.

@codecov
Copy link

codecov bot commented May 25, 2023

Codecov Report

Attention: 23 lines in your changes are missing coverage. Please review.

Comparison is base (2beadf1) 58.99% compared to head (185a49a) 59.24%.

Files Patch % Lines
handleleave.go 71.60% 16 Missing and 7 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #387      +/-   ##
==========================================
+ Coverage   58.99%   59.24%   +0.25%     
==========================================
  Files          51       51              
  Lines        7113     7194      +81     
==========================================
+ Hits         4196     4262      +66     
- Misses       2528     2538      +10     
- Partials      389      394       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -221,3 +222,177 @@ func TestHandleMakeLeave(t *testing.T) {
})
}
}

type dummyQuerier struct {
pdu PDU
Copy link
Member

Choose a reason for hiding this comment

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

It would be good to assert the type/state key are correct when queried via CurrentStateEvent.

handleleave.go Outdated Show resolved Hide resolved
eventID, roomID string,
querier CurrentStateQuerier,
verifier JSONVerifier,
) (PDU, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Sidenote: this function and others like it will likely need to be modified to support pseudo IDs, as in many cases we pull out the state key and check that it is a user ID, and then check that the domain is correct on it. I would probably structure this as:

  • static function HandleSendLeave as it is in this PR
  • Pull out the room version immediately.
  • Call roomVer.HandleSendLeave(args...) to let room versions decide how to implement this.
  • Most room versions will call a private function which does the below code, checking user IDs etc.
  • But pseudo IDs will call a custom function which omits these checks.

Whilst the caller could call roomVer.HandleSendLeave this then creates bad symmetry, as there are cases where you don't know the room version at this point (e.g invites).

eventversion.go Outdated
@@ -431,6 +447,17 @@ func (v RoomVersionImpl) RedactEventJSON(eventJSON []byte) ([]byte, error) {
return v.redactionAlgorithm(eventJSON)
}

// HandleSendLeave handles requests to `/send_leave`
func (v RoomVersionImpl) HandleSendLeave(ctx context.Context,
event PDU,
Copy link
Member

Choose a reason for hiding this comment

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

This is problematic if v != event.Version().

handleleave.go Outdated
// handleSendLeave handles requests to `/send_leave
// Returns the parsed event or an error.
func handleSendLeave(ctx context.Context,
event PDU,
Copy link
Member

Choose a reason for hiding this comment

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

The proposal I mentioned in #387 (comment) was to keep this function public, and to serve as the entry point for callers, because:

Whilst the caller could call roomVer.HandleSendLeave this then creates bad symmetry, as there are cases where you don't know the room version at this point (e.g invites).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants