Skip to content

Add a SendKnock method and RespSendKnock struct#329

Merged
neilalexander merged 4 commits into
mainfrom
rei/send_knock_client
Aug 18, 2022
Merged

Add a SendKnock method and RespSendKnock struct#329
neilalexander merged 4 commits into
mainfrom
rei/send_knock_client

Conversation

@reivilibre
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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!

Comment thread federationtypes.go Outdated
// 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
Copy Markdown
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