Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend UpdateAccountSettings options #548

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
12 changes: 9 additions & 3 deletions src/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}
Expand Down
3 changes: 3 additions & 0 deletions src/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2321,6 +2321,9 @@ var doc = `{
},
"share_number": {
"type": "boolean"
},
"unrestricted_unidentified_sender": {
"type": "boolean"
}
}
},
Expand Down
3 changes: 3 additions & 0 deletions src/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -2305,6 +2305,9 @@
},
"share_number": {
"type": "boolean"
},
"unrestricted_unidentified_sender": {
"type": "boolean"
}
}
},
Expand Down
60 changes: 45 additions & 15 deletions src/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ definitions:
api.SendMessageV1:
properties:
base64_attachment:
example: '''<BASE64 ENCODED DATA>'' OR ''data:<MIME-TYPE>;base64,<BASE64 ENCODED DATA>'' OR ''data:<MIME-TYPE>;filename=<FILENAME>;base64,<BASE64 ENCODED DATA>'''
example: '''<BASE64 ENCODED DATA>'' OR ''data:<MIME-TYPE>;base64,<BASE64 ENCODED
DATA>'' OR ''data:<MIME-TYPE>;filename=<FILENAME>;base64,<BASE64 ENCODED
DATA>'''
type: string
is_group:
type: boolean
Expand Down Expand Up @@ -240,6 +242,8 @@ definitions:
type: boolean
share_number:
type: boolean
unrestricted_unidentified_sender:
type: boolean
type: object
api.UpdateContactRequest:
properties:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -1316,15 +1335,17 @@ 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
- description: Specify whether stories should be ignored when receiving messages
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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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~.'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bbernhard I"m not sure why most of the changes in these docs were made. I saw your comment #209 (comment) that you use swag to generate the docs, so I installed the swag version v1.6.7 that is pinned in the Dockerfile and ran swag init and these are the automated changes. I also double-checked and I am on go version 1.22.3 so it's not clear to me why these linting changes were made.

parameters:
- description: Input Data
in: body
Expand Down