mirror of
https://github.com/bbernhard/signal-cli-rest-api.git
synced 2026-05-16 13:10:20 +00:00
Merge pull request #828 from Gara-Dorta/additional-api-checks
refactor: add missing checks on required fields
This commit is contained in:
commit
2838e1f879
@ -873,6 +873,11 @@ func (a *Api) AddMembersToGroup(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if len(req.Members) == 0 {
|
||||
c.JSON(400, Error{Msg: "Couldn't process request - group members missing"})
|
||||
return
|
||||
}
|
||||
|
||||
err = a.signalClient.AddMembersToGroup(number, groupId, req.Members)
|
||||
if err != nil {
|
||||
switch err.(type) {
|
||||
@ -1279,6 +1284,16 @@ func (a *Api) UnpinMessageInGroup(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if req.TargetAuthor == "" {
|
||||
c.JSON(400, Error{Msg: "Couldn't process request - target author missing"})
|
||||
return
|
||||
}
|
||||
|
||||
if req.Timestamp == 0 {
|
||||
c.JSON(400, Error{Msg: "Couldn't process request - timestamp missing"})
|
||||
return
|
||||
}
|
||||
|
||||
err = a.signalClient.UnpinMessageInGroup(number, groupId, req.TargetAuthor, req.Timestamp)
|
||||
if err != nil {
|
||||
c.JSON(400, Error{Msg: err.Error()})
|
||||
@ -2385,6 +2400,16 @@ func (a *Api) SubmitRateLimitChallenge(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if req.ChallengeToken == "" {
|
||||
c.JSON(400, Error{Msg: "Couldn't process request - challenge token missing"})
|
||||
return
|
||||
}
|
||||
|
||||
if req.Captcha == "" {
|
||||
c.JSON(400, Error{Msg: "Couldn't process request - captcha missing"})
|
||||
return
|
||||
}
|
||||
|
||||
err = a.signalClient.SubmitRateLimitChallenge(number, req.ChallengeToken, req.Captcha)
|
||||
if err != nil {
|
||||
c.JSON(400, Error{Msg: err.Error()})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user