GOWA - WhatsApp REST API with support for UI, Multi Account, Webhooks, and MCP, and Chatwoot. Built with Golang for efficient memory use.
Go botgogolanggolang-whatsappgolang-whatsapp-apirestrest-apiwhatsappwhatsapp-apiwhatsapp-api-gowhatsapp-multi-devicewhatsapp-web-multi-device
feat: add my privacy & my groups API
Aldino Kemal1a902de40122
diff --git a/controllers/user_controller.go b/controllers/user_controller.goindex 32f1ade8..931ec168 100644--- a/controllers/user_controller.go+++ b/controllers/user_controller.go@@ -19,6 +19,8 @@ func NewUserController(service services.UserService) UserController {func (controller *UserController) Route(app *fiber.App) {app.Get("/user/info", controller.UserInfo)app.Get("/user/avatar", controller.UserAvatar)+ app.Get("/user/my/privacy", controller.UserMyPrivacySetting)+ app.Get("/user/my/groups", controller.UserMyListGroups)}func (controller *UserController) UserInfo(c *fiber.Ctx) error {@@ -39,6 +41,7 @@ func (controller *UserController) UserInfo(c *fiber.Ctx) error {Results: response,})}+func (controller *UserController) UserAvatar(c *fiber.Ctx) error {var request structs.UserAvatarRequesterr := c.QueryParser(&request)@@ -57,3 +60,25 @@ func (controller *UserController) UserAvatar(c *fiber.Ctx) error {Results: response,})}++func (controller *UserController) UserMyPrivacySetting(c *fiber.Ctx) error {+ response, err := controller.Service.UserMyPrivacySetting(c)+ utils.PanicIfNeeded(err)++ return c.JSON(utils.ResponseData{+ Code: 200,+ Message: "Success",+ Results: response,+ })+}++func (controller *UserController) UserMyListGroups(c *fiber.Ctx) error {+ response, err := controller.Service.UserMyListGroups(c)+ utils.PanicIfNeeded(err)++ return c.JSON(utils.ResponseData{+ Code: 200,+ Message: "Success",+ Results: response,+ })+}diff --git a/services/user_service.go b/services/user_service.goindex 67a2a37b..fe738466 100644--- a/services/user_service.go+++ b/services/user_service.go@@ -8,4 +8,6 @@ import (type UserService interface {UserInfo(c *fiber.Ctx, request structs.UserInfoRequest) (response structs.UserInfoResponse, err error)UserAvatar(c *fiber.Ctx, request structs.UserAvatarRequest) (response structs.UserAvatarResponse, err error)+ UserMyListGroups(c *fiber.Ctx) (response structs.UserMyListGroupsResponse, err error)+ UserMyPrivacySetting(c *fiber.Ctx) (response structs.UserMyPrivacySettingResponse, err error)}diff --git a/services/user_service_impl.go b/services/user_service_impl.goindex 5ef850b5..5ef6dc5d 100644--- a/services/user_service_impl.go+++ b/services/user_service_impl.go@@ -83,3 +83,30 @@ func (service UserServiceImpl) UserAvatar(_ *fiber.Ctx, request structs.UserAvatreturn response, nil}}++func (service UserServiceImpl) UserMyListGroups(_ *fiber.Ctx) (response structs.UserMyListGroupsResponse, err error) {+ groups, err := service.WaCli.GetJoinedGroups()+ if err != nil {+ return+ }+ fmt.Printf("%+v\n", groups)+ if groups != nil {+ for _, group := range groups {+ response.Data = append(response.Data, *group)+ }+ }+ return response, nil+}++func (service UserServiceImpl) UserMyPrivacySetting(_ *fiber.Ctx) (response structs.UserMyPrivacySettingResponse, err error) {+ resp, err := service.WaCli.TryFetchPrivacySettings(false)+ if err != nil {+ return+ }++ response.GroupAdd = string(resp.GroupAdd)+ response.Status = string(resp.Status)+ response.ReadReceipts = string(resp.ReadReceipts)+ response.Profile = string(resp.Profile)+ return response, nil+}diff --git a/structs/send_struct.go b/structs/send_struct.goindex a8239c41..4d808dc5 100644--- a/structs/send_struct.go+++ b/structs/send_struct.go@@ -1,6 +1,7 @@package structsimport (+ "go.mau.fi/whatsmeow/types""mime/multipart")@@ -39,6 +40,18 @@ type UserAvatarResponse struct {Type string `json:"type"`}+type UserMyPrivacySettingResponse struct {+ GroupAdd string `json:"group_add"`+ LastSeen string `json:"last_seen"`+ Status string `json:"status"`+ Profile string `json:"profile"`+ ReadReceipts string `json:"read_receipts"`+}++type UserMyListGroupsResponse struct {+ Data []types.GroupInfo `json:"data"`+}+// ============================== END USER ==============================// ============================== SEND ==============================