mirror of
https://github.com/aljazceru/signal-cli-rest-api.git
synced 2025-12-21 08:34:22 +01:00
fixed bug in jsonrpc2-helper script
* only look for registered numbers in the signal-cli-config/data folder and do NOT traverse the whole signal-cli-config folder (as there might be other files starting with '+...'
This commit is contained in:
@@ -33,6 +33,7 @@ numprocs=1
|
||||
|
||||
func main() {
|
||||
signalCliConfigDir := flag.String("signal-cli-config-dir", "/home/.local/share/signal-cli/", "Path to signal-cli config directory")
|
||||
signalCliConfigDataDir := *signalCliConfigDir + "data"
|
||||
|
||||
jsonRpc2ClientConfig := utils.NewJsonRpc2ClientConfig()
|
||||
|
||||
@@ -40,9 +41,16 @@ func main() {
|
||||
fifoBasePathName := "/tmp/sigsocket"
|
||||
var ctr int64 = 0
|
||||
|
||||
err := filepath.Walk(*signalCliConfigDir, func(path string, info os.FileInfo, err error) error {
|
||||
filename := filepath.Base(path)
|
||||
if strings.HasPrefix(filename, "+") && info.Mode().IsRegular() {
|
||||
items, err := ioutil.ReadDir(signalCliConfigDataDir)
|
||||
if err != nil {
|
||||
log.Fatal("Couldn't read contents of ", signalCliConfigDataDir)
|
||||
}
|
||||
for _, item := range items {
|
||||
if item.IsDir() {
|
||||
continue
|
||||
}
|
||||
filename := filepath.Base(item.Name())
|
||||
if strings.HasPrefix(filename, "+") {
|
||||
if utils.IsPhoneNumber(filename) {
|
||||
number := filename
|
||||
fifoPathname := fifoBasePathName + strconv.FormatInt(ctr, 10)
|
||||
@@ -83,8 +91,7 @@ func main() {
|
||||
log.Error("Skipping ", filename, " as it is not a valid phone number!")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// write jsonrpc.yml config file
|
||||
err = jsonRpc2ClientConfig.Persist(*signalCliConfigDir + "jsonrpc2.yml")
|
||||
|
||||
Reference in New Issue
Block a user