sync: 0.7.2 from main (6164dced8d3ab8f9bcce9bf333fb4e8663760ff1)
This commit is contained in:
1 parent
0f9ef308d2
commit
9337afc47e
74 files changed
+11173
-4687
No files matched your search
@@ -3,8 +3,8 @@ package message_handler
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
instance_model "github.com/EvolutionAPI/evolution-go/pkg/instance/model"
|
||||
message_service "github.com/EvolutionAPI/evolution-go/pkg/message/service"
|
||||
instance_model "github.com/evolution-foundation/evolution-go/pkg/instance/model"
|
||||
message_service "github.com/evolution-foundation/evolution-go/pkg/message/service"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
@@ -12,6 +12,7 @@ type MessageHandler interface {
|
||||
React(ctx *gin.Context)
|
||||
ChatPresence(ctx *gin.Context)
|
||||
MarkRead(ctx *gin.Context)
|
||||
MarkPlayed(ctx *gin.Context)
|
||||
DownloadMedia(ctx *gin.Context)
|
||||
GetMessageStatus(ctx *gin.Context)
|
||||
DeleteMessageEveryone(ctx *gin.Context)
|
||||
@@ -168,17 +169,67 @@ func (m *messageHandler) MarkRead(ctx *gin.Context) {
|
||||
ctx.JSON(http.StatusOK, gin.H{"message": "success", "data": responseData})
|
||||
}
|
||||
|
||||
// DownloadImage download an image
|
||||
// @Summary Download an image
|
||||
// @Description Download an image
|
||||
// MarkPlayed mark an audio message as played (blue mic icon)
|
||||
// @Summary Mark an audio message as played
|
||||
// @Description Mark an audio message as played
|
||||
// @Tags Message
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param message body message_service.DownloadMediaStruct true "Download an image"
|
||||
// @Param message body message_service.MarkPlayedStruct true "Mark an audio message as played"
|
||||
// @Success 200 {object} gin.H "success"
|
||||
// @Failure 400 {object} gin.H "Error on validation"
|
||||
// @Failure 500 {object} gin.H "Internal server error"
|
||||
// @Router /message/downloadimage [post]
|
||||
// @Router /message/markplayed [post]
|
||||
func (m *messageHandler) MarkPlayed(ctx *gin.Context) {
|
||||
getInstance := ctx.MustGet("instance")
|
||||
|
||||
instance, ok := getInstance.(*instance_model.Instance)
|
||||
if !ok {
|
||||
ctx.JSON(http.StatusInternalServerError, gin.H{"error": "instance not found"})
|
||||
return
|
||||
}
|
||||
|
||||
var data *message_service.MarkPlayedStruct
|
||||
err := ctx.ShouldBindBodyWithJSON(&data)
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
if data.Number == "" {
|
||||
ctx.JSON(http.StatusBadRequest, gin.H{"error": "phone number is required"})
|
||||
return
|
||||
}
|
||||
|
||||
if len(data.Id) < 1 {
|
||||
ctx.JSON(http.StatusBadRequest, gin.H{"error": "id is required"})
|
||||
return
|
||||
}
|
||||
|
||||
ts, err := m.messageService.MarkPlayed(data, instance)
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
responseData := gin.H{
|
||||
"timestamp": ts,
|
||||
}
|
||||
|
||||
ctx.JSON(http.StatusOK, gin.H{"message": "success", "data": responseData})
|
||||
}
|
||||
|
||||
// DownloadMedia download a media message (image, video, audio, document)
|
||||
// @Summary Download media
|
||||
// @Description Download the media content of a message (image, video, audio or document)
|
||||
// @Tags Message
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param message body message_service.DownloadMediaStruct true "Download media"
|
||||
// @Success 200 {object} gin.H "success"
|
||||
// @Failure 400 {object} gin.H "Error on validation"
|
||||
// @Failure 500 {object} gin.H "Internal server error"
|
||||
// @Router /message/downloadmedia [post]
|
||||
func (m *messageHandler) DownloadMedia(ctx *gin.Context) {
|
||||
getInstance := ctx.MustGet("instance")
|
||||
|
||||
|
||||
Reference in new issue
Block a user