Skip to content

Commit

Permalink
This one is also Completed
Browse files Browse the repository at this point in the history
  • Loading branch information
keyurboss committed Apr 12, 2024
1 parent 250c2d1 commit b0e245c
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 1,512 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ __debug*

server.config.json
tmp
jwelly.whatsapp.config
jwelly.whatsapp.config

**/.DS_Store
33 changes: 29 additions & 4 deletions apis/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ func SendMediaFile(c *fiber.Ctx) error {
return err
}

if len(body.To) == 0 || len(body.To[0]) < 7 {
return &interfaces.RequestError{
StatusCode: http.StatusBadRequest,
Code: interfaces.ERROR_INVALID_INPUT,
Message: "Number Not Found",
Name: "ERROR_INVALID_INPUT",
}
}
connection, ok := whatsapp.ConnectionMap[number]
if !ok || connection == nil {
return &interfaces.RequestError{
Expand Down Expand Up @@ -97,11 +105,21 @@ func SendMediaFile(c *fiber.Ctx) error {
func SendMediaFileWithBase64(c *fiber.Ctx) error {
body := new(apiSendMediaMsgWithBase64)
c.BodyParser(body)
number, err := interfaces.ExtractNumberFromCtx(c)
if err != nil {

if err := utility.ValidateReqInput(body); err != nil {
return err
}
if err := utility.ValidateReqInput(body); err != nil {

if len(body.To) == 0 || len(body.To[0]) < 7 {
return &interfaces.RequestError{
StatusCode: http.StatusBadRequest,
Code: interfaces.ERROR_INVALID_INPUT,
Message: "Number Not Found",
Name: "ERROR_INVALID_INPUT",
}
}
number, err := interfaces.ExtractNumberFromCtx(c)
if err != nil {
return err
}

Expand Down Expand Up @@ -137,7 +155,14 @@ func SendMessage(c *fiber.Ctx) error {
if err := utility.ValidateReqInput(body); err != nil {
return err
}

if len(body.To) == 0 || len(body.To[0]) < 7 {
return &interfaces.RequestError{
StatusCode: http.StatusBadRequest,
Code: interfaces.ERROR_INVALID_INPUT,
Message: "Number Not Found",
Name: "ERROR_INVALID_INPUT",
}
}
number, err := interfaces.ExtractNumberFromCtx(c)
if err != nil {
return err
Expand Down
23 changes: 0 additions & 23 deletions swagger/index.html

This file was deleted.

Loading

0 comments on commit b0e245c

Please sign in to comment.