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 a SendKnock method and RespSendKnock struct #329

Merged
merged 4 commits into from
Aug 18, 2022

Conversation

reivilibre
Copy link
Contributor

I also need these for writing a Complement test.

Q: is EventJSONs the right type to use for knock_room_state?
The spec describes it as [StrippedState]. EventJSONs seems to be an alias for an array of RawJSON, so sounds like it should be compatible at the very least.

@neilalexander
Copy link
Contributor

Q: is EventJSONs the right type to use for knock_room_state?

If you just plan to hold JSON and not do anything with it then yes, but if you want to turn them into actual *Event then no, stripped events won't work here.

@reivilibre
Copy link
Contributor Author

Q: is EventJSONs the right type to use for knock_room_state?

If you just plan to hold JSON and not do anything with it then yes, but if you want to turn them into actual *Event then no, stripped events won't work here.

I believe that's what I want then, but let me know if that's not what you expect.

Copy link
Contributor

@neilalexander neilalexander left a comment

Choose a reason for hiding this comment

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

Overall looks OK!

// A RespSendKnock is the content of a response to PUT /_matrix/federation/v2/send_knock/{roomID}/{eventID}
type RespSendKnock struct {
// A list of stripped state events to help the initiator of the knock identify the room.
KnockRoomState EventJSONs `json:"knock_room_state"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Thinking some more about this, the fields from the spec are content, state_key, sender and type which is the exact same shape as the InviteV2StrippedState type. If you want to be able to access those fields without having to run through the JSON unmarshaller in your tests, then it might be a better idea to define this as:

KnockRoomState []InviteV2StrippedState `json:"knock_room_state"`

@neilalexander neilalexander merged commit cb70392 into main Aug 18, 2022
@neilalexander neilalexander deleted the rei/send_knock_client branch August 18, 2022 10:21
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