diff options
author | Aaron Ogle <geekgonecrazy@users.noreply.github.com> | 2022-05-24 03:07:33 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-24 09:07:33 +0100 |
commit | 20844942a8923752c7ec2ca1cbcd37b5c36de875 (patch) | |
tree | 34b290ac299a9cecc9bd26c8289831b9dd91f43e | |
parent | 447226790153afc47b62df4d81f66ec7129dca90 (diff) |
Handle invite in appservice roomserver consumer (#2476)
Signed-off-by: Aaron Ogle <aaron@geekgonecrazy.com>
-rw-r--r-- | appservice/consumers/roomserver.go | 49 |
1 files changed, 29 insertions, 20 deletions
diff --git a/appservice/consumers/roomserver.go b/appservice/consumers/roomserver.go index e406e88a..37d4ef9c 100644 --- a/appservice/consumers/roomserver.go +++ b/appservice/consumers/roomserver.go @@ -83,29 +83,38 @@ func (s *OutputRoomEventConsumer) onMessage(ctx context.Context, msg *nats.Msg) return true } - if output.Type != api.OutputTypeNewRoomEvent || output.NewRoomEvent == nil { - return true - } - - newEventID := output.NewRoomEvent.Event.EventID() - events := make([]*gomatrixserverlib.HeaderedEvent, 0, len(output.NewRoomEvent.AddsStateEventIDs)) - events = append(events, output.NewRoomEvent.Event) - if len(output.NewRoomEvent.AddsStateEventIDs) > 0 { - eventsReq := &api.QueryEventsByIDRequest{ - EventIDs: make([]string, 0, len(output.NewRoomEvent.AddsStateEventIDs)), - } - eventsRes := &api.QueryEventsByIDResponse{} - for _, eventID := range output.NewRoomEvent.AddsStateEventIDs { - if eventID != newEventID { - eventsReq.EventIDs = append(eventsReq.EventIDs, eventID) + log.WithFields(log.Fields{ + "type": output.Type, + }).Debug("Got a message in OutputRoomEventConsumer") + + events := []*gomatrixserverlib.HeaderedEvent{} + if output.Type == api.OutputTypeNewRoomEvent && output.NewRoomEvent != nil { + newEventID := output.NewRoomEvent.Event.EventID() + events = append(events, output.NewRoomEvent.Event) + if len(output.NewRoomEvent.AddsStateEventIDs) > 0 { + eventsReq := &api.QueryEventsByIDRequest{ + EventIDs: make([]string, 0, len(output.NewRoomEvent.AddsStateEventIDs)), } - } - if len(eventsReq.EventIDs) > 0 { - if err := s.rsAPI.QueryEventsByID(s.ctx, eventsReq, eventsRes); err != nil { - return false + eventsRes := &api.QueryEventsByIDResponse{} + for _, eventID := range output.NewRoomEvent.AddsStateEventIDs { + if eventID != newEventID { + eventsReq.EventIDs = append(eventsReq.EventIDs, eventID) + } + } + if len(eventsReq.EventIDs) > 0 { + if err := s.rsAPI.QueryEventsByID(s.ctx, eventsReq, eventsRes); err != nil { + return false + } + events = append(events, eventsRes.Events...) } - events = append(events, eventsRes.Events...) } + } else if output.Type == api.OutputTypeNewInviteEvent && output.NewInviteEvent != nil { + events = append(events, output.NewInviteEvent.Event) + } else { + log.WithFields(log.Fields{ + "type": output.Type, + }).Debug("appservice OutputRoomEventConsumer ignoring event", string(msg.Data)) + return true } // Send event to any relevant application services |