From 576bb29e2792a1d6be6469fd36d15a45e3c12644 Mon Sep 17 00:00:00 2001 From: Aldino Kemal Date: Sat, 21 Jan 2023 20:44:49 +0700 Subject: [PATCH] fix: update package version & bug webhook trigger --- src/config/settings.go | 2 +- src/go.mod | 26 ++++++++++----------- src/go.sum | 28 ++++++++++++++++++++++ src/pkg/whatsapp/whatsapp.go | 4 ++-- src/services/send.go | 45 +++++++++++++++--------------------- 5 files changed, 62 insertions(+), 43 deletions(-) diff --git a/src/config/settings.go b/src/config/settings.go index e526ce3..b893c51 100644 --- a/src/config/settings.go +++ b/src/config/settings.go @@ -6,7 +6,7 @@ import ( ) var ( - AppVersion = "v4.4.4" + AppVersion = "v4.4.5" AppPort = "3000" AppDebug = false AppOs = fmt.Sprintf("AldinoKemal") diff --git a/src/go.mod b/src/go.mod index f563d18..222177a 100644 --- a/src/go.mod +++ b/src/go.mod @@ -3,11 +3,11 @@ module github.com/aldinokemal/go-whatsapp-web-multidevice go 1.19 require ( - github.com/dustin/go-humanize v1.0.0 + github.com/dustin/go-humanize v1.0.1 github.com/go-ozzo/ozzo-validation/v4 v4.3.0 - github.com/gofiber/fiber/v2 v2.40.1 - github.com/gofiber/template v1.7.3 - github.com/gofiber/websocket/v2 v2.1.2 + github.com/gofiber/fiber/v2 v2.41.0 + github.com/gofiber/template v1.7.4 + github.com/gofiber/websocket/v2 v2.1.3 github.com/google/uuid v1.3.0 github.com/h2non/bimg v1.1.9 github.com/markbates/pkger v0.17.1 @@ -15,10 +15,10 @@ require ( github.com/sirupsen/logrus v1.9.0 github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e github.com/spf13/cobra v1.6.1 - github.com/stretchr/testify v1.8.0 - github.com/valyala/fasthttp v1.43.0 - go.mau.fi/libsignal v0.0.0-20221015105917-d970e7c3c9cf - go.mau.fi/whatsmeow v0.0.0-20221213225758-70ef67df3c68 + github.com/stretchr/testify v1.8.1 + github.com/valyala/fasthttp v1.44.0 + go.mau.fi/libsignal v0.1.0 + go.mau.fi/whatsmeow v0.0.0-20230120142431-cd2d1213eff6 google.golang.org/protobuf v1.28.1 ) @@ -27,13 +27,13 @@ require ( github.com/andybalholm/brotli v1.0.4 // indirect github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/fasthttp/websocket v1.5.0 // indirect + github.com/fasthttp/websocket v1.5.1 // indirect github.com/gobuffalo/here v0.6.7 // indirect github.com/gorilla/websocket v1.5.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect - github.com/klauspost/compress v1.15.13 // indirect + github.com/klauspost/compress v1.15.14 // indirect github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.16 // indirect + github.com/mattn/go-isatty v0.0.17 // indirect github.com/mattn/go-runewidth v0.0.14 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/rivo/uniseg v0.4.3 // indirect @@ -41,8 +41,8 @@ require ( github.com/spf13/pflag v1.0.5 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/tcplisten v1.0.0 // indirect - golang.org/x/crypto v0.4.0 // indirect - golang.org/x/sys v0.3.0 // indirect + golang.org/x/crypto v0.5.0 // indirect + golang.org/x/sys v0.4.0 // indirect golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/src/go.sum b/src/go.sum index a91acc3..5ca4057 100644 --- a/src/go.sum +++ b/src/go.sum @@ -52,6 +52,7 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03 github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53/go.mod h1:+3IMCy2vIlbG1XG/0ggNQv0SvxCAIpPM5b1nCz56Xno= github.com/CloudyKit/jet/v6 v6.1.0/go.mod h1:d3ypHeIRNo2+XyqnGA8s+aphtcVpjP5hPwP/Lzo7Ro4= +github.com/CloudyKit/jet/v6 v6.2.0/go.mod h1:d3ypHeIRNo2+XyqnGA8s+aphtcVpjP5hPwP/Lzo7Ro4= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/Joker/hpp v1.0.0/go.mod h1:8x5n+M1Hp5hC0g8okX3sR3vFQwynaX/UgSOM9MeBKzY= github.com/Joker/jade v1.1.3/go.mod h1:T+2WLyt7VH6Lp0TRxQrUYEs64nRc83wkMQrfeIQKduM= @@ -108,6 +109,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= +github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= +github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= github.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385/go.mod h1:0vRUJqYpeSZifjYj7uP3BG/gKcuzL9xWVV/Y+cK33KM= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= @@ -122,6 +125,8 @@ github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7 github.com/envoyproxy/protoc-gen-validate v0.6.2/go.mod h1:2t7qjJNvHPx8IjnBOzl9E9/baC+qXE/TeeyBRzgJDws= github.com/fasthttp/websocket v1.5.0 h1:B4zbe3xXyvIdnqjOZrafVFklCUq5ZLo/TqCt5JA1wLE= github.com/fasthttp/websocket v1.5.0/go.mod h1:n0BlOQvJdPbTuBkZT0O5+jk/sp/1/VCzquR1BehI2F4= +github.com/fasthttp/websocket v1.5.1 h1:iZsMv5OtZ1E52hhCnlOm/feLCrPhutlrZgvEGcZa1FM= +github.com/fasthttp/websocket v1.5.1/go.mod h1:s+gJkEn38QXLkNfOe/n75Yb8we+VEho1vYqeUYheomw= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= @@ -144,10 +149,16 @@ github.com/gobuffalo/here v0.6.7/go.mod h1:vuCfanjqckTuRlqAitJz6QC4ABNnS27wLb816 github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gofiber/fiber/v2 v2.40.1 h1:pc7n9VVpGIqNsvg9IPLQhyFEMJL8gCs1kneH5D1pIl4= github.com/gofiber/fiber/v2 v2.40.1/go.mod h1:Gko04sLksnHbzLSRBFWPFdzM9Ws9pRxvvIaohJK1dsk= +github.com/gofiber/fiber/v2 v2.41.0 h1:YhNoUS/OTjEz+/WLYuQ01xI7RXgKEFnGBKMagAu5f0M= +github.com/gofiber/fiber/v2 v2.41.0/go.mod h1:RdebcCuCRFp4W6hr3968/XxwJVg0K+jr9/Ae0PFzZ0Q= github.com/gofiber/template v1.7.3 h1:ddWRgCB7kDdsgH7Qakwmlj6qM3kjggaT0aIhxLGatD0= github.com/gofiber/template v1.7.3/go.mod h1:MI/DIYL6czowb8KLkkNAojCifLnAVQcN3KGEUDvlFtU= +github.com/gofiber/template v1.7.4 h1:3K86NpBhDOBAhk6keecxNwqSgALqaHlUIhNItR96N2Y= +github.com/gofiber/template v1.7.4/go.mod h1:rePzgcCYbLaUvaaU7XeAOOg3c0Sif4vRVw3TFjLabxY= github.com/gofiber/websocket/v2 v2.1.2 h1:EulKyLB/fJgui5+6c8irwEnYQ9FRsrLZfkrq9OfTDGc= github.com/gofiber/websocket/v2 v2.1.2/go.mod h1:S+sKWo0xeC7Wnz5h4/8f6D/NxsrLFIdWDYB3SyVO9pE= +github.com/gofiber/websocket/v2 v2.1.3 h1:F+NSwIZPZ8L5w+cevkv4AqoXs15zAiT+yRpMZudoWbk= +github.com/gofiber/websocket/v2 v2.1.3/go.mod h1:xBRiR0hs+PDqZxE7d/VA96mvK1d1t4EBSRR9Q7KxkBs= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= @@ -279,6 +290,8 @@ github.com/klauspost/compress v1.14.1/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47e github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU= github.com/klauspost/compress v1.15.13 h1:NFn1Wr8cfnenSJSA46lLq4wHCcBzKTSjnBIexDMMOV0= github.com/klauspost/compress v1.15.13/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM= +github.com/klauspost/compress v1.15.14 h1:i7WCKDToww0wA+9qrUZ1xOjp218vfFo3nTU6UHp+gOc= +github.com/klauspost/compress v1.15.14/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= @@ -307,6 +320,8 @@ github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Ky github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng= +github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU= github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-slim v0.0.0-20200618151855-bde33eecb5ee/go.mod h1:ma9TUJeni8LGZMJvOwbAv/FOwiwqIMQN570LnpqCBSM= @@ -384,6 +399,7 @@ github.com/spf13/viper v1.10.0/go.mod h1:SoyBPwAtKDzypXNDFKN5kzH7ppppbGZtls1UpIy github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= @@ -393,6 +409,8 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= @@ -401,6 +419,8 @@ github.com/valyala/fasthttp v1.33.0/go.mod h1:KJRK/MXx0J+yd0c5hlR+s1tIHD72sniU8Z github.com/valyala/fasthttp v1.41.0/go.mod h1:f6VbjjoI3z1NDOZOv17o6RvtRSWxC77seBFc2uWtgiY= github.com/valyala/fasthttp v1.43.0 h1:Gy4sb32C98fbzVWZlTM1oTMdLWGyvxR03VhM6cBIU4g= github.com/valyala/fasthttp v1.43.0/go.mod h1:f6VbjjoI3z1NDOZOv17o6RvtRSWxC77seBFc2uWtgiY= +github.com/valyala/fasthttp v1.44.0 h1:R+gLUhldIsfg1HokMuQjdQ5bh9nuXHPIfvkYUu9eR5Q= +github.com/valyala/fasthttp v1.44.0/go.mod h1:f6VbjjoI3z1NDOZOv17o6RvtRSWxC77seBFc2uWtgiY= github.com/valyala/tcplisten v1.0.0 h1:rBHj/Xf+E1tRGZyWIWwJDiRY0zc1Js+CV5DqwacVSA8= github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc= github.com/yosssi/ace v0.0.5/go.mod h1:ALfIzm2vT7t5ZE7uoIZqF3TQ7SAOyupFZnkrF5id+K0= @@ -415,8 +435,12 @@ go.etcd.io/etcd/client/pkg/v3 v3.5.1/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3 go.etcd.io/etcd/client/v2 v2.305.1/go.mod h1:pMEacxZW7o8pg4CrFE7pquyCJJzZvkvdD2RibOCCCGs= go.mau.fi/libsignal v0.0.0-20221015105917-d970e7c3c9cf h1:mzPxXBgDPHKDHMVV1tIWh7lwCiRpzCsXC0gNRX+K07c= go.mau.fi/libsignal v0.0.0-20221015105917-d970e7c3c9cf/go.mod h1:XCjaU93vl71YNRPn059jMrK0xRDwVO5gKbxoPxow9mQ= +go.mau.fi/libsignal v0.1.0 h1:vAKI/nJ5tMhdzke4cTK1fb0idJzz1JuEIpmjprueC+c= +go.mau.fi/libsignal v0.1.0/go.mod h1:R8ovrTezxtUNzCQE5PH30StOQWWeBskBsWE55vMfY9I= go.mau.fi/whatsmeow v0.0.0-20221213225758-70ef67df3c68 h1:uieThnMYyFDdUNDrHxauuZOW5ip+igWhHwyWFNjA2Sw= go.mau.fi/whatsmeow v0.0.0-20221213225758-70ef67df3c68/go.mod h1:2yweL8nczvtlIxkrvCb0y8xiO13rveX9lJPambwYV/E= +go.mau.fi/whatsmeow v0.0.0-20230120142431-cd2d1213eff6 h1:/rhe2DT4A9BBoOZVzXtq48kBhHDpBGUhj94e8c9A0e0= +go.mau.fi/whatsmeow v0.0.0-20230120142431-cd2d1213eff6/go.mod h1:TrdC8N6SnPFxWo5FiMnDIDFuVyfOLzy5dWDaUPNjcHY= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= @@ -442,6 +466,8 @@ golang.org/x/crypto v0.0.0-20220112180741-5e0467b6c7ce/go.mod h1:IxCIyHEi3zRg3s0 golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.4.0 h1:UVQgzMY87xqpKNgb+kDsll2Igd33HszWHFLmpaRMq/8= golang.org/x/crypto v0.4.0/go.mod h1:3quD/ATkf6oY+rnes5c3ExXTbLc8mueNue5/DoinL80= +golang.org/x/crypto v0.5.0 h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE= +golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -625,6 +651,8 @@ golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ= golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18= +golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/src/pkg/whatsapp/whatsapp.go b/src/pkg/whatsapp/whatsapp.go index d70a313..81c25ef 100644 --- a/src/pkg/whatsapp/whatsapp.go +++ b/src/pkg/whatsapp/whatsapp.go @@ -209,10 +209,10 @@ func handler(rawEvt interface{}) { } if config.WhatsappAutoReplyMessage != "" && !isGroupJid(evt.Info.Chat.String()) { - _, _ = cli.SendMessage(context.Background(), evt.Info.Sender, "", &waProto.Message{Conversation: proto.String(config.WhatsappAutoReplyMessage)}) + _, _ = cli.SendMessage(context.Background(), evt.Info.Sender, &waProto.Message{Conversation: proto.String(config.WhatsappAutoReplyMessage)}) } - if config.WhatsappAutoReplyWebhook != "" && !isGroupJid(evt.Info.Chat.String()) && !strings.Contains(evt.Info.SourceString(), "in") { + if config.WhatsappAutoReplyWebhook != "" && !isGroupJid(evt.Info.Chat.String()) && !strings.Contains(evt.Info.SourceString(), "broadcast") { if err := sendAutoReplyWebhook(evt); err != nil { logrus.Error("Failed to send webhoook", err) } diff --git a/src/services/send.go b/src/services/send.go index 0b1f2ea..04e1652 100644 --- a/src/services/send.go +++ b/src/services/send.go @@ -41,14 +41,13 @@ func (service serviceSend) SendText(ctx context.Context, request domainSend.Mess return response, err } - msgId := whatsmeow.GenerateMessageID() msg := &waProto.Message{Conversation: proto.String(request.Message)} - ts, err := service.WaCli.SendMessage(ctx, dataWaRecipient, msgId, msg) + ts, err := service.WaCli.SendMessage(ctx, dataWaRecipient, msg) if err != nil { return response, err } - response.MessageID = msgId + response.MessageID = ts.ID response.Status = fmt.Sprintf("Message sent to %s (server timestamp: %s)", request.Phone, ts) return response, nil } @@ -122,7 +121,6 @@ func (service serviceSend) SendImage(ctx context.Context, request domainSend.Ima } dataWaThumbnail, err := os.ReadFile(imageThumbnail) - msgId := whatsmeow.GenerateMessageID() msg := &waProto.Message{ImageMessage: &waProto.ImageMessage{ JpegThumbnail: dataWaThumbnail, Caption: proto.String(dataWaCaption), @@ -135,7 +133,7 @@ func (service serviceSend) SendImage(ctx context.Context, request domainSend.Ima FileLength: proto.Uint64(uint64(len(dataWaImage))), ViewOnce: proto.Bool(request.ViewOnce), }} - ts, err := service.WaCli.SendMessage(ctx, dataWaRecipient, msgId, msg) + ts, err := service.WaCli.SendMessage(ctx, dataWaRecipient, msg) go func() { errDelete := utils.RemoveFile(0, deletedItems...) if errDelete != nil { @@ -146,7 +144,7 @@ func (service serviceSend) SendImage(ctx context.Context, request domainSend.Ima return response, err } - response.MessageID = msgId + response.MessageID = ts.ID response.Status = fmt.Sprintf("Message sent to %s (server timestamp: %s)", request.Phone, ts) return response, nil } @@ -178,7 +176,6 @@ func (service serviceSend) SendFile(ctx context.Context, request domainSend.File return response, err } - msgId := whatsmeow.GenerateMessageID() msg := &waProto.Message{DocumentMessage: &waProto.DocumentMessage{ Url: proto.String(uploadedFile.URL), Mimetype: proto.String(http.DetectContentType(dataWaFile)), @@ -191,7 +188,7 @@ func (service serviceSend) SendFile(ctx context.Context, request domainSend.File DirectPath: proto.String(uploadedFile.DirectPath), Caption: proto.String(request.Caption), }} - ts, err := service.WaCli.SendMessage(ctx, dataWaRecipient, msgId, msg) + ts, err := service.WaCli.SendMessage(ctx, dataWaRecipient, msg) go func() { errDelete := utils.RemoveFile(0, oriFilePath) if errDelete != nil { @@ -202,7 +199,7 @@ func (service serviceSend) SendFile(ctx context.Context, request domainSend.File return response, err } - response.MessageID = msgId + response.MessageID = ts.ID response.Status = fmt.Sprintf("Document sent to %s (server timestamp: %s)", request.Phone, ts) return response, nil } @@ -285,7 +282,6 @@ func (service serviceSend) SendVideo(ctx context.Context, request domainSend.Vid return response, err } - msgId := whatsmeow.GenerateMessageID() msg := &waProto.Message{VideoMessage: &waProto.VideoMessage{ Url: proto.String(uploaded.URL), Mimetype: proto.String(http.DetectContentType(dataWaVideo)), @@ -301,7 +297,7 @@ func (service serviceSend) SendVideo(ctx context.Context, request domainSend.Vid ThumbnailSha256: dataWaThumbnail, ThumbnailDirectPath: proto.String(uploaded.DirectPath), }} - ts, err := service.WaCli.SendMessage(ctx, dataWaRecipient, msgId, msg) + ts, err := service.WaCli.SendMessage(ctx, dataWaRecipient, msg) go func() { errDelete := utils.RemoveFile(1, deletedItems...) if errDelete != nil { @@ -312,7 +308,7 @@ func (service serviceSend) SendVideo(ctx context.Context, request domainSend.Vid return response, err } - response.MessageID = msgId + response.MessageID = ts.ID response.Status = fmt.Sprintf("Video sent to %s (server timestamp: %s)", request.Phone, ts) return response, nil } @@ -329,17 +325,16 @@ func (service serviceSend) SendContact(ctx context.Context, request domainSend.C msgVCard := fmt.Sprintf("BEGIN:VCARD\nVERSION:3.0\nN:;%v;;;\nFN:%v\nTEL;type=CELL;waid=%v:+%v\nEND:VCARD", request.ContactName, request.ContactName, request.ContactPhone, request.ContactPhone) - msgId := whatsmeow.GenerateMessageID() msg := &waProto.Message{ContactMessage: &waProto.ContactMessage{ DisplayName: proto.String(request.ContactName), Vcard: proto.String(msgVCard), }} - ts, err := service.WaCli.SendMessage(ctx, dataWaRecipient, "", msg) + ts, err := service.WaCli.SendMessage(ctx, dataWaRecipient, msg) if err != nil { return response, err } - response.MessageID = msgId + response.MessageID = ts.ID response.Status = fmt.Sprintf("Contact sent to %s (server timestamp: %s)", request.Phone, ts) return response, nil } @@ -354,7 +349,6 @@ func (service serviceSend) SendLink(ctx context.Context, request domainSend.Link return response, err } - msgId := whatsmeow.GenerateMessageID() msg := &waProto.Message{ExtendedTextMessage: &waProto.ExtendedTextMessage{ Text: proto.String(request.Caption), MatchedText: proto.String(request.Caption), @@ -366,12 +360,12 @@ func (service serviceSend) SendLink(ctx context.Context, request domainSend.Link }, }, }} - ts, err := service.WaCli.SendMessage(ctx, dataWaRecipient, msgId, msg) + ts, err := service.WaCli.SendMessage(ctx, dataWaRecipient, msg) if err != nil { return response, err } - response.MessageID = msgId + response.MessageID = ts.ID response.Status = fmt.Sprintf("Link sent to %s (server timestamp: %s)", request.Phone, ts) return response, nil } @@ -387,7 +381,6 @@ func (service serviceSend) SendLocation(ctx context.Context, request domainSend. } // Compose WhatsApp Proto - msgId := whatsmeow.GenerateMessageID() msg := &waProto.Message{ LocationMessage: &waProto.LocationMessage{ DegreesLatitude: proto.Float64(utils.StrToFloat64(request.Latitude)), @@ -396,12 +389,12 @@ func (service serviceSend) SendLocation(ctx context.Context, request domainSend. } // Send WhatsApp Message Proto - ts, err := service.WaCli.SendMessage(ctx, dataWaRecipient, msgId, msg) + ts, err := service.WaCli.SendMessage(ctx, dataWaRecipient, msg) if err != nil { return response, err } - response.MessageID = msgId + response.MessageID = ts.ID response.Status = fmt.Sprintf("Send location success %s (server timestamp: %s)", request.Phone, ts) return response, nil } @@ -416,13 +409,12 @@ func (service serviceSend) Revoke(ctx context.Context, request domainSend.Revoke return response, err } - msgId := whatsmeow.GenerateMessageID() - ts, err := service.WaCli.SendMessage(context.Background(), dataWaRecipient, msgId, service.WaCli.BuildRevoke(dataWaRecipient, types.EmptyJID, request.MessageID)) + ts, err := service.WaCli.SendMessage(context.Background(), dataWaRecipient, service.WaCli.BuildRevoke(dataWaRecipient, types.EmptyJID, request.MessageID)) if err != nil { return response, err } - response.MessageID = msgId + response.MessageID = ts.ID response.Status = fmt.Sprintf("Revoke success %s (server timestamp: %s)", request.Phone, ts) return response, nil } @@ -437,14 +429,13 @@ func (service serviceSend) UpdateMessage(ctx context.Context, request domainSend return response, err } - msgId := whatsmeow.GenerateMessageID() msg := &waProto.Message{Conversation: proto.String(request.Message)} - ts, err := service.WaCli.SendMessage(context.Background(), dataWaRecipient, msgId, service.WaCli.BuildEdit(dataWaRecipient, request.MessageID, msg)) + ts, err := service.WaCli.SendMessage(context.Background(), dataWaRecipient, service.WaCli.BuildEdit(dataWaRecipient, request.MessageID, msg)) if err != nil { return response, err } - response.MessageID = msgId + response.MessageID = ts.ID response.Status = fmt.Sprintf("Update message success %s (server timestamp: %s)", request.Phone, ts) return response, nil }