MCPcopy Create free account
hub / github.com/daodst/chat / SetReceipt

Function SetReceipt

clientapi/routing/receipt.go:30–53  ·  view source on GitHub ↗
(req *http.Request, syncProducer *producers.SyncAPIProducer, device *userapi.Device, roomID, receiptType, eventID string)

Source from the content-addressed store, hash-verified

28)
29
30func 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}

Callers 2

SaveReadMarkerFunction · 0.85
SetupFunction · 0.85

Calls 2

ContextMethod · 0.80
SendReceiptMethod · 0.45

Tested by

no test coverage detected