Skip to content

Commit d652d41

Browse files
committed
Return upon failure
1 parent 1237c52 commit d652d41

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

src/api/api.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ func (a *Api) RegisterNumber(c *gin.Context) {
236236
number, err := url.PathUnescape(c.Param("number"))
237237
if err != nil {
238238
c.JSON(400, Error{Msg: "Couldn't process request - malformed number"})
239+
return
239240
}
240241

241242
var req RegisterNumberRequest
@@ -281,6 +282,7 @@ func (a *Api) UnregisterNumber(c *gin.Context) {
281282
number, err := url.PathUnescape(c.Param("number"))
282283
if err != nil {
283284
c.JSON(400, Error{Msg: "Couldn't process request - malformed number"})
285+
return
284286
}
285287

286288
deleteAccount := false
@@ -322,6 +324,7 @@ func (a *Api) VerifyRegisteredNumber(c *gin.Context) {
322324
number, err := url.PathUnescape(c.Param("number"))
323325
if err != nil {
324326
c.JSON(400, Error{Msg: "Couldn't process request - malformed number"})
327+
return
325328
}
326329
token := c.Param("token")
327330

@@ -579,6 +582,7 @@ func (a *Api) Receive(c *gin.Context) {
579582
number, err := url.PathUnescape(c.Param("number"))
580583
if err != nil {
581584
c.JSON(400, Error{Msg: "Couldn't process request - malformed number"})
585+
return
582586
}
583587

584588
if a.signalClient.GetSignalCliMode() == client.JsonRpc {
@@ -649,6 +653,7 @@ func (a *Api) CreateGroup(c *gin.Context) {
649653
number, err := url.PathUnescape(c.Param("number"))
650654
if err != nil {
651655
c.JSON(400, Error{Msg: "Couldn't process request - malformed number"})
656+
return
652657
}
653658

654659
var req CreateGroupRequest
@@ -710,6 +715,7 @@ func (a *Api) AddMembersToGroup(c *gin.Context) {
710715
number, err := url.PathUnescape(c.Param("number"))
711716
if err != nil {
712717
c.JSON(400, Error{Msg: "Couldn't process request - malformed number"})
718+
return
713719
}
714720
if number == "" {
715721
c.JSON(400, Error{Msg: "Couldn't process request - number missing"})
@@ -758,6 +764,7 @@ func (a *Api) RemoveMembersFromGroup(c *gin.Context) {
758764
number, err := url.PathUnescape(c.Param("number"))
759765
if err != nil {
760766
c.JSON(400, Error{Msg: "Couldn't process request - malformed number"})
767+
return
761768
}
762769
if number == "" {
763770
c.JSON(400, Error{Msg: "Couldn't process request - number missing"})
@@ -806,6 +813,7 @@ func (a *Api) AddAdminsToGroup(c *gin.Context) {
806813
number, err := url.PathUnescape(c.Param("number"))
807814
if err != nil {
808815
c.JSON(400, Error{Msg: "Couldn't process request - malformed number"})
816+
return
809817
}
810818
if number == "" {
811819
c.JSON(400, Error{Msg: "Couldn't process request - number missing"})
@@ -854,6 +862,7 @@ func (a *Api) RemoveAdminsFromGroup(c *gin.Context) {
854862
number, err := url.PathUnescape(c.Param("number"))
855863
if err != nil {
856864
c.JSON(400, Error{Msg: "Couldn't process request - malformed number"})
865+
return
857866
}
858867
if number == "" {
859868
c.JSON(400, Error{Msg: "Couldn't process request - number missing"})
@@ -900,6 +909,7 @@ func (a *Api) GetGroups(c *gin.Context) {
900909
number, err := url.PathUnescape(c.Param("number"))
901910
if err != nil {
902911
c.JSON(400, Error{Msg: "Couldn't process request - malformed number"})
912+
return
903913
}
904914

905915
groups, err := a.signalClient.GetGroups(number)
@@ -925,6 +935,7 @@ func (a *Api) GetGroup(c *gin.Context) {
925935
number, err := url.PathUnescape(c.Param("number"))
926936
if err != nil {
927937
c.JSON(400, Error{Msg: "Couldn't process request - malformed number"})
938+
return
928939
}
929940
groupId := c.Param("groupid")
930941

@@ -956,6 +967,7 @@ func (a *Api) DeleteGroup(c *gin.Context) {
956967
number, err := url.PathUnescape(c.Param("number"))
957968
if err != nil {
958969
c.JSON(400, Error{Msg: "Couldn't process request - malformed number"})
970+
return
959971
}
960972

961973
if base64EncodedGroupId == "" {
@@ -1136,6 +1148,7 @@ func (a *Api) UpdateProfile(c *gin.Context) {
11361148
number, err := url.PathUnescape(c.Param("number"))
11371149
if err != nil {
11381150
c.JSON(400, Error{Msg: "Couldn't process request - malformed number"})
1151+
return
11391152
}
11401153

11411154
if number == "" {
@@ -1186,6 +1199,7 @@ func (a *Api) ListIdentities(c *gin.Context) {
11861199
number, err := url.PathUnescape(c.Param("number"))
11871200
if err != nil {
11881201
c.JSON(400, Error{Msg: "Couldn't process request - malformed number"})
1202+
return
11891203
}
11901204

11911205
if number == "" {
@@ -1215,6 +1229,7 @@ func (a *Api) TrustIdentity(c *gin.Context) {
12151229
number, err := url.PathUnescape(c.Param("number"))
12161230
if err != nil {
12171231
c.JSON(400, Error{Msg: "Couldn't process request - malformed number"})
1232+
return
12181233
}
12191234

12201235
if number == "" {
@@ -1329,6 +1344,7 @@ func (a *Api) BlockGroup(c *gin.Context) {
13291344
number, err := url.PathUnescape(c.Param("number"))
13301345
if err != nil {
13311346
c.JSON(400, Error{Msg: "Couldn't process request - malformed number"})
1347+
return
13321348
}
13331349
if number == "" {
13341350
c.JSON(400, Error{Msg: "Couldn't process request - number missing"})
@@ -1365,6 +1381,7 @@ func (a *Api) JoinGroup(c *gin.Context) {
13651381
number, err := url.PathUnescape(c.Param("number"))
13661382
if err != nil {
13671383
c.JSON(400, Error{Msg: "Couldn't process request - malformed number"})
1384+
return
13681385
}
13691386
if number == "" {
13701387
c.JSON(400, Error{Msg: "Couldn't process request - number missing"})
@@ -1401,6 +1418,7 @@ func (a *Api) QuitGroup(c *gin.Context) {
14011418
number, err := url.PathUnescape(c.Param("number"))
14021419
if err != nil {
14031420
c.JSON(400, Error{Msg: "Couldn't process request - malformed number"})
1421+
return
14041422
}
14051423
if number == "" {
14061424
c.JSON(400, Error{Msg: "Couldn't process request - number missing"})
@@ -1437,6 +1455,7 @@ func (a *Api) UpdateGroup(c *gin.Context) {
14371455
number, err := url.PathUnescape(c.Param("number"))
14381456
if err != nil {
14391457
c.JSON(400, Error{Msg: "Couldn't process request - malformed number"})
1458+
return
14401459
}
14411460
if number == "" {
14421461
c.JSON(400, Error{Msg: "Couldn't process request - number missing"})
@@ -1487,6 +1506,7 @@ func (a *Api) SendReaction(c *gin.Context) {
14871506
number, err := url.PathUnescape(c.Param("number"))
14881507
if err != nil {
14891508
c.JSON(400, Error{Msg: "Couldn't process request - malformed number"})
1509+
return
14901510
}
14911511

14921512
if req.Recipient == "" {
@@ -1538,6 +1558,7 @@ func (a *Api) RemoveReaction(c *gin.Context) {
15381558
number, err := url.PathUnescape(c.Param("number"))
15391559
if err != nil {
15401560
c.JSON(400, Error{Msg: "Couldn't process request - malformed number"})
1561+
return
15411562
}
15421563

15431564
if req.Recipient == "" {
@@ -1584,6 +1605,7 @@ func (a *Api) SendReceipt(c *gin.Context) {
15841605
number, err := url.PathUnescape(c.Param("number"))
15851606
if err != nil {
15861607
c.JSON(400, Error{Msg: "Couldn't process request - malformed number"})
1608+
return
15871609
}
15881610

15891611
if number == "" {
@@ -1637,6 +1659,7 @@ func (a *Api) SendStartTyping(c *gin.Context) {
16371659
number, err := url.PathUnescape(c.Param("number"))
16381660
if err != nil {
16391661
c.JSON(400, Error{Msg: "Couldn't process request - malformed number"})
1662+
return
16401663
}
16411664
if number == "" {
16421665
c.JSON(400, Error{Msg: "Couldn't process request - number missing"})
@@ -1673,6 +1696,7 @@ func (a *Api) SendStopTyping(c *gin.Context) {
16731696
number, err := url.PathUnescape(c.Param("number"))
16741697
if err != nil {
16751698
c.JSON(400, Error{Msg: "Couldn't process request - malformed number"})
1699+
return
16761700
}
16771701
if number == "" {
16781702
c.JSON(400, Error{Msg: "Couldn't process request - number missing"})
@@ -1707,6 +1731,7 @@ func (a *Api) SearchForNumbers(c *gin.Context) {
17071731
number, err := url.PathUnescape(c.Param("number"))
17081732
if err != nil {
17091733
c.JSON(400, Error{Msg: "Couldn't process request - malformed number"})
1734+
return
17101735
}
17111736

17121737
searchResults, err := a.signalClient.SearchForNumbers(number, query["numbers"])
@@ -1738,6 +1763,7 @@ func (a *Api) UpdateContact(c *gin.Context) {
17381763
number, err := url.PathUnescape(c.Param("number"))
17391764
if err != nil {
17401765
c.JSON(400, Error{Msg: "Couldn't process request - malformed number"})
1766+
return
17411767
}
17421768
if number == "" {
17431769
c.JSON(400, Error{Msg: "Couldn't process request - number missing"})
@@ -1778,6 +1804,7 @@ func (a *Api) AddDevice(c *gin.Context) {
17781804
number, err := url.PathUnescape(c.Param("number"))
17791805
if err != nil {
17801806
c.JSON(400, Error{Msg: "Couldn't process request - malformed number"})
1807+
return
17811808
}
17821809
if number == "" {
17831810
c.JSON(400, Error{Msg: "Couldn't process request - number missing"})
@@ -1813,6 +1840,7 @@ func (a *Api) SetTrustMode(c *gin.Context) {
18131840
number, err := url.PathUnescape(c.Param("number"))
18141841
if err != nil {
18151842
c.JSON(400, Error{Msg: "Couldn't process request - malformed number"})
1843+
return
18161844
}
18171845
if number == "" {
18181846
c.JSON(400, Error{Msg: "Couldn't process request - number missing"})
@@ -1855,6 +1883,7 @@ func (a *Api) GetTrustMode(c *gin.Context) {
18551883
number, err := url.PathUnescape(c.Param("number"))
18561884
if err != nil {
18571885
c.JSON(400, Error{Msg: "Couldn't process request - malformed number"})
1886+
return
18581887
}
18591888
if number == "" {
18601889
c.JSON(400, Error{Msg: "Couldn't process request - number missing"})
@@ -1885,6 +1914,7 @@ func (a *Api) SendContacts(c *gin.Context) {
18851914
number, err := url.PathUnescape(c.Param("number"))
18861915
if err != nil {
18871916
c.JSON(400, Error{Msg: "Couldn't process request - malformed number"})
1917+
return
18881918
}
18891919
if number == "" {
18901920
c.JSON(400, Error{Msg: "Couldn't process request - number missing"})
@@ -1913,6 +1943,7 @@ func (a *Api) SubmitRateLimitChallenge(c *gin.Context) {
19131943
number, err := url.PathUnescape(c.Param("number"))
19141944
if err != nil {
19151945
c.JSON(400, Error{Msg: "Couldn't process request - malformed number"})
1946+
return
19161947
}
19171948
if number == "" {
19181949
c.JSON(400, Error{Msg: "Couldn't process request - number missing"})
@@ -1948,6 +1979,7 @@ func (a *Api) UpdateAccountSettings(c *gin.Context) {
19481979
number, err := url.PathUnescape(c.Param("number"))
19491980
if err != nil {
19501981
c.JSON(400, Error{Msg: "Couldn't process request - malformed number"})
1982+
return
19511983
}
19521984
if number == "" {
19531985
c.JSON(400, Error{Msg: "Couldn't process request - number missing"})
@@ -1985,6 +2017,7 @@ func (a *Api) SetUsername(c *gin.Context) {
19852017
number, err := url.PathUnescape(c.Param("number"))
19862018
if err != nil {
19872019
c.JSON(400, Error{Msg: "Couldn't process request - malformed number"})
2020+
return
19882021
}
19892022
if number == "" {
19902023
c.JSON(400, Error{Msg: "Couldn't process request - number missing"})
@@ -2019,6 +2052,7 @@ func (a *Api) RemoveUsername(c *gin.Context) {
20192052
number, err := url.PathUnescape(c.Param("number"))
20202053
if err != nil {
20212054
c.JSON(400, Error{Msg: "Couldn't process request - malformed number"})
2055+
return
20222056
}
20232057
if number == "" {
20242058
c.JSON(400, Error{Msg: "Couldn't process request - number missing"})
@@ -2047,6 +2081,7 @@ func (a *Api) ListInstalledStickerPacks(c *gin.Context) {
20472081
number, err := url.PathUnescape(c.Param("number"))
20482082
if err != nil {
20492083
c.JSON(400, Error{Msg: "Couldn't process request - malformed number"})
2084+
return
20502085
}
20512086
if number == "" {
20522087
c.JSON(400, Error{Msg: "Couldn't process request - number missing"})
@@ -2076,6 +2111,7 @@ func (a *Api) AddStickerPack(c *gin.Context) {
20762111
number, err := url.PathUnescape(c.Param("number"))
20772112
if err != nil {
20782113
c.JSON(400, Error{Msg: "Couldn't process request - malformed number"})
2114+
return
20792115
}
20802116
if number == "" {
20812117
c.JSON(400, Error{Msg: "Couldn't process request - number missing"})
@@ -2109,6 +2145,7 @@ func (a *Api) ListContacts(c *gin.Context) {
21092145
number, err := url.PathUnescape(c.Param("number"))
21102146
if err != nil {
21112147
c.JSON(400, Error{Msg: "Couldn't process request - malformed number"})
2148+
return
21122149
}
21132150

21142151
if number == "" {

0 commit comments

Comments
 (0)