Skip to content

Commit fed11f9

Browse files
committed
cmd/bsky-webhook: show timestamp in embed footer
1 parent a11ba29 commit fed11f9

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

cmd/bsky-webhook/main.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"os"
1717
"os/signal"
1818
"path"
19+
"strconv"
1920
"strings"
2021
"syscall"
2122
"time"
@@ -262,7 +263,7 @@ func readJetstreamMessage(ctx context.Context, jetstreamMessageEncoded []byte, b
262263
imageURL = fmt.Sprintf("https://cdn.bsky.app/img/feed_fullsize/plain/%s/%s", bskyMessage.Did, bskyMessage.Commit.Record.Embed.Images[0].Image.Ref.Link)
263264
}
264265

265-
err = sendToSlack(ctx, jetstreamMessageStr, bskyMessage, imageURL, *profile)
266+
err = sendToSlack(ctx, jetstreamMessageStr, bskyMessage, imageURL, *profile, postTime)
266267
if err != nil {
267268
slog.Error("slack error", "err", err)
268269
}
@@ -286,14 +287,16 @@ func getBskyProfile(ctx context.Context, bskyMessage BskyMessage, bsky *bluesky.
286287
return profile, nil
287288
}
288289

289-
func sendToSlack(ctx context.Context, jetstreamMessageStr string, bskyMessage BskyMessage, imageURL string, profile bluesky.Profile) error {
290+
func sendToSlack(ctx context.Context, jetstreamMessageStr string, bskyMessage BskyMessage, imageURL string, profile bluesky.Profile, postTime time.Time) error {
290291
attachments := []SlackAttachment{
291292
{
292293
AuthorName: fmt.Sprintf("%s (@%s)", profile.Name, profile.Handle),
293294
AuthorIcon: profile.AvatarURL,
294295
AuthorLink: fmt.Sprintf("https://bsky.app/profile/%s", profile.Handle),
295296
Text: fmt.Sprintf("%s\n<%s|View post on Bluesky ↗>", bskyMessage.Commit.Record.Text, bskyMessage.toURL(&profile.Handle)),
296297
ImageUrl: imageURL,
298+
Footer: "Posted",
299+
Ts: strconv.FormatInt(postTime.Unix(), 10),
297300
},
298301
}
299302

cmd/bsky-webhook/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ type SlackAttachment struct {
5757
Text string `json:"text"`
5858
ImageUrl string `json:"image_url"`
5959
Footer string `json:"footer"`
60+
Ts string `json:"ts"`
6061
}
6162

6263
type SlackBody struct {

0 commit comments

Comments
 (0)