(req *http.Request, syncProducer *producers.SyncAPIProducer, device *userapi.Device, roomID, receiptType, eventID string)
| 28 | ) |
| 29 | |
| 30 | func SetReceipt(req *http.Request, syncProducer *producers.SyncAPIProducer, device *userapi.Device, roomID, receiptType, eventID string) util.JSONResponse { |
| 31 | timestamp := gomatrixserverlib.AsTimestamp(time.Now()) |
| 32 | logrus.WithFields(logrus.Fields{ |
| 33 | "roomID": roomID, |
| 34 | "receiptType": receiptType, |
| 35 | "eventID": eventID, |
| 36 | "userId": device.UserID, |
| 37 | "timestamp": timestamp, |
| 38 | }).Debug("Setting receipt") |
| 39 | |
| 40 | // currently only m.read is accepted |
| 41 | if receiptType != "m.read" { |
| 42 | return util.MessageResponse(400, fmt.Sprintf("receipt type must be m.read not '%s'", receiptType)) |
| 43 | } |
| 44 | |
| 45 | if err := syncProducer.SendReceipt(req.Context(), device.UserID, roomID, eventID, receiptType, timestamp); err != nil { |
| 46 | return util.ErrorResponse(err) |
| 47 | } |
| 48 | |
| 49 | return util.JSONResponse{ |
| 50 | Code: http.StatusOK, |
| 51 | JSON: struct{}{}, |
| 52 | } |
| 53 | } |
no test coverage detected