Skip to content

Commit

Permalink
fix: don't try to send unencrypted message, always do secure join
Browse files Browse the repository at this point in the history
  • Loading branch information
adbenitez committed Sep 19, 2024
1 parent 57fa44d commit 24b9ddc
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"io"
"net/http"
"path/filepath"
"strings"
"time"

"github.com/deltachat-bot/deltabot-cli-go/botcli"
Expand Down Expand Up @@ -99,7 +98,7 @@ func updateOfflineBotsStatusLoop(rpc *deltachat.Rpc) {
continue
}
logger.Debug("checking bot status")
if err := pingBot(rpc, accId, contactId, bot.Url); err != nil {
if _, err := rpc.SecureJoin(accId, bot.Url); err != nil {
logger.Error(err)
}
}
Expand Down Expand Up @@ -157,26 +156,13 @@ func updateStatusLoop(rpc *deltachat.Rpc) {
}
}
logger.Debug("checking bot status")
if err := pingBot(rpc, accId, contactId, bot.Url); err != nil {
if _, err := rpc.SecureJoin(accId, bot.Url); err != nil {
logger.Error(err)
}
}
}
}

func pingBot(rpc *deltachat.Rpc, accId deltachat.AccountId, contactId deltachat.ContactId, botUrl string) error {
if strings.HasPrefix(strings.ToLower(botUrl), "openpgp4fpr:") {
_, err := rpc.SecureJoin(accId, botUrl)
return err
}
chatId, err := rpc.CreateChatByContactId(accId, contactId)
if err != nil {
return err
}
_, err = rpc.MiscSendTextMessage(accId, chatId, "/help")
return err
}

func updateBotsLoop() {
url := "https://github.com/deltachat-bot/public-bots/raw/main/frontend/data.json"
logger := cli.Logger.With("origin", "metadata-loop")
Expand Down

0 comments on commit 24b9ddc

Please sign in to comment.