diff options
author | Robby Zambito <contact@robbyzambito.me> | 2024-11-17 18:46:14 -0500 |
---|---|---|
committer | Robby Zambito <contact@robbyzambito.me> | 2024-11-17 19:00:30 -0500 |
commit | 2ff5b759540d8437b52689436a2d64273754cb2f (patch) | |
tree | 4a7e6484db25d56fba691d4f7c1a2b365e82a97e | |
parent | aa421dab8cf0636dca7c38783058faa22240cb36 (diff) |
Perplexity is struggling
https://www.perplexity.ai/search/write-a-go-program-that-will-p-YxH8FdyoRESJ0lyPEvthqw
-rw-r--r-- | main.go | 18 |
1 files changed, 13 insertions, 5 deletions
@@ -2,7 +2,6 @@ package main import ( "encoding/json" - "fmt" "log" "os" "os/signal" @@ -22,6 +21,18 @@ type BlueskyPost struct { } `json:"record"` } +func createNATSSubject(userID, postType string, timestamp time.Time) string { + parts := []string{"bsky", "feed", "post"} + if userID != "" { + parts = append(parts, "user", userID) + } + if postType != "" { + parts = append(parts, "type", postType) + } + parts = append(parts, "time", timestamp.Format("20060102")) + return strings.Join(parts, ".") +} + func main() { // Connect to NATS nc, err := nats.Connect(nats.DefaultURL) @@ -62,10 +73,7 @@ func main() { } // Create a more detailed NATS subject - subject := fmt.Sprintf("bsky.feed.post.user.%s.type.%s.time.%s", - userID, - postType, - post.Record.CreatedAt.Format("20060102")) + subject := createNATSSubject(userID, postType, post.Record.CreatedAt) // Publish the JSON message to NATS with the detailed subject if err := nc.Publish(subject, message); err != nil { |