mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-25 15:53:09 -06:00
Remove single purpose struct
This commit is contained in:
parent
72c0134e99
commit
80f346d70a
|
|
@ -324,15 +324,15 @@ func (t *txnReq) processEDUs(ctx context.Context) {
|
||||||
t.processDeviceListUpdate(ctx, e)
|
t.processDeviceListUpdate(ctx, e)
|
||||||
case gomatrixserverlib.MReceipt:
|
case gomatrixserverlib.MReceipt:
|
||||||
// https://matrix.org/docs/spec/server_server/r0.1.4#receipts
|
// https://matrix.org/docs/spec/server_server/r0.1.4#receipts
|
||||||
payload := receiptPayload{}
|
payload := map[string]eduserverAPI.FederationReceiptMRead{}
|
||||||
|
|
||||||
if err := json.Unmarshal(e.Content, &payload.Data); err != nil {
|
if err := json.Unmarshal(e.Content, &payload); err != nil {
|
||||||
util.GetLogger(ctx).WithError(err).Error("Failed to unmarshal receipt event")
|
util.GetLogger(ctx).WithError(err).Error("Failed to unmarshal receipt event")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
for roomID, receipt := range payload.Data {
|
for roomID, receipt := range payload {
|
||||||
for userID := range receipt.MRead {
|
for userID := range receipt.User {
|
||||||
_, domain, err := gomatrixserverlib.SplitID('@', userID)
|
_, domain, err := gomatrixserverlib.SplitID('@', userID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
util.GetLogger(ctx).WithError(err).Error("Failed to split domain from receipt event sender")
|
util.GetLogger(ctx).WithError(err).Error("Failed to split domain from receipt event sender")
|
||||||
|
|
@ -342,14 +342,14 @@ func (t *txnReq) processEDUs(ctx context.Context) {
|
||||||
util.GetLogger(ctx).Warnf("Dropping receipt event where sender domain (%q) doesn't match origin (%q)", domain, t.Origin)
|
util.GetLogger(ctx).Warnf("Dropping receipt event where sender domain (%q) doesn't match origin (%q)", domain, t.Origin)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
ts := receipt.MRead[userID].Data.TS
|
ts := receipt.User[userID].Data.TS
|
||||||
events := receipt.MRead[userID].EventIDs
|
events := receipt.User[userID].EventIDs
|
||||||
if err := t.processReceiptEvent(ctx, userID, roomID, "m.read", ts, events); err != nil {
|
if err := t.processReceiptEvent(ctx, userID, roomID, "m.read", ts, events); err != nil {
|
||||||
util.GetLogger(ctx).WithError(err).WithFields(logrus.Fields{
|
util.GetLogger(ctx).WithError(err).WithFields(logrus.Fields{
|
||||||
"sender": t.Origin,
|
"sender": t.Origin,
|
||||||
"user_id": userID,
|
"user_id": userID,
|
||||||
"room_id": roomID,
|
"room_id": roomID,
|
||||||
"events": receipt.MRead[userID].EventIDs,
|
"events": receipt.User[userID].EventIDs,
|
||||||
}).Error("Failed to send receipt event to edu server")
|
}).Error("Failed to send receipt event to edu server")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
@ -361,18 +361,6 @@ func (t *txnReq) processEDUs(ctx context.Context) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReceiptPayload is the receipt payload passed between servers
|
|
||||||
type receiptPayload struct {
|
|
||||||
Data map[string]struct {
|
|
||||||
MRead map[string]struct {
|
|
||||||
Data struct {
|
|
||||||
TS gomatrixserverlib.Timestamp `json:"ts"`
|
|
||||||
} `json:"data"`
|
|
||||||
EventIDs []string `json:"event_ids"`
|
|
||||||
} `json:"m.read"`
|
|
||||||
} `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// processReceiptEvent sends receipt events to the edu server
|
// processReceiptEvent sends receipt events to the edu server
|
||||||
func (t *txnReq) processReceiptEvent(ctx context.Context,
|
func (t *txnReq) processReceiptEvent(ctx context.Context,
|
||||||
userID, roomID, receiptType string,
|
userID, roomID, receiptType string,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue