From af5e55b9283b2b26195f501ee6f1f0227c4c430d Mon Sep 17 00:00:00 2001 From: mattwr18 Date: Fri, 14 Jun 2024 08:50:27 +0200 Subject: [PATCH 1/2] Extend updateAccountSettings options - add --unrestricted-unidentified-sender option --- src/api/api.go | 7 ++++--- src/client/client.go | 12 +++++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/api/api.go b/src/api/api.go index 24625e2..56c5e0a 100644 --- a/src/api/api.go +++ b/src/api/api.go @@ -182,8 +182,9 @@ type RateLimitChallengeRequest struct { } type UpdateAccountSettingsRequest struct { - DiscoverableByNumber *bool `json:"discoverable_by_number"` - ShareNumber *bool `json:"share_number"` + DiscoverableByNumber *bool `json:"discoverable_by_number"` + ShareNumber *bool `json:"share_number"` + UnrestrictedUnidentifiedSender *bool `json:"unrestricted_unidentified_sender"` } type SetUsernameRequest struct { @@ -1846,7 +1847,7 @@ func (a *Api) UpdateAccountSettings(c *gin.Context) { return } - err = a.signalClient.UpdateAccountSettings(number, req.DiscoverableByNumber, req.ShareNumber) + err = a.signalClient.UpdateAccountSettings(number, req.DiscoverableByNumber, req.ShareNumber, req.UnrestrictedUnidentifiedSender) if err != nil { c.JSON(400, Error{Msg: err.Error()}) return diff --git a/src/client/client.go b/src/client/client.go index 03b121c..f46e82a 100644 --- a/src/client/client.go +++ b/src/client/client.go @@ -2017,15 +2017,17 @@ func (s *SignalClient) RemoveUsername(number string) error { } } -func (s *SignalClient) UpdateAccountSettings(number string, discoverableByNumber *bool, shareNumber *bool) error { +func (s *SignalClient) UpdateAccountSettings(number string, discoverableByNumber *bool, shareNumber *bool, unrestrictedUnidentifiedSender *bool) error { if s.signalCliMode == JsonRpc { type Request struct { - ShareNumber *bool `json:"number-sharing"` - DiscoverableByNumber *bool `json:"discoverable-by-number"` + ShareNumber *bool `json:"number-sharing"` + DiscoverableByNumber *bool `json:"discoverable-by-number"` + UnrestrictedUnidentifiedSender *bool `json:"unrestricted-unidentified-sender"` } request := Request{} request.DiscoverableByNumber = discoverableByNumber request.ShareNumber = shareNumber + request.UnrestrictedUnidentifiedSender = unrestrictedUnidentifiedSender jsonRpc2Client, err := s.getJsonRpc2Client() if err != nil { @@ -2042,6 +2044,10 @@ func (s *SignalClient) UpdateAccountSettings(number string, discoverableByNumber if shareNumber != nil { cmd = append(cmd, []string{"--number-sharing", strconv.FormatBool(*shareNumber)}...) } + + if unrestrictedUnidentifiedSender != nil { + cmd = append(cmd, []string{"--unrestricted-unidentified-sender", strconv.FormatBool(*unrestrictedUnidentifiedSender)}...) + } _, err := s.cliClient.Execute(true, cmd, "") return err } From 25f2dc03a70b7904e2eb9c1e4c6c553b6a7a48e1 Mon Sep 17 00:00:00 2001 From: mattwr18 Date: Fri, 14 Jun 2024 08:51:36 +0200 Subject: [PATCH 2/2] Update docs with swag v1.6.7 --- src/docs/docs.go | 3 +++ src/docs/swagger.json | 3 +++ src/docs/swagger.yaml | 60 ++++++++++++++++++++++++++++++++----------- 3 files changed, 51 insertions(+), 15 deletions(-) diff --git a/src/docs/docs.go b/src/docs/docs.go index 46e19ea..dcca335 100644 --- a/src/docs/docs.go +++ b/src/docs/docs.go @@ -2321,6 +2321,9 @@ var doc = `{ }, "share_number": { "type": "boolean" + }, + "unrestricted_unidentified_sender": { + "type": "boolean" } } }, diff --git a/src/docs/swagger.json b/src/docs/swagger.json index d3e57db..aa41600 100644 --- a/src/docs/swagger.json +++ b/src/docs/swagger.json @@ -2305,6 +2305,9 @@ }, "share_number": { "type": "boolean" + }, + "unrestricted_unidentified_sender": { + "type": "boolean" } } }, diff --git a/src/docs/swagger.yaml b/src/docs/swagger.yaml index ea8a702..c0a909b 100644 --- a/src/docs/swagger.yaml +++ b/src/docs/swagger.yaml @@ -145,7 +145,9 @@ definitions: api.SendMessageV1: properties: base64_attachment: - example: ''''' OR ''data:;base64,'' OR ''data:;filename=;base64,''' + example: ''''' OR ''data:;base64,'' OR ''data:;filename=;base64,''' type: string is_group: type: boolean @@ -240,6 +242,8 @@ definitions: type: boolean share_number: type: boolean + unrestricted_unidentified_sender: + type: boolean type: object api.UpdateContactRequest: properties: @@ -395,7 +399,11 @@ paths: post: consumes: - application/json - description: 'When running into rate limits, sometimes the limit can be lifted, by solving a CAPTCHA. To get the captcha token, go to https://signalcaptchas.org/challenge/generate.html For the staging environment, use: https://signalcaptchas.org/staging/registration/generate.html. The "challenge_token" is the token from the failed send attempt. The "captcha" is the captcha result, starting with signalcaptcha://' + description: 'When running into rate limits, sometimes the limit can be lifted, + by solving a CAPTCHA. To get the captcha token, go to https://signalcaptchas.org/challenge/generate.html + For the staging environment, use: https://signalcaptchas.org/staging/registration/generate.html. + The "challenge_token" is the token from the failed send attempt. The "captcha" + is the captcha result, starting with signalcaptcha://' parameters: - description: Registered Phone Number in: path @@ -472,7 +480,10 @@ paths: post: consumes: - application/json - description: Allows to set the username that should be used for this account. This can either be just the nickname (e.g. test) or the complete username with discriminator (e.g. test.123). Returns the new username with discriminator and the username link. + description: Allows to set the username that should be used for this account. + This can either be just the nickname (e.g. test) or the complete username + with discriminator (e.g. test.123). Returns the new username with discriminator + and the username link. parameters: - description: Registered Phone Number in: path @@ -688,14 +699,17 @@ paths: description: Bad Request schema: $ref: '#/definitions/api.Error' - summary: Updates the info associated to a number on the contact list. If the contact doesn’t exist yet, it will be added. + summary: Updates the info associated to a number on the contact list. If the + contact doesn’t exist yet, it will be added. tags: - Contacts /v1/contacts/{number}/sync: post: consumes: - application/json - description: Send a synchronization message with the local contacts list to all linked devices. This command should only be used if this is the primary device. + description: Send a synchronization message with the local contacts list to + all linked devices. This command should only be used if this is the primary + device. parameters: - description: Registered Phone Number in: path @@ -710,14 +724,16 @@ paths: description: Bad Request schema: $ref: '#/definitions/api.Error' - summary: Send a synchronization message with the local contacts list to all linked devices. + summary: Send a synchronization message with the local contacts list to all + linked devices. tags: - Contacts /v1/devices/{number}: post: consumes: - application/json - description: Links another device to this device. Only works, if this is the master device. + description: Links another device to this device. Only works, if this is the + master device. parameters: - description: Registered Phone Number in: path @@ -1140,7 +1156,8 @@ paths: - Identities /v1/identities/{number}/trust/{numberToTrust}: put: - description: Trust an identity. When 'trust_all_known_keys' is set to' true', all known keys of this user are trusted. **This is only recommended for testing.** + description: Trust an identity. When 'trust_all_known_keys' is set to' true', + all known keys of this user are trusted. **This is only recommended for testing.** parameters: - description: Input Data in: body @@ -1305,7 +1322,9 @@ paths: get: consumes: - application/json - description: Receives Signal Messages from the Signal Network. If you are running the docker container in normal/native mode, this is a GET endpoint. In json-rpc mode this is a websocket endpoint. + description: Receives Signal Messages from the Signal Network. If you are running + the docker container in normal/native mode, this is a GET endpoint. In json-rpc + mode this is a websocket endpoint. parameters: - description: Registered Phone Number in: path @@ -1316,7 +1335,8 @@ paths: in: query name: timeout type: string - - description: Specify whether the attachments of the received message should be ignored + - description: Specify whether the attachments of the received message should + be ignored in: query name: ignore_attachments type: string @@ -1324,7 +1344,8 @@ paths: in: query name: ignore_stories type: string - - description: 'Specify the maximum number of messages to receive (default: unlimited)' + - description: 'Specify the maximum number of messages to receive (default: + unlimited)' in: query name: max_messages type: string @@ -1414,7 +1435,8 @@ paths: get: consumes: - application/json - description: Check if one or more phone numbers are registered with the Signal Service. + description: Check if one or more phone numbers are registered with the Signal + Service. parameters: - description: Registered Phone Number in: path @@ -1502,7 +1524,11 @@ paths: post: consumes: - application/json - description: 'In order to add a sticker pack, browse to https://signalstickers.org/ and select the sticker pack you want to add. Then, press the "Add to Signal" button. If you look at the address bar in your browser you should see an URL in this format: https://signal.art/addstickers/#pack_id=XXX&pack_key=YYY, where XXX is the pack_id and YYY is the pack_key.' + description: 'In order to add a sticker pack, browse to https://signalstickers.org/ + and select the sticker pack you want to add. Then, press the "Add to Signal" + button. If you look at the address bar in your browser you should see an URL + in this format: https://signal.art/addstickers/#pack_id=XXX&pack_key=YYY, + where XXX is the pack_id and YYY is the pack_key.' parameters: - description: Registered Phone Number in: path @@ -1591,7 +1617,9 @@ paths: post: consumes: - application/json - description: Disables push support for this device. **WARNING:** If *delete_account* is set to *true*, the account will be deleted from the Signal Server. This cannot be undone without loss. + description: Disables push support for this device. **WARNING:** If *delete_account* + is set to *true*, the account will be deleted from the Signal Server. This + cannot be undone without loss. parameters: - description: Registered Phone Number in: path @@ -1618,7 +1646,9 @@ paths: post: consumes: - application/json - description: 'Send a signal message. Set the text_mode to ''styled'' in case you want to add formatting to your text message. Styling Options: *italic text*, **bold text**, ~strikethrough text~.' + description: 'Send a signal message. Set the text_mode to ''styled'' in case + you want to add formatting to your text message. Styling Options: *italic + text*, **bold text**, ~strikethrough text~.' parameters: - description: Input Data in: body