check if post is already in channel
All checks were successful
/ build (push) Successful in 59s

This commit is contained in:
Astra 2025-09-23 17:51:12 +01:00
parent acbdd41680
commit c4d4e91548

13
main.go
View file

@ -88,11 +88,11 @@ func main() {
log.Fatal("Unable to send posts from other accounts")
}
tgpost, tgposterr := h.bsky.Bluesky.GetTelegramData(s[2])
if *delete {
r, e := h.bsky.Bluesky.GetTelegramData(s[2])
if e == "" {
log.Printf("Found post %s in channel %d, deleting", s[2], r.ChannelID)
m := tgbotapi.NewDeleteMessages(r.ChannelID, r.MessageID)
if tgposterr == "" {
log.Printf("Found post %s in channel %d, deleting", s[2], tgpost.ChannelID)
m := tgbotapi.NewDeleteMessages(tgpost.ChannelID, tgpost.MessageID)
h.tg.Send(m)
h.bsky.Bluesky.DeleteRecord([]string{s[2], s[1], "blue.zio.bsky2tg.post"})
} else {
@ -101,6 +101,11 @@ func main() {
return
}
if tgpost.ChannelID != 0 {
log.Printf("Post %s already sent to channel %d, exiting", s[2], tgpost.ChannelID)
return
}
postJSON := bskyClient.Bluesky.FetchPost(handle, s[2])
p, _ := json.Marshal(postJSON.Record)
h.ProcessPost(&models.Event{