diff --git a/cmd/signaldctl/cmd/account/register/register-account.go b/cmd/signaldctl/cmd/account/register/register-account.go index f97504d..b2c92c0 100644 --- a/cmd/signaldctl/cmd/account/register/register-account.go +++ b/cmd/signaldctl/cmd/account/register/register-account.go @@ -26,7 +26,8 @@ import ( ) var ( - voice bool + voice bool + captcha string RegisterAccountCmd = &cobra.Command{ Use: "register [phone number]", @@ -44,6 +45,7 @@ var ( ID: requestID, Username: args[0], Voice: voice, + Captcha: captcha, }) if err != nil { log.Fatal("error sending request to signald: ", err) @@ -51,9 +53,12 @@ var ( c := make(chan v0.LegacyResponse) go common.Signald.Listen(c) response := signald.GetLegacyResponse(c, requestID) - if response.Type == "verification_required" { + switch response.Type { + case "verification_required": log.Println("verification code requested. submit with: signaldctl account verify", args[0], "") - } else { + case "captcha_required": + log.Println("captcha required. Please provide a captcha token with the --captcha argument (see https://gitlab.com/signald/signald/-/wikis/Captchas)") + default: log.Fatalf("unexpected response from signald when requesting verification code: %+v", response) } }, @@ -62,4 +67,5 @@ var ( func init() { RegisterAccountCmd.Flags().BoolVarP(&voice, "voice", "V", false, "request verification code be sent via an automated voice call (code is sent via SMS by default)") + RegisterAccountCmd.Flags().StringVarP(&captcha, "captcha", "c", "", "a captcha token may be required to register, see https://gitlab.com/signald/signald/-/wikis/Captchas for how to get one") } diff --git a/signald/client-protocol/v0/signaldrequest.go b/signald/client-protocol/v0/signaldrequest.go index d087387..a695cd3 100644 --- a/signald/client-protocol/v0/signaldrequest.go +++ b/signald/client-protocol/v0/signaldrequest.go @@ -21,7 +21,7 @@ type LegacyRequest struct { ID string `json:"id,omitempty"` Username string `json:"username,omitempty"` MessageBody string `json:"messageBody,omitempty"` - RecipientAddress JsonAddress `json:"recipientAddress,omitempty"` + RecipientAddress *JsonAddress `json:"recipientAddress,omitempty"` RecipientGroupID string `json:"recipientGroupId,omitempty"` Voice bool `json:"voice,omitempty"` Code string `json:"code,omitempty"` @@ -32,6 +32,7 @@ type LegacyRequest struct { GroupName string `json:"groupName,omitempty"` Members []string `json:"members,omitempty"` Avatar string `json:"avatar,omitempty"` + Captcha string `json:"captcha,omitempty"` } type JsonAddress struct {