Browse Source

feat: Update app version to v5.3.0 and upgrade Go version to 1.24

feat: add MyListContacts endpoint
pull/271/head
Aldino Kemal 1 year ago
parent
commit
e83c9d2893
  1. 4
      .github/workflows/release-linux.yml
  2. 2
      .github/workflows/release-mac.yml
  3. 2
      .github/workflows/release-windows.yml
  4. 2
      docker/golang.Dockerfile
  5. 47
      docs/openapi.yaml
  6. 1
      readme.md
  7. 2
      src/config/settings.go
  8. 12
      src/domains/user/account.go
  9. 1
      src/domains/user/user.go
  10. 9
      src/go.mod
  11. 32
      src/go.sum
  12. 5
      src/internal/rest/message.go
  13. 13
      src/internal/rest/user.go
  14. 18
      src/services/user.go
  15. 2
      src/views/components/AccountAvatar.js
  16. 2
      src/views/components/AccountChangeAvatar.js
  17. 79
      src/views/components/AccountContact.js
  18. 2
      src/views/components/AccountPrivacy.js
  19. 2
      src/views/components/AccountUserInfo.js
  20. 4
      src/views/index.html

4
.github/workflows/release-linux.yml

@ -18,7 +18,7 @@ jobs:
- name: Golang Installation
uses: actions/setup-go@v5
with:
go-version: '1.23'
go-version: '1.24'
- name: Golang build
run: |
cd src && go build -o linux-amd64
@ -38,7 +38,7 @@ jobs:
- name: Golang Installation
uses: actions/setup-go@v5
with:
go-version: '1.23'
go-version: '1.24'
- name: Golang build
run: |
cd src && go build -o linux-arm64

2
.github/workflows/release-mac.yml

@ -18,7 +18,7 @@ jobs:
- name: Golang Installation
uses: actions/setup-go@v5
with:
go-version: '1.23'
go-version: '1.24'
- name: Golang build
run: |
cd src && go build -o darwin-amd64

2
.github/workflows/release-windows.yml

@ -18,7 +18,7 @@ jobs:
- name: Golang Installation
uses: actions/setup-go@v5
with:
go-version: '1.23'
go-version: '1.24'
- name: Golang build
run: |
cd src && go build -o windows-amd64.exe

2
docker/golang.Dockerfile

@ -1,7 +1,7 @@
############################
# STEP 1 build executable binary
############################
FROM golang:1.23-alpine3.20 AS builder
FROM golang:1.24-alpine3.20 AS builder
RUN apk update && apk add --no-cache gcc musl-dev gcompat
WORKDIR /whatsapp
COPY ./src .

47
docs/openapi.yaml

@ -1,7 +1,7 @@
openapi: "3.0.0"
info:
title: WhatsApp API MultiDevice
version: 5.1.0
version: 5.2.0
description: This API is used for sending whatsapp via API
servers:
- url: http://localhost:3000
@ -282,6 +282,26 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/ErrorInternalServer'
/user/my/contacts:
get:
operationId: userMyContacts
tags:
- user
summary: Get list of user contacts
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/MyListContactsResponse'
'500':
description: Internal Server Error
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorInternalServer'
/send/message:
post:
operationId: sendMessage
@ -1646,6 +1666,31 @@ components:
role:
type: string
example: "subscriber"
MyListContactsResponse:
type: object
properties:
code:
type: string
example: "SUCCESS"
message:
type: string
example: "Success get list contacts"
results:
type: object
properties:
data:
type: array
items:
$ref: '#/components/schemas/MyListContacts'
MyListContacts:
type: object
properties:
jid:
type: string
example: "628123123123123@s.whatsapp.net"
name:
type: string
example: "Aldino Kemal"
GroupResponse:
type: object
properties:

1
readme.md

@ -187,6 +187,7 @@ You can fork or edit this source code !
| ✅ | User My Groups | GET | /user/my/groups |
| ✅ | User My Newsletter | GET | /user/my/newsletters |
| ✅ | User My Privacy Setting | GET | /user/my/privacy |
| ✅ | User My Contacts | GET | /user/my/contacts |
| ✅ | Send Message | POST | /send/message |
| ✅ | Send Image | POST | /send/image |
| ✅ | Send Audio | POST | /send/audio |

2
src/config/settings.go

@ -5,7 +5,7 @@ import (
)
var (
AppVersion = "v5.2.0"
AppVersion = "v5.3.0"
AppPort = "3000"
AppDebug = false
AppOs = "AldinoKemal"

12
src/domains/user/account.go

@ -1,8 +1,9 @@
package user
import (
"go.mau.fi/whatsmeow/types"
"mime/multipart"
"go.mau.fi/whatsmeow/types"
)
type InfoRequest struct {
@ -59,3 +60,12 @@ type MyListNewsletterResponse struct {
type ChangeAvatarRequest struct {
Avatar *multipart.FileHeader `json:"avatar" form:"avatar"`
}
type MyListContactsResponse struct {
Data []MyListContactsResponseData `json:"data"`
}
type MyListContactsResponseData struct {
JID types.JID `json:"jid"`
Name string `json:"name"`
}

1
src/domains/user/user.go

@ -11,4 +11,5 @@ type IUserService interface {
MyListGroups(ctx context.Context) (response MyListGroupsResponse, err error)
MyListNewsletter(ctx context.Context) (response MyListNewsletterResponse, err error)
MyPrivacySetting(ctx context.Context) (response MyPrivacySettingResponse, err error)
MyListContacts(ctx context.Context) (response MyListContactsResponse, err error)
}

9
src/go.mod

@ -1,8 +1,6 @@
module github.com/aldinokemal/go-whatsapp-web-multidevice
go 1.23.0
toolchain go1.24.0
go 1.24.0
require (
github.com/PuerkitoBio/goquery v1.10.2
@ -22,7 +20,7 @@ require (
github.com/stretchr/testify v1.10.0
github.com/valyala/fasthttp v1.59.0
go.mau.fi/libsignal v0.1.2
go.mau.fi/whatsmeow v0.0.0-20250221160813-35b965ceadf1
go.mau.fi/whatsmeow v0.0.0-20250225112721-b7530f3a5056
google.golang.org/protobuf v1.36.5
)
@ -58,10 +56,9 @@ require (
github.com/spf13/pflag v1.0.6 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/tcplisten v1.0.0 // indirect
go.mau.fi/util v0.8.5 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.34.0 // indirect
golang.org/x/crypto v0.35.0 // indirect
golang.org/x/exp v0.0.0-20250218142911-aa4b98e5adaa // indirect
golang.org/x/image v0.24.0 // indirect
golang.org/x/net v0.35.0 // indirect

32
src/go.sum

@ -1,7 +1,5 @@
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
github.com/PuerkitoBio/goquery v1.10.1 h1:Y8JGYUkXWTGRB6Ars3+j3kN0xg1YqqlwvdTV8WTFQcU=
github.com/PuerkitoBio/goquery v1.10.1/go.mod h1:IYiHrOMps66ag56LEH7QYDDupKXyo5A8qrjIx3ZtujY=
github.com/PuerkitoBio/goquery v1.10.2 h1:7fh2BdHcG6VFZsK7toXBT/Bh1z5Wmy8Q9MV9HqT2AM8=
github.com/PuerkitoBio/goquery v1.10.2/go.mod h1:0guWGjcLu9AYC7C1GHnpysHy056u9aEkUHwhdnePMCU=
github.com/andybalholm/brotli v1.1.1 h1:PR2pgnyFznKEugtsUo0xLdDop5SKXd5Qf5ysW+7XdTA=
@ -12,7 +10,6 @@ github.com/asaskevich/govalidator v0.0.0-20200108200545-475eaeb16496/go.mod h1:o
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3dyBCFEj5IhUbnKptjxatkF07cF2ak3yi77so=
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw=
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@ -51,8 +48,6 @@ github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc=
github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0=
github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=
github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
@ -107,11 +102,8 @@ github.com/spf13/afero v1.12.0 h1:UcOPyRBYczmFn6yvphxkn9ZEOY65cpwGKb5mL36mrqs=
github.com/spf13/afero v1.12.0/go.mod h1:ZTlWwG4/ahT8W7T0WQ5uYmjI9duaLQGy3Q2OAl4sk/4=
github.com/spf13/cast v1.7.1 h1:cuNEagBQEHWN1FnbGEjCXL2szYEXqfJPbP2HNUaca9Y=
github.com/spf13/cast v1.7.1/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM=
github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y=
github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo=
github.com/spf13/cobra v1.9.1/go.mod h1:nDyEzZ8ogv936Cinf6g1RU9MRY64Ir93oCnqb9wxYW0=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o=
github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/spf13/viper v1.19.0 h1:RWq5SEjt8o25SROyN3z2OrDB9l7RPd3lwTWU8EcEdcI=
@ -125,27 +117,17 @@ github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasthttp v1.58.0 h1:GGB2dWxSbEprU9j0iMJHgdKYJVDyjrOwF9RE59PbRuE=
github.com/valyala/fasthttp v1.58.0/go.mod h1:SYXvHHaFp7QZHGKSHmoMipInhrI5StHrhDTYVEjK/Kw=
github.com/valyala/fasthttp v1.59.0 h1:Qu0qYHfXvPk1mSLNqcFtEk6DpxgA26hy6bmydotDpRI=
github.com/valyala/fasthttp v1.59.0/go.mod h1:GTxNb9Bc6r2a9D0TWNSPwDz78UxnTGBViY3xZNEqyYU=
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/xyproto/randomstring v1.0.5 h1:YtlWPoRdgMu3NZtP45drfy1GKoojuR7hmRcnhZqKjWU=
github.com/xyproto/randomstring v1.0.5/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
go.mau.fi/libsignal v0.1.1 h1:m/0PGBh4QKP/I1MQ44ti4C0fMbLMuHb95cmDw01FIpI=
go.mau.fi/libsignal v0.1.1/go.mod h1:QLs89F/OA3ThdSL2Wz2p+o+fi8uuQUz0e1BRa6ExdBw=
go.mau.fi/libsignal v0.1.2 h1:Vs16DXWxSKyzVtI+EEXLCSy5pVWzzCzp/2eqFGvLyP0=
go.mau.fi/libsignal v0.1.2/go.mod h1:JpnLSSJptn/s1sv7I56uEMywvz8x4YzxeF5OzdPb6PE=
go.mau.fi/util v0.8.4 h1:mVKlJcXWfVo8ZW3f4vqtjGpqtZqJvX4ETekxawt2vnQ=
go.mau.fi/util v0.8.4/go.mod h1:MOfGTs1CBuK6ERTcSL4lb5YU7/ujz09eOPVEDckuazY=
go.mau.fi/util v0.8.5 h1:PwCAAtcfK0XxZ4sdErJyfBMkTEWoQU33aB7QqDDzQRI=
go.mau.fi/util v0.8.5/go.mod h1:Ycug9mrbztlahHPEJ6H5r8Nu/xqZaWbE5vPHVWmfz6M=
go.mau.fi/whatsmeow v0.0.0-20250210124836-838d5eeaf73e h1:29JB5UMhd3kzLj0GpKUnZM8ZpyP3o9Kd0iDRtXgLvog=
go.mau.fi/whatsmeow v0.0.0-20250210124836-838d5eeaf73e/go.mod h1:PG1x7fBW66I9q/e8a9mU2qF9M94+kK32MceMWgxBoiw=
go.mau.fi/whatsmeow v0.0.0-20250221160813-35b965ceadf1 h1:mqlGS29j1rtg4Wl7VbRyd6yHBqLLgvUN2EMnNQ6ZiSY=
go.mau.fi/whatsmeow v0.0.0-20250221160813-35b965ceadf1/go.mod h1:6hRrUtDWI2wTRClOd6m17GwrFE2a8/p5R4pjJsIVn+U=
go.mau.fi/whatsmeow v0.0.0-20250225112721-b7530f3a5056 h1:1JQUOpYXhFSEQgXMEWD/ZH38FrIe5i1yjxSBwa0aN/Q=
go.mau.fi/whatsmeow v0.0.0-20250225112721-b7530f3a5056/go.mod h1:6hRrUtDWI2wTRClOd6m17GwrFE2a8/p5R4pjJsIVn+U=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
@ -154,12 +136,8 @@ golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliY
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus=
golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M=
golang.org/x/crypto v0.34.0 h1:+/C6tk6rf/+t5DhUketUbD1aNGqiSX3j15Z6xuIDlBA=
golang.org/x/crypto v0.34.0/go.mod h1:dy7dXNW32cAb/6/PRuTNsix8T+vJAqvuIy5Bli/x0YQ=
golang.org/x/exp v0.0.0-20250207012021-f9890c6ad9f3 h1:qNgPs5exUA+G0C96DrPwNrvLSj7GT/9D+3WMWUcUg34=
golang.org/x/exp v0.0.0-20250207012021-f9890c6ad9f3/go.mod h1:tujkw807nyEEAamNbDrEGzRav+ilXA7PCRAd6xsmwiU=
golang.org/x/crypto v0.35.0 h1:b15kiHdrGCHrP6LvwaQ3c03kgNhhiMgvlhxHQhmg2Xs=
golang.org/x/crypto v0.35.0/go.mod h1:dy7dXNW32cAb/6/PRuTNsix8T+vJAqvuIy5Bli/x0YQ=
golang.org/x/exp v0.0.0-20250218142911-aa4b98e5adaa h1:t2QcU6V556bFjYgu4L6C+6VrCPyJZ+eyRsABUPs1mz4=
golang.org/x/exp v0.0.0-20250218142911-aa4b98e5adaa/go.mod h1:BHOTPb3L19zxehTsLoJXVaTktb06DFgmdW6Wb9s8jqk=
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
@ -179,8 +157,6 @@ golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0=
golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k=
golang.org/x/net v0.35.0 h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8=
golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=

5
src/internal/rest/message.go

@ -1,7 +1,6 @@
package rest
import (
"github.com/aldinokemal/go-whatsapp-web-multidevice/domains/message"
domainMessage "github.com/aldinokemal/go-whatsapp-web-multidevice/domains/message"
"github.com/aldinokemal/go-whatsapp-web-multidevice/pkg/utils"
"github.com/aldinokemal/go-whatsapp-web-multidevice/pkg/whatsapp"
@ -82,7 +81,7 @@ func (controller *Message) UpdateMessage(c *fiber.Ctx) error {
}
func (controller *Message) ReactMessage(c *fiber.Ctx) error {
var request message.ReactionRequest
var request domainMessage.ReactionRequest
err := c.BodyParser(&request)
utils.PanicIfNeeded(err)
@ -101,7 +100,7 @@ func (controller *Message) ReactMessage(c *fiber.Ctx) error {
}
func (controller *Message) MarkAsRead(c *fiber.Ctx) error {
var request message.MarkAsReadRequest
var request domainMessage.MarkAsReadRequest
err := c.BodyParser(&request)
utils.PanicIfNeeded(err)

13
src/internal/rest/user.go

@ -19,6 +19,7 @@ func InitRestUser(app *fiber.App, service domainUser.IUserService) User {
app.Get("/user/my/privacy", rest.UserMyPrivacySetting)
app.Get("/user/my/groups", rest.UserMyListGroups)
app.Get("/user/my/newsletters", rest.UserMyListNewsletter)
app.Get("/user/my/contacts", rest.UserMyListContacts)
return rest
}
@ -112,3 +113,15 @@ func (controller *User) UserMyListNewsletter(c *fiber.Ctx) error {
Results: response,
})
}
func (controller *User) UserMyListContacts(c *fiber.Ctx) error {
response, err := controller.Service.MyListContacts(c.UserContext())
utils.PanicIfNeeded(err)
return c.JSON(utils.ResponseData{
Status: 200,
Code: "SUCCESS",
Message: "Success get list contacts",
Results: response,
})
}

18
src/services/user.go

@ -160,6 +160,24 @@ func (service userService) MyPrivacySetting(_ context.Context) (response domainU
return response, nil
}
func (service userService) MyListContacts(ctx context.Context) (response domainUser.MyListContactsResponse, err error) {
whatsapp.MustLogin(service.WaCli)
contacts, err := service.WaCli.Store.Contacts.GetAllContacts()
if err != nil {
return
}
for jid, contact := range contacts {
response.Data = append(response.Data, domainUser.MyListContactsResponseData{
JID: jid,
Name: contact.FullName,
})
}
return response, nil
}
func (service userService) ChangeAvatar(ctx context.Context, request domainUser.ChangeAvatarRequest) (err error) {
whatsapp.MustLogin(service.WaCli)

2
src/views/components/AccountAvatar.js

@ -65,7 +65,7 @@ export default {
}
},
template: `
<div class="green card" @click="openModal" style="cursor: pointer;">
<div class="olive card" @click="openModal" style="cursor: pointer;">
<div class="content">
<a class="ui olive right ribbon label">Account</a>
<div class="header">Avatar</div>

2
src/views/components/AccountChangeAvatar.js

@ -63,7 +63,7 @@ export default {
}
},
template: `
<div class="blue card" @click="openModal()" style="cursor:pointer;">
<div class="olive card" @click="openModal()" style="cursor:pointer;">
<div class="content">
<a class="ui olive right ribbon label">Account</a>
<div class="header">Change Avatar</div>

79
src/views/components/AccountContact.js

@ -0,0 +1,79 @@
export default {
name: 'AccountContact',
data() {
return {
contacts: []
}
},
methods: {
async openModal() {
try {
this.dtClear()
await this.submitApi();
$('#modalContactList').modal('show');
this.dtRebuild()
showSuccessInfo("Contacts fetched")
} catch (err) {
showErrorInfo(err)
}
},
dtClear() {
$('#account_contacts_table').DataTable().destroy();
},
dtRebuild() {
$('#account_contacts_table').DataTable({
"pageLength": 10,
"reloadData": true,
}).draw();
},
async submitApi() {
try {
let response = await window.http.get(`/user/my/contacts`)
this.contacts = response.data.results.data;
} catch (error) {
if (error.response) {
throw new Error(error.response.data.message);
}
throw new Error(error.message);
}
},
getPhoneNumber(jid) {
return jid.split('@')[0];
}
},
template: `
<div class="olive card" @click="openModal" style="cursor: pointer">
<div class="content">
<a class="ui olive right ribbon label">Contacts</a>
<div class="header">My Contacts</div>
<div class="description">
Display all your contacts
</div>
</div>
</div>
<!-- Modal Contact List -->
<div class="ui large modal" id="modalContactList">
<i class="close icon"></i>
<div class="header">
My Contacts
</div>
<div class="content">
<table class="ui celled table" id="account_contacts_table">
<thead>
<tr>
<th>Phone Number</th>
<th>Name</th>
</tr>
</thead>
<tbody v-if="contacts != null">
<tr v-for="contact in contacts">
<td>{{ getPhoneNumber(contact.jid) }}</td>
<td>{{ contact.name }}</td>
</tr>
</tbody>
</table>
</div>
</div>
`
}

2
src/views/components/AccountPrivacy.js

@ -28,7 +28,7 @@ export default {
},
},
template: `
<div class="green card" @click="openModal" style="cursor: pointer">
<div class="olive card" @click="openModal" style="cursor: pointer">
<div class="content">
<a class="ui olive right ribbon label">Account</a>
<div class="header">My Privacy Setting</div>

2
src/views/components/AccountUserInfo.js

@ -72,7 +72,7 @@ export default {
}
},
template: `
<div class="green card" @click="openModal" style="cursor: pointer;">
<div class="olive card" @click="openModal" style="cursor: pointer;">
<div class="content">
<a class="ui olive right ribbon label">Account</a>
<div class="header">User Info</div>

4
src/views/index.html

@ -157,6 +157,7 @@
<account-change-avatar></account-change-avatar>
<account-user-info></account-user-info>
<account-privacy></account-privacy>
<account-contact></account-contact>
</div>
</div>
@ -218,6 +219,7 @@
import AccountUserInfo from "./components/AccountUserInfo.js";
import AccountPrivacy from "./components/AccountPrivacy.js";
import NewsletterList from "./components/NewsletterList.js";
import AccountContact from "./components/AccountContact.js";
const showErrorInfo = (message) => {
$('body').toast({
@ -256,7 +258,7 @@
MessageDelete, MessageUpdate, MessageReact, MessageRevoke,
GroupList, GroupCreate, GroupJoinWithLink, GroupAddParticipants,
NewsletterList,
AccountAvatar, AccountUserInfo, AccountPrivacy, AccountChangeAvatar
AccountAvatar, AccountUserInfo, AccountPrivacy, AccountChangeAvatar, AccountContact
},
delimiters: ['[[', ']]'],
data() {

Loading…
Cancel
Save