mirror of
https://github.com/aljazceru/signal-cli-rest-api.git
synced 2025-12-20 16:14:29 +01:00
json-rpc mode: fixed bug in register endpoint + added verify endpoint
This commit is contained in:
@@ -526,7 +526,6 @@ func (s *SignalClient) About() About {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *SignalClient) RegisterNumber(number string, useVoice bool, captcha string) error {
|
func (s *SignalClient) RegisterNumber(number string, useVoice bool, captcha string) error {
|
||||||
var err error
|
|
||||||
if s.signalCliMode == JsonRpc {
|
if s.signalCliMode == JsonRpc {
|
||||||
type Request struct {
|
type Request struct {
|
||||||
UseVoice bool `json:"voice,omitempty"`
|
UseVoice bool `json:"voice,omitempty"`
|
||||||
@@ -548,6 +547,7 @@ func (s *SignalClient) RegisterNumber(number string, useVoice bool, captcha stri
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
_, err = jsonRpc2Client.getRaw("register", nil, request)
|
_, err = jsonRpc2Client.getRaw("register", nil, request)
|
||||||
|
return err
|
||||||
} else {
|
} else {
|
||||||
command := []string{"--config", s.signalCliConfig, "-a", number, "register"}
|
command := []string{"--config", s.signalCliConfig, "-a", number, "register"}
|
||||||
|
|
||||||
@@ -559,9 +559,9 @@ func (s *SignalClient) RegisterNumber(number string, useVoice bool, captcha stri
|
|||||||
command = append(command, []string{"--captcha", captcha}...)
|
command = append(command, []string{"--captcha", captcha}...)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = s.cliClient.Execute(true, command, "")
|
_, err := s.cliClient.Execute(true, command, "")
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SignalClient) UnregisterNumber(number string, deleteAccount bool, deleteLocalData bool) error {
|
func (s *SignalClient) UnregisterNumber(number string, deleteAccount bool, deleteLocalData bool) error {
|
||||||
@@ -591,17 +591,33 @@ func (s *SignalClient) UnregisterNumber(number string, deleteAccount bool, delet
|
|||||||
|
|
||||||
func (s *SignalClient) VerifyRegisteredNumber(number string, token string, pin string) error {
|
func (s *SignalClient) VerifyRegisteredNumber(number string, token string, pin string) error {
|
||||||
if s.signalCliMode == JsonRpc {
|
if s.signalCliMode == JsonRpc {
|
||||||
return errors.New(endpointNotSupportedInJsonRpcMode)
|
type Request struct {
|
||||||
}
|
VerificationCode string `json:"verificationCode,omitempty"`
|
||||||
|
Account string `json:"account,omitempty"`
|
||||||
|
Pin string `json:"pin,omitempty"`
|
||||||
|
}
|
||||||
|
request := Request{Account: number, VerificationCode: token}
|
||||||
|
|
||||||
cmd := []string{"--config", s.signalCliConfig, "-a", number, "verify", token}
|
if pin != "" {
|
||||||
if pin != "" {
|
request.Pin = pin
|
||||||
cmd = append(cmd, "--pin")
|
}
|
||||||
cmd = append(cmd, pin)
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err := s.cliClient.Execute(true, cmd, "")
|
jsonRpc2Client, err := s.getJsonRpc2Client()
|
||||||
return err
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_, err = jsonRpc2Client.getRaw("verify", nil, request)
|
||||||
|
return err
|
||||||
|
} else {
|
||||||
|
cmd := []string{"--config", s.signalCliConfig, "-a", number, "verify", token}
|
||||||
|
if pin != "" {
|
||||||
|
cmd = append(cmd, "--pin")
|
||||||
|
cmd = append(cmd, pin)
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err := s.cliClient.Execute(true, cmd, "")
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SignalClient) SendV1(number string, message string, recipients []string, base64Attachments []string, isGroup bool) (*SendResponse, error) {
|
func (s *SignalClient) SendV1(number string, message string, recipients []string, base64Attachments []string, isGroup bool) (*SendResponse, error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user