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 group_handler
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
group_service "github.com/EvolutionAPI/evolution-go/pkg/group/service"
|
||||
instance_model "github.com/EvolutionAPI/evolution-go/pkg/instance/model"
|
||||
group_service "github.com/evolution-foundation/evolution-go/pkg/group/service"
|
||||
instance_model "github.com/evolution-foundation/evolution-go/pkg/instance/model"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
@@ -20,6 +20,7 @@ type GroupHandler interface {
|
||||
GetMyGroups(ctx *gin.Context)
|
||||
JoinGroupLink(ctx *gin.Context)
|
||||
LeaveGroup(ctx *gin.Context)
|
||||
UpdateGroupSettings(ctx *gin.Context)
|
||||
}
|
||||
|
||||
type groupHandler struct {
|
||||
@@ -477,6 +478,52 @@ func (g *groupHandler) LeaveGroup(ctx *gin.Context) {
|
||||
ctx.JSON(http.StatusOK, gin.H{"message": "success"})
|
||||
}
|
||||
|
||||
// Update group settings
|
||||
// @Summary Update group settings
|
||||
// @Description Update group settings (announcement, not_announcement, locked, unlocked, approval_on, approval_off, admin_add, all_member_add)
|
||||
// @Tags Group
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param message body group_service.UpdateGroupSettingsStruct true "Group data"
|
||||
// @Success 200 {object} gin.H "success"
|
||||
// @Failure 400 {object} gin.H "Error on validation"
|
||||
// @Failure 500 {object} gin.H "Internal server error"
|
||||
// @Router /group/settings [post]
|
||||
func (g *groupHandler) UpdateGroupSettings(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 *group_service.UpdateGroupSettingsStruct
|
||||
err := ctx.ShouldBindBodyWithJSON(&data)
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
if data.GroupJID == "" {
|
||||
ctx.JSON(http.StatusBadRequest, gin.H{"error": "groupJid is required"})
|
||||
return
|
||||
}
|
||||
|
||||
if data.Action == "" {
|
||||
ctx.JSON(http.StatusBadRequest, gin.H{"error": "action is required"})
|
||||
return
|
||||
}
|
||||
|
||||
err = g.groupService.UpdateGroupSettings(data, instance)
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
ctx.JSON(http.StatusOK, gin.H{"message": "success"})
|
||||
}
|
||||
|
||||
func NewGroupHandler(
|
||||
groupService group_service.GroupService,
|
||||
) GroupHandler {
|
||||
|
||||
Reference in new issue
Block a user