diff options
-rw-r--r-- | are-we-synapse-yet.list | 1 | ||||
-rw-r--r-- | clientapi/routing/createroom.go | 45 | ||||
-rw-r--r-- | clientapi/routing/membership.go | 6 | ||||
-rw-r--r-- | go.mod | 2 | ||||
-rw-r--r-- | go.sum | 4 | ||||
-rw-r--r-- | roomserver/internal/input_events.go | 1 |
6 files changed, 54 insertions, 5 deletions
diff --git a/are-we-synapse-yet.list b/are-we-synapse-yet.list index 71b05d1c..cb90d628 100644 --- a/are-we-synapse-yet.list +++ b/are-we-synapse-yet.list @@ -833,3 +833,4 @@ gst Guest user can call /events on another world_readable room (SYN-606) gst Real user can call /events on another world_readable room (SYN-606) gst Events come down the correct room pub Asking for a remote rooms list, but supplying the local server's name, returns the local rooms list +std Can send a to-device message to two users which both receive it using /sync
\ No newline at end of file diff --git a/clientapi/routing/createroom.go b/clientapi/routing/createroom.go index 28e2b151..43a16945 100644 --- a/clientapi/routing/createroom.go +++ b/clientapi/routing/createroom.go @@ -30,6 +30,7 @@ import ( "github.com/matrix-org/dendrite/clientapi/httputil" "github.com/matrix-org/dendrite/clientapi/jsonerror" "github.com/matrix-org/dendrite/clientapi/producers" + "github.com/matrix-org/dendrite/clientapi/threepid" "github.com/matrix-org/dendrite/common" "github.com/matrix-org/dendrite/common/config" "github.com/matrix-org/gomatrixserverlib" @@ -351,6 +352,50 @@ func createRoom( } } + // If this is a direct message then we should invite the participants. + for _, invitee := range r.Invite { + // Build the membership request. + body := threepid.MembershipRequest{ + UserID: invitee, + } + // Build the invite event. + inviteEvent, err := buildMembershipEvent( + req.Context(), body, accountDB, device, gomatrixserverlib.Invite, + roomID, true, cfg, evTime, rsAPI, asAPI, + ) + if err != nil { + util.GetLogger(req.Context()).WithError(err).Error("buildMembershipEvent failed") + continue + } + // Build some stripped state for the invite. + candidates := append(gomatrixserverlib.UnwrapEventHeaders(builtEvents), *inviteEvent) + var strippedState []gomatrixserverlib.InviteV2StrippedState + for _, event := range candidates { + switch event.Type() { + // TODO: case gomatrixserverlib.MRoomEncryption: + // fallthrough + case gomatrixserverlib.MRoomMember: + fallthrough + case gomatrixserverlib.MRoomJoinRules: + strippedState = append( + strippedState, + gomatrixserverlib.NewInviteV2StrippedState(&event), + ) + } + } + // Send the invite event to the roomserver. + if err = producer.SendInvite( + req.Context(), + inviteEvent.Headered(roomVersion), + strippedState, // invite room state + cfg.Matrix.ServerName, // send as server + nil, // transaction ID + ); err != nil { + util.GetLogger(req.Context()).WithError(err).Error("producer.SendEvents failed") + return jsonerror.InternalServerError() + } + } + response := createRoomResponse{ RoomID: roomID, RoomAlias: roomAlias, diff --git a/clientapi/routing/membership.go b/clientapi/routing/membership.go index 9030f9f7..0a56eec5 100644 --- a/clientapi/routing/membership.go +++ b/clientapi/routing/membership.go @@ -89,7 +89,8 @@ func SendMembership( } event, err := buildMembershipEvent( - req.Context(), body, accountDB, device, membership, roomID, cfg, evTime, rsAPI, asAPI, + req.Context(), body, accountDB, device, membership, + roomID, false, cfg, evTime, rsAPI, asAPI, ) if err == errMissingUserID { return util.JSONResponse{ @@ -151,7 +152,7 @@ func buildMembershipEvent( ctx context.Context, body threepid.MembershipRequest, accountDB accounts.Database, device *authtypes.Device, - membership, roomID string, + membership, roomID string, isDirect bool, cfg *config.Dendrite, evTime time.Time, rsAPI roomserverAPI.RoomserverInternalAPI, asAPI appserviceAPI.AppServiceQueryAPI, ) (*gomatrixserverlib.Event, error) { @@ -182,6 +183,7 @@ func buildMembershipEvent( DisplayName: profile.DisplayName, AvatarURL: profile.AvatarURL, Reason: reason, + IsDirect: isDirect, } if err = builder.SetContent(content); err != nil { @@ -17,7 +17,7 @@ require ( github.com/matrix-org/go-http-js-libp2p v0.0.0-20200318135427-31631a9ef51f github.com/matrix-org/go-sqlite3-js v0.0.0-20200325174927-327088cdef10 github.com/matrix-org/gomatrix v0.0.0-20190528120928-7df988a63f26 - github.com/matrix-org/gomatrixserverlib v0.0.0-20200505092542-ef8abbde3f6b + github.com/matrix-org/gomatrixserverlib v0.0.0-20200507150553-025991c971ea github.com/matrix-org/naffka v0.0.0-20200422140631-181f1ee7401f github.com/matrix-org/util v0.0.0-20190711121626-527ce5ddefc7 github.com/mattn/go-sqlite3 v2.0.2+incompatible @@ -367,8 +367,8 @@ github.com/matrix-org/gomatrix v0.0.0-20190528120928-7df988a63f26 h1:Hr3zjRsq2bh github.com/matrix-org/gomatrix v0.0.0-20190528120928-7df988a63f26/go.mod h1:3fxX6gUjWyI/2Bt7J1OLhpCzOfO/bB3AiX0cJtEKud0= github.com/matrix-org/gomatrixserverlib v0.0.0-20200124100636-0c2ec91d1df5 h1:kmRjpmFOenVpOaV/DRlo9p6z/IbOKlUC+hhKsAAh8Qg= github.com/matrix-org/gomatrixserverlib v0.0.0-20200124100636-0c2ec91d1df5/go.mod h1:FsKa2pWE/bpQql9H7U4boOPXFoJX/QcqaZZ6ijLkaZI= -github.com/matrix-org/gomatrixserverlib v0.0.0-20200505092542-ef8abbde3f6b h1:gxLun/noFJ7DplX7rqT8E4v4NkeDJ45tqW7LXC6k4C4= -github.com/matrix-org/gomatrixserverlib v0.0.0-20200505092542-ef8abbde3f6b/go.mod h1:JsAzE1Ll3+gDWS9JSUHPJiiyAksvOOnGWF2nXdg4ZzU= +github.com/matrix-org/gomatrixserverlib v0.0.0-20200507150553-025991c971ea h1:1qfbSjg3PwULY68AVRdZ3QIJoccNMbre0mSR7m7mqI4= +github.com/matrix-org/gomatrixserverlib v0.0.0-20200507150553-025991c971ea/go.mod h1:JsAzE1Ll3+gDWS9JSUHPJiiyAksvOOnGWF2nXdg4ZzU= github.com/matrix-org/naffka v0.0.0-20200127221512-0716baaabaf1 h1:osLoFdOy+ChQqVUn2PeTDETFftVkl4w9t/OW18g3lnk= github.com/matrix-org/naffka v0.0.0-20200127221512-0716baaabaf1/go.mod h1:cXoYQIENbdWIQHt1SyCo6Bl3C3raHwJ0wgVrXHSqf+A= github.com/matrix-org/naffka v0.0.0-20200422140631-181f1ee7401f h1:pRz4VTiRCO4zPlEMc3ESdUOcW4PXHH4Kj+YDz1XyE+Y= diff --git a/roomserver/internal/input_events.go b/roomserver/internal/input_events.go index b17076ef..a0bfaa2e 100644 --- a/roomserver/internal/input_events.go +++ b/roomserver/internal/input_events.go @@ -308,6 +308,7 @@ func buildInviteStrippedState( inviteState := []gomatrixserverlib.InviteV2StrippedState{ gomatrixserverlib.NewInviteV2StrippedState(&input.Event.Event), } + stateEvents = append(stateEvents, types.Event{Event: input.Event.Unwrap()}) for _, event := range stateEvents { inviteState = append(inviteState, gomatrixserverlib.NewInviteV2StrippedState(&event.Event)) } |