From 67da1b7dd9cc590262f032c9571bcddc570880a8 Mon Sep 17 00:00:00 2001 From: Aldino Kemal Date: Sun, 15 May 2022 19:21:01 +0700 Subject: [PATCH] feat: set chrome as default platform feat: change port from setting --- src/config/settings.go | 13 ++++++--- src/main.go | 2 +- src/structs/send_struct.go | 54 -------------------------------------- src/structs/user_struct.go | 48 +++++++++++++++++++++++++++++++++ src/utils/whatsapp.go | 2 +- 5 files changed, 60 insertions(+), 59 deletions(-) create mode 100644 src/structs/user_struct.go diff --git a/src/config/settings.go b/src/config/settings.go index 7bcc1a8..9d208f1 100644 --- a/src/config/settings.go +++ b/src/config/settings.go @@ -1,5 +1,12 @@ package config -const PathQrCode = "statics/images/qrcode" -const PathSendItems = "statics/images/senditems" -const DBName = "hydrogenWaCli.db" +type Browser string + +const ( + AppPort string = "3000" + + PathQrCode string = "statics/images/qrcode" + PathSendItems string = "statics/images/senditems" + + DBName string = "hydrogenWaCli.db" +) diff --git a/src/main.go b/src/main.go index 524a865..9806893 100644 --- a/src/main.go +++ b/src/main.go @@ -57,7 +57,7 @@ func main() { return ctx.Render("index", fiber.Map{"AppHost": fmt.Sprintf("%s://%s", ctx.Protocol(), ctx.Hostname())}) }) - err = app.Listen(":3000") + err = app.Listen(":" + config.AppPort) if err != nil { log.Fatalln("Failed to start: ", err.Error()) } diff --git a/src/structs/send_struct.go b/src/structs/send_struct.go index bd6dd9f..631a95e 100644 --- a/src/structs/send_struct.go +++ b/src/structs/send_struct.go @@ -1,61 +1,9 @@ package structs import ( - "go.mau.fi/whatsmeow/types" "mime/multipart" ) -// ============================== USER ============================== - -type UserInfoRequest struct { - Phone string `json:"phone" query:"phone"` -} - -type UserInfoResponseDataDevice struct { - User string - Agent uint8 - Device string - Server string - AD bool -} - -type UserInfoResponseData struct { - VerifiedName string `json:"verified_name"` - Status string `json:"status"` - PictureID string `json:"picture_id"` - Devices []UserInfoResponseDataDevice `json:"devices"` -} - -type UserInfoResponse struct { - Data []UserInfoResponseData `json:"data"` -} - -type UserAvatarRequest struct { - Phone string `json:"phone" query:"phone"` -} - -type UserAvatarResponse struct { - URL string `json:"url"` - ID string `json:"id"` - 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 ============================== - type SendType string const TypeUser SendType = "user" @@ -92,5 +40,3 @@ type SendFileRequest struct { type SendFileResponse struct { Status string `json:"status"` } - -// ============================== END SEND ============================== diff --git a/src/structs/user_struct.go b/src/structs/user_struct.go new file mode 100644 index 0000000..12c4ed9 --- /dev/null +++ b/src/structs/user_struct.go @@ -0,0 +1,48 @@ +package structs + +import "go.mau.fi/whatsmeow/types" + +type UserInfoRequest struct { + Phone string `json:"phone" query:"phone"` +} + +type UserInfoResponseDataDevice struct { + User string + Agent uint8 + Device string + Server string + AD bool +} + +type UserInfoResponseData struct { + VerifiedName string `json:"verified_name"` + Status string `json:"status"` + PictureID string `json:"picture_id"` + Devices []UserInfoResponseDataDevice `json:"devices"` +} + +type UserInfoResponse struct { + Data []UserInfoResponseData `json:"data"` +} + +type UserAvatarRequest struct { + Phone string `json:"phone" query:"phone"` +} + +type UserAvatarResponse struct { + URL string `json:"url"` + ID string `json:"id"` + 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"` +} diff --git a/src/utils/whatsapp.go b/src/utils/whatsapp.go index ce1824f..6be5e40 100644 --- a/src/utils/whatsapp.go +++ b/src/utils/whatsapp.go @@ -97,7 +97,7 @@ func InitWaCLI(storeContainer *sqlstore.Container) *whatsmeow.Client { panic(err) } - store.CompanionProps.PlatformType = waProto.CompanionProps_UNKNOWN.Enum() + store.CompanionProps.PlatformType = waProto.CompanionProps_CHROME.Enum() store.CompanionProps.Os = proto.String("AldinoKemal") cli = whatsmeow.NewClient(device, waLog.Stdout("Client", logLevel, true)) cli.AddEventHandler(handler)