This commit is contained in:
parent
c9cc325ef7
commit
2675ce1ea0
1 changed files with 14 additions and 4 deletions
18
main.go
18
main.go
|
|
@ -219,7 +219,7 @@ func (h *handler) ProcessPost(event *models.Event) error {
|
|||
handle, _ := h.bsky.GetHandleFromDID(strings.Split(ps.Embed.Record.Record.URI, "/")[2])
|
||||
captionText = fmt.Sprintf(
|
||||
quotePostFormat,
|
||||
facets,
|
||||
escapeHTML(facets),
|
||||
strings.Split(ps.Embed.Record.Record.URI, "/")[2],
|
||||
strings.Split(ps.Embed.Record.Record.URI, "/")[4],
|
||||
handle,
|
||||
|
|
@ -230,7 +230,7 @@ func (h *handler) ProcessPost(event *models.Event) error {
|
|||
handle, _ := h.bsky.GetHandleFromDID(strings.Split(ps.Embed.Record.URI, "/")[2])
|
||||
captionText = fmt.Sprintf(
|
||||
quotePostFormat,
|
||||
facets,
|
||||
escapeHTML(facets),
|
||||
strings.Split(ps.Embed.Record.URI, "/")[2],
|
||||
strings.Split(ps.Embed.Record.URI, "/")[4],
|
||||
handle,
|
||||
|
|
@ -246,7 +246,7 @@ func (h *handler) ProcessPost(event *models.Event) error {
|
|||
ownHandle = h.bsky.Bluesky.Cfg.Handle
|
||||
}
|
||||
if facets != "" {
|
||||
captionText = fmt.Sprintf(postFormat, facets, h.bsky.Bluesky.Cfg.DID, event.Commit.RKey, ownHandle)
|
||||
captionText = fmt.Sprintf(postFormat, escapeHTML(facets), h.bsky.Bluesky.Cfg.DID, event.Commit.RKey, ownHandle)
|
||||
} else {
|
||||
captionText = fmt.Sprintf("<a href=\"https://bsky.app/profile/%s/post/%s\">🦋 @%s</a>", h.bsky.Bluesky.Cfg.DID, event.Commit.RKey, ownHandle)
|
||||
}
|
||||
|
|
@ -328,7 +328,7 @@ func (h *handler) ProcessPost(event *models.Event) error {
|
|||
} else {
|
||||
m := tgbotapi.MessageConfig{}
|
||||
if captionText == "" {
|
||||
m = tgbotapi.NewMessage(cid, fmt.Sprintf(postFormat, facets, h.bsky.Bluesky.Cfg.DID, event.Commit.RKey, h.bsky.Bluesky.Cfg.Handle))
|
||||
m = tgbotapi.NewMessage(cid, fmt.Sprintf(postFormat, escapeHTML(facets), h.bsky.Bluesky.Cfg.DID, event.Commit.RKey, h.bsky.Bluesky.Cfg.Handle))
|
||||
} else {
|
||||
m = tgbotapi.NewMessage(cid, captionText)
|
||||
}
|
||||
|
|
@ -360,6 +360,16 @@ func (h *handler) ProcessPost(event *models.Event) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func escapeHTML(text string) string {
|
||||
// Escape HTML special characters so they display literally
|
||||
replacements := strings.NewReplacer(
|
||||
"&", "&",
|
||||
"<", "<",
|
||||
">", ">",
|
||||
)
|
||||
return replacements.Replace(text)
|
||||
}
|
||||
|
||||
func buildBlobURL(server string, did string, cid string) string {
|
||||
return server + "/xrpc/com.atproto.sync.getBlob?did=" + url.QueryEscape(did) + "&cid=" + cid
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue