Peeking via MSC2753 (#1370)

Initial implementation of MSC2753, as tested by https://github.com/matrix-org/sytest/pull/944.
Doesn't yet handle unpeeks, peeked EDUs, or history viz changing during a peek - these will follow.
https://github.com/matrix-org/dendrite/pull/1370 has full details.
This commit is contained in:
Matthew Hodgson 2020-09-10 14:39:18 +01:00 committed by GitHub
parent 35564dd73c
commit 39507bacc3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 1209 additions and 59 deletions

View file

@ -388,6 +388,7 @@ type Response struct {
} `json:"presence,omitempty"`
Rooms struct {
Join map[string]JoinResponse `json:"join"`
Peek map[string]JoinResponse `json:"peek"`
Invite map[string]InviteResponse `json:"invite"`
Leave map[string]LeaveResponse `json:"leave"`
} `json:"rooms"`
@ -407,6 +408,7 @@ func NewResponse() *Response {
// Pre-initialise the maps. Synapse will return {} even if there are no rooms under a specific section,
// so let's do the same thing. Bonus: this means we can't get dreaded 'assignment to entry in nil map' errors.
res.Rooms.Join = make(map[string]JoinResponse)
res.Rooms.Peek = make(map[string]JoinResponse)
res.Rooms.Invite = make(map[string]InviteResponse)
res.Rooms.Leave = make(map[string]LeaveResponse)
@ -433,7 +435,7 @@ func (r *Response) IsEmpty() bool {
len(r.ToDevice.Events) == 0
}
// JoinResponse represents a /sync response for a room which is under the 'join' key.
// JoinResponse represents a /sync response for a room which is under the 'join' or 'peek' key.
type JoinResponse struct {
State struct {
Events []gomatrixserverlib.ClientEvent `json:"events"`
@ -507,3 +509,14 @@ type SendToDeviceEvent struct {
DeviceID string
SentByToken *StreamingToken
}
type PeekingDevice struct {
UserID string
DeviceID string
}
type Peek struct {
RoomID string
New bool
Deleted bool
}