aboutsummaryrefslogtreecommitdiff
path: root/clientapi/routing/account_data.go
diff options
context:
space:
mode:
authorNeil Alexander <neilalexander@users.noreply.github.com>2022-10-11 12:27:21 +0100
committerGitHub <noreply@github.com>2022-10-11 12:27:21 +0100
commit0a9aebdf011921680e5b0646bf50d7900423aa69 (patch)
treeae111f8aba12c73a0d4c4ec32f3e109d401693e3 /clientapi/routing/account_data.go
parent3920b9f9b6155db69822d0dbcd36acb1eaa51c34 (diff)
Private read receipts (#2789)
Implement behaviours for `m.read.private` receipts.
Diffstat (limited to 'clientapi/routing/account_data.go')
-rw-r--r--clientapi/routing/account_data.go42
1 files changed, 20 insertions, 22 deletions
diff --git a/clientapi/routing/account_data.go b/clientapi/routing/account_data.go
index b28f0bb1..4742b124 100644
--- a/clientapi/routing/account_data.go
+++ b/clientapi/routing/account_data.go
@@ -154,33 +154,31 @@ func SaveReadMarker(
return *resErr
}
- if r.FullyRead == "" {
- return util.JSONResponse{
- Code: http.StatusBadRequest,
- JSON: jsonerror.BadJSON("Missing m.fully_read mandatory field"),
+ if r.FullyRead != "" {
+ data, err := json.Marshal(fullyReadEvent{EventID: r.FullyRead})
+ if err != nil {
+ return jsonerror.InternalServerError()
}
- }
- data, err := json.Marshal(fullyReadEvent{EventID: r.FullyRead})
- if err != nil {
- return jsonerror.InternalServerError()
- }
-
- dataReq := api.InputAccountDataRequest{
- UserID: device.UserID,
- DataType: "m.fully_read",
- RoomID: roomID,
- AccountData: data,
- }
- dataRes := api.InputAccountDataResponse{}
- if err := userAPI.InputAccountData(req.Context(), &dataReq, &dataRes); err != nil {
- util.GetLogger(req.Context()).WithError(err).Error("userAPI.InputAccountData failed")
- return util.ErrorResponse(err)
+ dataReq := api.InputAccountDataRequest{
+ UserID: device.UserID,
+ DataType: "m.fully_read",
+ RoomID: roomID,
+ AccountData: data,
+ }
+ dataRes := api.InputAccountDataResponse{}
+ if err := userAPI.InputAccountData(req.Context(), &dataReq, &dataRes); err != nil {
+ util.GetLogger(req.Context()).WithError(err).Error("userAPI.InputAccountData failed")
+ return util.ErrorResponse(err)
+ }
}
- // Handle the read receipt that may be included in the read marker
+ // Handle the read receipts that may be included in the read marker.
if r.Read != "" {
- return SetReceipt(req, syncProducer, device, roomID, "m.read", r.Read)
+ return SetReceipt(req, userAPI, syncProducer, device, roomID, "m.read", r.Read)
+ }
+ if r.ReadPrivate != "" {
+ return SetReceipt(req, userAPI, syncProducer, device, roomID, "m.read.private", r.ReadPrivate)
}
return util.JSONResponse{