mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-16 18:43:10 -06:00
Implement behaviours for m.read.private receipts
This commit is contained in:
parent
3920b9f9b6
commit
323227cead
|
|
@ -37,9 +37,11 @@ func SetReceipt(req *http.Request, syncProducer *producers.SyncAPIProducer, devi
|
||||||
"timestamp": timestamp,
|
"timestamp": timestamp,
|
||||||
}).Debug("Setting receipt")
|
}).Debug("Setting receipt")
|
||||||
|
|
||||||
// currently only m.read is accepted
|
switch receiptType {
|
||||||
if receiptType != "m.read" {
|
case "m.read":
|
||||||
return util.MessageResponse(400, fmt.Sprintf("receipt type must be m.read not '%s'", receiptType))
|
case "m.read.private":
|
||||||
|
default:
|
||||||
|
return util.MessageResponse(400, fmt.Sprintf("receipt type '%s' not known", receiptType))
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := syncProducer.SendReceipt(req.Context(), device.UserID, roomID, eventID, receiptType, timestamp); err != nil {
|
if err := syncProducer.SendReceipt(req.Context(), device.UserID, roomID, eventID, receiptType, timestamp); err != nil {
|
||||||
|
|
|
||||||
|
|
@ -81,6 +81,14 @@ func (t *OutputReceiptConsumer) onMessage(ctx context.Context, msgs []*nats.Msg)
|
||||||
Type: msg.Header.Get("type"),
|
Type: msg.Header.Get("type"),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch receipt.Type {
|
||||||
|
case "m.read":
|
||||||
|
// These are allowed to be sent over federation
|
||||||
|
case "m.read.private":
|
||||||
|
// These must not be sent over federation
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
// only send receipt events which originated from us
|
// only send receipt events which originated from us
|
||||||
_, receiptServerName, err := gomatrixserverlib.SplitID('@', receipt.UserID)
|
_, receiptServerName, err := gomatrixserverlib.SplitID('@', receipt.UserID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,10 @@ func (p *ReceiptStreamProvider) IncrementalSync(
|
||||||
if _, ok := req.IgnoredUsers.List[receipt.UserID]; ok {
|
if _, ok := req.IgnoredUsers.List[receipt.UserID]; ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
// Don't send private read receipts to other users
|
||||||
|
if receipt.Type == "m.read.private" && req.Device.UserID != receipt.UserID {
|
||||||
|
continue
|
||||||
|
}
|
||||||
receiptsByRoom[receipt.RoomID] = append(receiptsByRoom[receipt.RoomID], receipt)
|
receiptsByRoom[receipt.RoomID] = append(receiptsByRoom[receipt.RoomID], receipt)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue