From a3f4f4f54c0596f1c5bf043aa7c6b10dcfabaee2 Mon Sep 17 00:00:00 2001 From: Astra Date: Thu, 6 Nov 2025 16:17:07 +0000 Subject: [PATCH] resolve own DID on posts --- main.go | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/main.go b/main.go index 3fcd1a2..a85af72 100644 --- a/main.go +++ b/main.go @@ -45,7 +45,7 @@ type handler struct { var ( post = flag.String("post", "", "URL to a BlueSky post") delete = flag.Bool("delete", false, "true/false to delete post") - oldPosts = flag.Float64("oldposttime", 24, "Ignore posts if createdAt more than this many hours ago") + oldPosts = flag.Float64("oldposttime", 1, "Ignore posts if createdAt more than this many hours ago") ) func main() { @@ -208,6 +208,10 @@ func (h *handler) ProcessPost(event *models.Event) error { var captionText string if ps.IsQuotePost() { + ownHandle, handleErr := h.bsky.GetHandleFromDID(h.bsky.Bluesky.Cfg.DID) + if handleErr != nil { + ownHandle = h.bsky.Bluesky.Cfg.Handle + } if ps.Embed.Record.Type == "app.bsky.embed.record" { handle, _ := h.bsky.GetHandleFromDID(strings.Split(ps.Embed.Record.Record.URI, "/")[2]) captionText = fmt.Sprintf( @@ -218,7 +222,7 @@ func (h *handler) ProcessPost(event *models.Event) error { handle, event.Did, event.Commit.RKey, - h.bsky.Bluesky.Cfg.Handle) + ownHandle) } else { handle, _ := h.bsky.GetHandleFromDID(strings.Split(ps.Embed.Record.URI, "/")[2]) captionText = fmt.Sprintf( @@ -229,15 +233,19 @@ func (h *handler) ProcessPost(event *models.Event) error { handle, event.Did, event.Commit.RKey, - h.bsky.Bluesky.Cfg.Handle) + ownHandle) } } if captionText == "" { + ownHandle, handleErr := h.bsky.GetHandleFromDID(h.bsky.Bluesky.Cfg.DID) + if handleErr != nil { + ownHandle = h.bsky.Bluesky.Cfg.Handle + } if ps.ProcessFacets(h.bsky.Bluesky.FetchAliases()) != "" { - captionText = fmt.Sprintf(postFormat, ps.ProcessFacets(h.bsky.Bluesky.FetchAliases()), h.bsky.Bluesky.Cfg.DID, event.Commit.RKey, h.bsky.Bluesky.Cfg.Handle) + captionText = fmt.Sprintf(postFormat, ps.ProcessFacets(h.bsky.Bluesky.FetchAliases()), h.bsky.Bluesky.Cfg.DID, event.Commit.RKey, ownHandle) } else { - captionText = fmt.Sprintf("🦋 @%s", h.bsky.Bluesky.Cfg.DID, event.Commit.RKey, h.bsky.Bluesky.Cfg.Handle) + captionText = fmt.Sprintf("🦋 @%s", h.bsky.Bluesky.Cfg.DID, event.Commit.RKey, ownHandle) } }