mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-18 12:23:09 -06:00
Do same for appservice
This commit is contained in:
parent
f5b103b1f0
commit
287b384df4
|
|
@ -81,6 +81,22 @@ func (s *OutputRoomEventConsumer) Start() error {
|
||||||
func (s *OutputRoomEventConsumer) onMessage(msg *sarama.ConsumerMessage) error {
|
func (s *OutputRoomEventConsumer) onMessage(msg *sarama.ConsumerMessage) error {
|
||||||
// Parse out the event JSON
|
// Parse out the event JSON
|
||||||
var output api.OutputEvent
|
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 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
|
// 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")
|
log.WithError(err).Errorf("roomserver output log: message parse failure")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue