From 21e47b8fd2f3653745d17fcca815de5934c4cfbb Mon Sep 17 00:00:00 2001 From: Mark Haines Date: Tue, 18 Jul 2017 11:40:33 +0100 Subject: [PATCH] Add new output types to roomserver for invites --- .../dendrite/roomserver/api/output.go | 25 +++++++++++++++++++ .../dendrite/roomserver/input/membership.go | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/github.com/matrix-org/dendrite/roomserver/api/output.go b/src/github.com/matrix-org/dendrite/roomserver/api/output.go index f1b402315..f84ed7766 100644 --- a/src/github.com/matrix-org/dendrite/roomserver/api/output.go +++ b/src/github.com/matrix-org/dendrite/roomserver/api/output.go @@ -98,3 +98,28 @@ type OutputNewRoomEvent struct { // future proof the API for virtual hosting. SendAsServer string `json:"send_as_server"` } + +// An OutputNewInviteEvent is written whenever an invite becomes active. +// Invite events can be received outside of an existing room so have to be +// tracked separately from the room events themselves. +type OutputNewInviteEvent struct { + // The "m.room.member" invite event. + Event gomatrixserverlib.Event `json:"event"` +} + +// An OutputRetireInviteEvent is written whenever an existing invite is no longer +// active. An invite stops being active if the user joins the room or if the +// invite is rejected by the user. +type OutputRetireInviteEvent struct { + // The room ID of the "m.room.member" invite event. + RoomID string + // The ID of the "m.room.member" invite event. + EventID string + // Optional event ID of the event that replaced the invite. + // This can be empty if the invite was rejected locally and we were unable + // to reach the server that originally sent the invite. + ReplacedByEventID string + // The "membership" of the user after retiring the invite. One of "join" + // "leave" or "ban". + Membership string +} diff --git a/src/github.com/matrix-org/dendrite/roomserver/input/membership.go b/src/github.com/matrix-org/dendrite/roomserver/input/membership.go index 9ed655216..575230d9c 100644 --- a/src/github.com/matrix-org/dendrite/roomserver/input/membership.go +++ b/src/github.com/matrix-org/dendrite/roomserver/input/membership.go @@ -50,7 +50,7 @@ func updateMemberships( } if change.added.EventNID != 0 { ev, _ := eventMap(events).lookup(change.added.EventNID) - if ae != nil { + if ev != nil { ae = &ev.Event } targetNID = change.added.EventStateKeyNID