Do same for appservice

This commit is contained in:
Neil Alexander 2020-03-11 11:36:27 +00:00
parent f5b103b1f0
commit 287b384df4

View file

@ -81,6 +81,22 @@ func (s *OutputRoomEventConsumer) Start() error {
func (s *OutputRoomEventConsumer) onMessage(msg *sarama.ConsumerMessage) error {
// Parse out the event JSON
var output api.OutputEvent
// Get the room version of the room
vQueryReq := api.QueryRoomVersionForRoomIDRequest{RoomID: string(msg.Key)}
vQueryRes := api.QueryRoomVersionForRoomIDResponse{}
if err := s.query.QueryRoomVersionForRoomID(context.Background(), &vQueryReq, &vQueryRes); err != nil {
return err
}
// Prepare the room event so that it has the correct field types
// for the room version
if err := output.NewRoomEvent.Event.PrepareAs(vQueryRes.RoomVersion); err != nil {
log.WithFields(log.Fields{
"room_version": vQueryRes.RoomVersion,
}).WithError(err).Errorf("can't prepare event to version")
}
if err := json.Unmarshal(msg.Value, &output); err != nil {
// If the message was invalid, log it and move on to the next message in the stream
log.WithError(err).Errorf("roomserver output log: message parse failure")