mirror of
https://git.robbyzambito.me/bluesky-nats-proxy/
synced 2025-12-20 08:14:50 +00:00
Perplexity is struggling
https://www.perplexity.ai/search/write-a-go-program-that-will-p-YxH8FdyoRESJ0lyPEvthqw
This commit is contained in:
18
main.go
18
main.go
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user