add possibility to specify captcha in register endpoint

see #19
This commit is contained in:
Bernhard B
2021-01-08 22:46:58 +01:00
parent a63a80d464
commit 787bb2b50b

View File

@@ -31,6 +31,7 @@ type GroupEntry struct {
type RegisterNumberRequest struct {
UseVoice bool `json:"use_voice"`
Captcha string `json:"captcha"`
}
type VerifyNumberSettings struct {
@@ -328,6 +329,7 @@ func (a *Api) RegisterNumber(c *gin.Context) {
}
} else {
req.UseVoice = false
req.Captcha = ""
}
if number == "" {
@@ -341,6 +343,10 @@ func (a *Api) RegisterNumber(c *gin.Context) {
command = append(command, "--voice")
}
if req.Captcha != "" {
command = append(command, []string{"--captcha", req.Captcha}...)
}
_, err := runSignalCli(true, command, "")
if err != nil {
c.JSON(400, gin.H{"error": err.Error()})