Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,52 @@ const docTemplate = `{
}
}
},
"/group/settings": {
"post": {
"description": "Update group settings (announcement, not_announcement, locked, unlocked, approval_on, approval_off, admin_add, all_member_add)",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Group"
],
"summary": "Update group settings",
"parameters": [
{
"description": "Group data",
"name": "message",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/github_com_EvolutionAPI_evolution-go_pkg_group_service.UpdateGroupSettingsStruct"
}
}
],
"responses": {
"200": {
"description": "success",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"400": {
"description": "Error on validation",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"500": {
"description": "Internal server error",
"schema": {
"$ref": "#/definitions/gin.H"
}
}
}
}
},
"/group/list": {
"get": {
"description": "List groups",
Expand Down Expand Up @@ -3598,6 +3644,27 @@ const docTemplate = `{
}
}
},
"github_com_EvolutionAPI_evolution-go_pkg_group_service.UpdateGroupSettingsStruct": {
"type": "object",
"properties": {
"groupJid": {
"type": "string"
},
"action": {
"type": "string",
"enum": [
"announcement",
"not_announcement",
"locked",
"unlocked",
"approval_on",
"approval_off",
"admin_add",
"all_member_add"
]
}
}
},
"github_com_EvolutionAPI_evolution-go_pkg_group_service.LeaveGroupStruct": {
"type": "object",
"properties": {
Expand Down
67 changes: 67 additions & 0 deletions docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,52 @@
}
}
},
"/group/settings": {
"post": {
"description": "Update group settings (announcement, not_announcement, locked, unlocked, approval_on, approval_off, admin_add, all_member_add)",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Group"
],
"summary": "Update group settings",
"parameters": [
{
"description": "Group data",
"name": "message",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/github_com_EvolutionAPI_evolution-go_pkg_group_service.UpdateGroupSettingsStruct"
}
}
],
"responses": {
"200": {
"description": "success",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"400": {
"description": "Error on validation",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"500": {
"description": "Internal server error",
"schema": {
"$ref": "#/definitions/gin.H"
}
}
}
}
},
"/group/list": {
"get": {
"description": "List groups",
Expand Down Expand Up @@ -3590,6 +3636,27 @@
}
}
},
"github_com_EvolutionAPI_evolution-go_pkg_group_service.UpdateGroupSettingsStruct": {
"type": "object",
"properties": {
"groupJid": {
"type": "string"
},
"action": {
"type": "string",
"enum": [
"announcement",
"not_announcement",
"locked",
"unlocked",
"approval_on",
"approval_off",
"admin_add",
"all_member_add"
]
}
}
},
"github_com_EvolutionAPI_evolution-go_pkg_group_service.LeaveGroupStruct": {
"type": "object",
"properties": {
Expand Down
47 changes: 47 additions & 0 deletions docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,22 @@ definitions:
code:
type: string
type: object
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
github_com_EvolutionAPI_evolution-go_pkg_group_service.UpdateGroupSettingsStruct:
properties:
action:
enum:
- announcement
- not_announcement
- locked
- unlocked
- approval_on
- approval_off
- admin_add
- all_member_add
type: string
groupJid:
type: string
type: object
github_com_EvolutionAPI_evolution-go_pkg_group_service.LeaveGroupStruct:
properties:
groupJid:
Expand Down Expand Up @@ -7113,6 +7129,37 @@ paths:
summary: Leave group
tags:
- Group
/group/settings:
post:
consumes:
- application/json
description: Update group settings (announcement, not_announcement, locked,
unlocked, approval_on, approval_off, admin_add, all_member_add)
parameters:
- description: Group data
in: body
name: message
required: true
schema:
$ref: '#/definitions/github_com_EvolutionAPI_evolution-go_pkg_group_service.UpdateGroupSettingsStruct'
produces:
- application/json
responses:
"200":
description: success
schema:
$ref: '#/definitions/gin.H'
"400":
description: Error on validation
schema:
$ref: '#/definitions/gin.H'
"500":
description: Internal server error
schema:
$ref: '#/definitions/gin.H'
summary: Update group settings
tags:
- Group
/group/list:
get:
consumes:
Expand Down
47 changes: 47 additions & 0 deletions pkg/group/handler/group_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions pkg/routes/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ func (r *Routes) AssignRoutes(eng *gin.Engine) {
routes.GET("/myall", r.groupHandler.GetMyGroups) // TODO: not working
routes.POST("/join", r.groupHandler.JoinGroupLink)
routes.POST("/leave", r.jidValidationMiddleware.ValidateNumberField(), r.groupHandler.LeaveGroup)
routes.POST("/settings", r.jidValidationMiddleware.ValidateNumberField(), r.groupHandler.UpdateGroupSettings)
}
}
routes = eng.Group("/call")
Expand Down