mirror of
https://github.com/bbernhard/signal-cli-rest-api.git
synced 2026-05-17 13:20:16 +00:00
Compare commits
2 Commits
10d7a8d4ce
...
e3ae4dabed
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e3ae4dabed | ||
|
|
5714161567 |
@ -156,3 +156,4 @@ There are a bunch of environmental variables that can be set inside the docker c
|
|||||||
|
|
||||||
* `JSON_RPC_IGNORE_ATTACHMENTS`: When set to `true`, attachments are not automatically downloaded in json-rpc mode (default: `false`)
|
* `JSON_RPC_IGNORE_ATTACHMENTS`: When set to `true`, attachments are not automatically downloaded in json-rpc mode (default: `false`)
|
||||||
* `JSON_RPC_IGNORE_STORIES`: When set to `true`, stories are not automatically downloaded in json-rpc mode (default: `false`)
|
* `JSON_RPC_IGNORE_STORIES`: When set to `true`, stories are not automatically downloaded in json-rpc mode (default: `false`)
|
||||||
|
* `JSON_RPC_TRUST_NEW_IDENTITIES`: Choose how to trust new identities in json-rpc mode. Supported values: `on-first-use`, `always`, `never`. (default: `on-first-use`)
|
||||||
|
|||||||
@ -2296,8 +2296,12 @@ func (s *SignalClient) ListDevices(number string) ([]ListDevicesResponse, error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *SignalClient) SetTrustMode(number string, trustMode utils.SignalCliTrustMode) error {
|
func (s *SignalClient) SetTrustMode(number string, trustMode utils.SignalCliTrustMode) error {
|
||||||
|
if s.signalCliMode == JsonRpc {
|
||||||
|
return errors.New("Not supported in json-rpc mode, use the environment variable JSON_RPC_TRUST_NEW_IDENTITIES instead!")
|
||||||
|
} else {
|
||||||
s.signalCliApiConfig.SetTrustModeForNumber(number, trustMode)
|
s.signalCliApiConfig.SetTrustModeForNumber(number, trustMode)
|
||||||
return s.signalCliApiConfig.Persist()
|
return s.signalCliApiConfig.Persist()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SignalClient) GetTrustMode(number string) utils.SignalCliTrustMode {
|
func (s *SignalClient) GetTrustMode(number string) utils.SignalCliTrustMode {
|
||||||
|
|||||||
@ -2,18 +2,19 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/bbernhard/signal-cli-rest-api/utils"
|
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/bbernhard/signal-cli-rest-api/utils"
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
const supervisorctlConfigTemplate = `
|
const supervisorctlConfigTemplate = `
|
||||||
[program:%s]
|
[program:%s]
|
||||||
process_name=%s
|
process_name=%s
|
||||||
command=bash -c "nc -l -p %d <%s | signal-cli --output=json --config %s jsonRpc%s%s >%s"
|
command=bash -c "nc -l -p %d <%s | signal-cli --output=json --config %s%s jsonRpc%s%s >%s"
|
||||||
autostart=true
|
autostart=true
|
||||||
autorestart=true
|
autorestart=true
|
||||||
startretries=10
|
startretries=10
|
||||||
@ -77,17 +78,27 @@ func main() {
|
|||||||
log.Fatal("Couldn't create log folder ", supervisorctlLogFolder, ": ", err.Error())
|
log.Fatal("Couldn't create log folder ", supervisorctlLogFolder, ": ", err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
trustNewIdentities := ""
|
||||||
|
trustNewIdentitiesEnv := utils.GetEnv("JSON_RPC_TRUST_NEW_IDENTITIES", "")
|
||||||
|
if trustNewIdentitiesEnv == "on-first-use" {
|
||||||
|
trustNewIdentities = " --trust-new-identities on-first-use"
|
||||||
|
} else if trustNewIdentitiesEnv == "always" {
|
||||||
|
trustNewIdentities = " --trust-new-identities always"
|
||||||
|
} else if trustNewIdentitiesEnv == "never" {
|
||||||
|
trustNewIdentities = " --trust-new-identities never"
|
||||||
|
} else if trustNewIdentitiesEnv != "" {
|
||||||
|
log.Fatal("Invalid JSON_RPC_TRUST_NEW_IDENTITIES environment variable set!")
|
||||||
|
}
|
||||||
|
|
||||||
log.Info("Updated jsonrpc2.yml")
|
log.Info("Updated jsonrpc2.yml")
|
||||||
|
|
||||||
//write supervisorctl config
|
//write supervisorctl config
|
||||||
supervisorctlConfigFilename := "/etc/supervisor/conf.d/" + "signal-cli-json-rpc-1.conf"
|
supervisorctlConfigFilename := "/etc/supervisor/conf.d/" + "signal-cli-json-rpc-1.conf"
|
||||||
|
|
||||||
|
|
||||||
supervisorctlConfig := fmt.Sprintf(supervisorctlConfigTemplate, supervisorctlProgramName, supervisorctlProgramName,
|
supervisorctlConfig := fmt.Sprintf(supervisorctlConfigTemplate, supervisorctlProgramName, supervisorctlProgramName,
|
||||||
tcpPort, fifoPathname, signalCliConfigDir, signalCliIgnoreAttachments, signalCliIgnoreStories, fifoPathname,
|
tcpPort, fifoPathname, signalCliConfigDir, trustNewIdentities, signalCliIgnoreAttachments, signalCliIgnoreStories, fifoPathname,
|
||||||
supervisorctlProgramName, supervisorctlProgramName)
|
supervisorctlProgramName, supervisorctlProgramName)
|
||||||
|
|
||||||
|
|
||||||
err = ioutil.WriteFile(supervisorctlConfigFilename, []byte(supervisorctlConfig), 0644)
|
err = ioutil.WriteFile(supervisorctlConfigFilename, []byte(supervisorctlConfig), 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal("Couldn't write ", supervisorctlConfigFilename, ": ", err.Error())
|
log.Fatal("Couldn't write ", supervisorctlConfigFilename, ": ", err.Error())
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user