switched implementation to multi-account mode

* instead of starting signal-cli in json-rpc mode with the '-u',
  we start signal-cli without the '-u' parameter (also known as
  multi-account mode). This makes it possible to register a number in
  json-rpc mode.
This commit is contained in:
Bernhard B
2023-10-30 14:49:11 +01:00
parent 0cab12c49d
commit a06a9f873b
5 changed files with 131 additions and 158 deletions

View File

@@ -59,7 +59,7 @@ func (r *JsonRpc2Client) Dial(address string) error {
return nil
}
func (r *JsonRpc2Client) getRaw(command string, args interface{}) (string, error) {
func (r *JsonRpc2Client) getRaw(command string, account *string, args interface{}) (string, error) {
type Request struct {
JsonRpc string `json:"jsonrpc"`
Method string `json:"method"`
@@ -99,6 +99,13 @@ func (r *JsonRpc2Client) getRaw(command string, args interface{}) (string, error
}
}
if account != nil {
fullCommandBytes, err = sjson.SetBytes(fullCommandBytes, "params.account", account)
if err != nil {
return "", err
}
}
log.Debug("full command: ", string(fullCommandBytes))
_, err = r.conn.Write([]byte(string(fullCommandBytes) + "\n"))