Move GMSL client types to Dendrite (#3045)

GMSL is intended for Federation only. Sister PR to
https://github.com/matrix-org/gomatrixserverlib/pull/357
This commit is contained in:
kegsay 2023-04-04 18:16:53 +01:00 committed by GitHub
parent 985298cfc4
commit 3691423626
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
58 changed files with 692 additions and 234 deletions

View file

@ -7,6 +7,7 @@ import (
"github.com/matrix-org/gomatrixserverlib"
"github.com/sirupsen/logrus"
"github.com/matrix-org/dendrite/syncapi/synctypes"
userapi "github.com/matrix-org/dendrite/userapi/api"
)
@ -15,7 +16,7 @@ type SyncRequest struct {
Log *logrus.Entry
Device *userapi.Device
Response *Response
Filter gomatrixserverlib.Filter
Filter synctypes.Filter
Since StreamingToken
Timeout time.Duration
WantFullState bool

View file

@ -25,6 +25,7 @@ import (
"github.com/tidwall/gjson"
"github.com/matrix-org/dendrite/roomserver/api"
"github.com/matrix-org/dendrite/syncapi/synctypes"
)
var (
@ -451,13 +452,13 @@ type UnreadNotifications struct {
}
type ClientEvents struct {
Events []gomatrixserverlib.ClientEvent `json:"events,omitempty"`
Events []synctypes.ClientEvent `json:"events,omitempty"`
}
type Timeline struct {
Events []gomatrixserverlib.ClientEvent `json:"events"`
Limited bool `json:"limited"`
PrevBatch *TopologyToken `json:"prev_batch,omitempty"`
Events []synctypes.ClientEvent `json:"events"`
Limited bool `json:"limited"`
PrevBatch *TopologyToken `json:"prev_batch,omitempty"`
}
type Summary struct {
@ -549,7 +550,7 @@ func NewInviteResponse(event *gomatrixserverlib.HeaderedEvent) *InviteResponse {
// Then we'll see if we can create a partial of the invite event itself.
// This is needed for clients to work out *who* sent the invite.
inviteEvent := gomatrixserverlib.ToClientEvent(event.Unwrap(), gomatrixserverlib.FormatSync)
inviteEvent := synctypes.ToClientEvent(event.Unwrap(), synctypes.FormatSync)
inviteEvent.Unsigned = nil
if ev, err := json.Marshal(inviteEvent); err == nil {
res.InviteState.Events = append(res.InviteState.Events, ev)

View file

@ -5,6 +5,7 @@ import (
"reflect"
"testing"
"github.com/matrix-org/dendrite/syncapi/synctypes"
"github.com/matrix-org/gomatrixserverlib"
)
@ -125,7 +126,7 @@ func TestJoinResponse_MarshalJSON(t *testing.T) {
{
name: "unread notifications are NOT removed, if state is set",
fields: fields{
State: &ClientEvents{Events: []gomatrixserverlib.ClientEvent{{Content: []byte("{}")}}},
State: &ClientEvents{Events: []synctypes.ClientEvent{{Content: []byte("{}")}}},
UnreadNotifications: &UnreadNotifications{NotificationCount: 1},
},
want: []byte(`{"state":{"events":[{"content":{},"type":""}]},"unread_notifications":{"highlight_count":0,"notification_count":1}}`),
@ -134,7 +135,7 @@ func TestJoinResponse_MarshalJSON(t *testing.T) {
name: "roomID is removed from EDUs",
fields: fields{
Ephemeral: &ClientEvents{
Events: []gomatrixserverlib.ClientEvent{
Events: []synctypes.ClientEvent{
{RoomID: "!someRandomRoomID:test", Content: []byte("{}")},
},
},