Use SetUnsignedField and log error

This commit is contained in:
Erik Johnston 2017-12-06 17:04:16 +00:00
parent a5f130c670
commit 387afd3ed7

View file

@ -19,6 +19,8 @@ import (
"database/sql" "database/sql"
"fmt" "fmt"
"github.com/sirupsen/logrus"
"github.com/matrix-org/dendrite/clientapi/auth/authtypes" "github.com/matrix-org/dendrite/clientapi/auth/authtypes"
"github.com/matrix-org/dendrite/roomserver/api" "github.com/matrix-org/dendrite/roomserver/api"
// Import the postgres database driver. // Import the postgres database driver.
@ -625,12 +627,13 @@ func streamEventsToEvents(device *authtypes.Device, in []streamEvent) []gomatrix
out[i] = in[i].Event out[i] = in[i].Event
if device != nil && in[i].transactionID != nil { if device != nil && in[i].transactionID != nil {
if device.UserID == in[i].Sender() && device.ID == in[i].transactionID.DeviceID { if device.UserID == in[i].Sender() && device.ID == in[i].transactionID.DeviceID {
// TODO: Don't clobber unsigned err := out[i].SetUnsignedField(
ev, err := out[i].SetUnsigned(map[string]string{ "transaction_id", in[i].transactionID.TransactionID,
"transaction_id": in[i].transactionID.TransactionID, )
}) if err != nil {
if err == nil { logrus.WithFields(logrus.Fields{
out[i] = ev "event_id": out[i].EventID(),
}).WithError(err).Warnf("Failed to add transaction ID to event")
} }
} }
} }