Skip to content

Commit

Permalink
feat: add newsletter (#204)
Browse files Browse the repository at this point in the history
* feat(newsletter): add newsletter service, endpoints, and UI components

Add Newsletter service to support functionality for unfollowing newsletters
Add Newsletter REST controller and routing
Implement newsletter-related endpoints and methods in the User Service
Create UnfollowRequest for the INewsletterService interface
Add MyListNewsletterResponse to user's data fields
Add newsletter validation
Refactor JS components to support newsletter type and simplify recipient forms by moving logic to FormRecipient component
Refactor window global constants to support newsletters
Modify server to initialize and use the newsletter services
Add UI component for listing newsletters
Refactor existing components to use FormRecipient for recipient data input

* chore: update documentation

feat(openapi.yaml): add newsletter support with new paths and schemas
docs(readme.md): update API endpoints including newsletter and images
fix(openapi.yaml): correct duplicated summary text for user my newsletters

* feat: update package name

* feat: Update src/views/components/NewsletterList.js

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* feat: Update src/views/components/NewsletterList.js

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* feat: Update src/views/components/NewsletterList.js

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
  • Loading branch information
aldinokemal and coderabbitai[bot] authored Oct 11, 2024
1 parent c54d414 commit c419406
Show file tree
Hide file tree
Showing 29 changed files with 766 additions and 240 deletions.
303 changes: 301 additions & 2 deletions docs/openapi.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
openapi: 3.0.0
info:
title: WhatsApp API MultiDevice
version: 4.2.0
version: 4.3.0
description: This API is used for sending whatsapp via API
servers:
- url: http://localhost:3000
Expand All @@ -16,6 +16,8 @@ tags:
description: Message manipulation (revoke/react/update).
- name: group
description: Group setting
- name: newsletter
description: newsletter setting
paths:
/app/login:
get:
Expand Down Expand Up @@ -212,6 +214,31 @@ paths:
- user
summary: User My List Groups
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/UserGroupResponse'
'500':
description: Internal Server Error
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorInternalServer'
/user/my/newsletters:
get:
operationId: userMyNewsletter
tags:
- user
summary: User My List Groups
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/NewsletterResponse'
'500':
description: Internal Server Error
content:
Expand Down Expand Up @@ -1042,6 +1069,40 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/ErrorInternalServer'
/newsletter/unfollow:
post:
operationId: unfollowNewsletter
tags:
- newsletter
summary: Unfollow newsletter
requestBody:
content:
application/json:
schema:
type: object
properties:
newsletter_id:
type: string
example: '120363024512399999@newsletter'
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/GenericResponse'
'400':
description: Bad Request
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorBadRequest'
'500':
description: Internal Server Error
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorInternalServer'

components:
schemas:
Expand Down Expand Up @@ -1341,4 +1402,242 @@ components:
results:
type: object
example: null
description: 'additional data'
description: 'additional data'
NewsletterResponse:
type: object
properties:
code:
type: string
example: "SUCCESS"
message:
type: string
example: "Success get list newsletter"
results:
type: object
properties:
data:
type: array
items:
$ref: '#/components/schemas/Newsletter'
Newsletter:
type: object
properties:
id:
type: string
example: "120363144038483540@newsletter"
state:
type: object
properties:
type:
type: string
example: "active"
thread_metadata:
type: object
properties:
creation_time:
type: string
example: "1688746895"
invite:
type: string
example: "0029Va4K0PZ5a245NkngBA2M"
name:
type: object
properties:
text:
type: string
example: "WhatsApp"
id:
type: string
example: "1688746895480511"
update_time:
type: string
example: "1688746895480511"
description:
type: object
properties:
text:
type: string
example: "WhatsApp’s official channel. Follow for our latest feature launches, updates, exclusive drops and more."
id:
type: string
example: "1689653839450668"
update_time:
type: string
example: "1689653839450668"
subscribers_count:
type: string
example: "0"
verification:
type: string
example: "verified"
picture:
type: object
properties:
url:
type: string
example: ""
id:
type: string
example: "1707950960975554"
type:
type: string
example: "IMAGE"
direct_path:
type: string
example: "/v/t61.24694-24/416962407_970228831134395_8869146381947923973_n.jpg?ccb=11-4&oh=01_Q5AaIIvOIeu3l0HCZWILrmr-dGR_vXFqnhUeytw0-ojPc4hL&oe=670D95B1&_nc_sid=5e03e0&_nc_cat=110"
preview:
type: object
properties:
url:
type: string
example: ""
id:
type: string
example: "1707950960975554"
type:
type: string
example: "PREVIEW"
direct_path:
type: string
example: "/v/t61.24694-24/416962407_970228831134395_8869146381947923973_n.jpg?stp=dst-jpg_s192x192&ccb=11-4&oh=01_Q5AaIHO-DQklqm3q3awF7xwji_WAn9DkgZASQA0B2Ct0qbSa&oe=670D95B1&_nc_sid=5e03e0&_nc_cat=110"
settings:
type: object
properties:
reaction_codes:
type: object
properties:
value:
type: string
example: "ALL"
viewer_metadata:
type: object
properties:
mute:
type: string
example: "off"
role:
type: string
example: "subscriber"
GroupResponse:
type: object
properties:
code:
type: string
example: "SUCCESS"
message:
type: string
example: "Success get list groups"
results:
type: object
properties:
data:
type: array
items:
$ref: '#/components/schemas/Group'
Group:
type: object
properties:
JID:
type: string
example: "[email protected]"
OwnerJID:
type: string
example: "[email protected]"
Name:
type: string
example: "Example Group"
NameSetAt:
type: string
format: date-time
example: "2024-10-11T21:27:29+07:00"
NameSetBy:
type: string
example: "[email protected]"
Topic:
type: string
example: ""
TopicID:
type: string
example: ""
TopicSetAt:
type: string
format: date-time
example: "0001-01-01T00:00:00Z"
TopicSetBy:
type: string
example: ""
TopicDeleted:
type: boolean
example: false
IsLocked:
type: boolean
example: false
IsAnnounce:
type: boolean
example: false
AnnounceVersionID:
type: string
example: "1728656849439709"
IsEphemeral:
type: boolean
example: false
DisappearingTimer:
type: integer
example: 0
IsIncognito:
type: boolean
example: false
IsParent:
type: boolean
example: false
DefaultMembershipApprovalMode:
type: string
example: ""
LinkedParentJID:
type: string
example: ""
IsDefaultSubGroup:
type: boolean
example: false
IsJoinApprovalRequired:
type: boolean
example: false
GroupCreated:
type: string
format: date-time
example: "2024-10-11T21:27:29+07:00"
ParticipantVersionID:
type: string
example: "1728656849439790"
Participants:
type: array
items:
$ref: '#/components/schemas/Participant'
MemberAddMode:
type: string
example: "admin_add"

Participant:
type: object
properties:
JID:
type: string
example: "[email protected]"
LID:
type: string
example: "20036609675500@lid"
IsAdmin:
type: boolean
example: true
IsSuperAdmin:
type: boolean
example: true
DisplayName:
type: string
example: ""
Error:
type: integer
example: 0
AddRequest:
type: string
example: null
7 changes: 5 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ You can fork or edit this source code !
|| Devices | GET | /app/devices |
|| User Info | GET | /user/info |
|| User Avatar | GET | /user/avatar |
|| User My Group List | GET | /user/my/groups |
|| User My Groups | GET | /user/my/groups |
|| User My Newsletter | GET | /user/my/newsletters |
|| User My Privacy Setting | GET | /user/my/privacy |
|| Send Message | POST | /send/message |
|| Send Image | POST | /send/image |
Expand All @@ -135,6 +136,7 @@ You can fork or edit this source code !
|| Remove Participant in Group | POST | /group/participants/remove |
|| Promote Participant in Group | POST | /group/participants/promote |
|| Demote Participant in Group | POST | /group/participants/demote |
|| Unfollow Newsletter | POST | /group/newsletter/unfollow |

```
✅ = Available
Expand All @@ -145,7 +147,7 @@ You can fork or edit this source code !

| Description | Image |
|--------------------|------------------------------------------------------------------------------------------|
| Homepage | ![Homepage](https://i.ibb.co.com/L0B1LVb/homepage-v4-16.png) |
| Homepage | ![Homepage](https://i.ibb.co.com/Sy0dHZp/homepage-v4-20.png) |
| Login | ![Login](https://i.ibb.co.com/jkcB15R/login.png?v=1) |
| Login With Code | ![Login With Code](https://i.ibb.co.com/rdJGvGw/paircode.png) |
| Send Message | ![Send Message](https://i.ibb.co.com/rc3NXMX/send-message.png?v1) |
Expand All @@ -167,6 +169,7 @@ You can fork or edit this source code !
| Auto Reply | ![Auto Reply](https://i.ibb.co.com/D4rTytX/IMG-20220517-162500.jpg) |
| Basic Auth Prompt | ![Basic Auth Prompt](https://i.ibb.co.com/PDjQ92W/Screenshot-2022-11-06-at-14-06-29.png) |
| Manage Participant | ![Manage Participant](https://i.ibb.co.com/ynrN7cr/manage-participant.png) |
| My Newsletter | ![List Newsletter](https://i.ibb.co.com/WDg50jJ/image.png) |

### Mac OS NOTE

Expand Down
2 changes: 2 additions & 0 deletions src/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,15 @@ func runRest(_ *cobra.Command, _ []string) {
userService := services.NewUserService(cli)
messageService := services.NewMessageService(cli)
groupService := services.NewGroupService(cli)
newsletterService := services.NewNewsletterService(cli)

// Rest
rest.InitRestApp(app, appService)
rest.InitRestSend(app, sendService)
rest.InitRestUser(app, userService)
rest.InitRestMessage(app, messageService)
rest.InitRestGroup(app, groupService)
rest.InitRestNewsletter(app, newsletterService)

app.Get("/", func(c *fiber.Ctx) error {
return c.Render("views/index", fiber.Map{
Expand Down
11 changes: 11 additions & 0 deletions src/domains/newsletter/newsletter.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package newsletter

import "context"

type INewsletterService interface {
Unfollow(ctx context.Context, request UnfollowRequest) (err error)
}

type UnfollowRequest struct {
NewsletterID string `json:"newsletter_id" form:"newsletter_id"`
}
Loading

0 comments on commit c419406

Please sign in to comment.