Add support for read receipts on /receive

This commit is contained in:
Jonathan Neidel
2024-04-26 12:50:53 +02:00
parent 9d6f4a05a3
commit b23ee29b1f
3 changed files with 15 additions and 2 deletions

View File

@@ -540,6 +540,7 @@ func StringToBool(input string) bool {
// @Param ignore_attachments query string false "Specify whether the attachments of the received message should be ignored" (default: false)"
// @Param ignore_stories query string false "Specify whether stories should be ignored when receiving messages" (default: false)"
// @Param max_messages query string false "Specify the maximum number of messages to receive (default: unlimited)". Not available in json-rpc mode.
// @Param send_read_receipts query string false "Specify whether read receipts should be sent when receiving messages" (default: false)"
// @Router /v1/receive/{number} [get]
func (a *Api) Receive(c *gin.Context) {
number := c.Param("number")
@@ -582,7 +583,13 @@ func (a *Api) Receive(c *gin.Context) {
return
}
jsonStr, err := a.signalClient.Receive(number, timeoutInt, StringToBool(ignoreAttachments), StringToBool(ignoreStories), maxMessagesInt)
sendReadReceipts := c.DefaultQuery("send_read_receipts", "false")
if sendReadReceipts != "true" && sendReadReceipts != "false" {
c.JSON(400, Error{Msg: "Couldn't process request - send_read_receipts parameter needs to be either 'true' or 'false'"})
return
}
jsonStr, err := a.signalClient.Receive(number, timeoutInt, StringToBool(ignoreAttachments), StringToBool(ignoreStories), maxMessagesInt, StringToBool(sendReadReceipts))
if err != nil {
c.JSON(400, Error{Msg: err.Error()})
return