diff --git a/bsky/parse.go b/bsky/parse.go index a06f131..c600af9 100644 --- a/bsky/parse.go +++ b/bsky/parse.go @@ -18,50 +18,42 @@ type Post struct { Facets *[]Facets `json:"facets,omitempty"` CreatedAt time.Time `json:"createdAt"` } - type Ref struct { Link string `json:"$link,omitempty"` } - type Thumb struct { Type string `json:"$type,omitempty"` Ref *Ref `json:"ref,omitempty"` MimeType string `json:"mimeType,omitempty"` Size int `json:"size,omitempty"` } - type External struct { URI string `json:"uri,omitempty"` Thumb *Thumb `json:"thumb,omitempty"` Title string `json:"title,omitempty"` Description string `json:"description,omitempty"` } - type Video struct { Type string `json:"$type,omitempty"` Ref *Ref `json:"ref,omitempty"` MimeType string `json:"mimeType,omitempty"` Size int `json:"size,omitempty"` } - type Image struct { Type string `json:"$type,omitempty"` Ref *Ref `json:"ref,omitempty"` MimeType string `json:"mimeType,omitempty"` Size int `json:"size,omitempty"` } - type AspectRatio struct { Width int `json:"width,omitempty"` Height int `json:"height,omitempty"` } - type Images struct { Alt string `json:"alt,omitempty"` Image *Image `json:"image,omitempty"` AspectRatio *AspectRatio `json:"aspectRatio,omitempty"` } - type Media struct { Type string `json:"$type,omitempty"` External *External `json:"external,omitempty"` @@ -69,19 +61,16 @@ type Media struct { Images *[]Images `json:"images,omitempty"` AspectRatio *AspectRatio `json:"aspectRatio,omitempty"` } - type Record struct { Cid string `json:"cid,omitempty"` URI string `json:"uri,omitempty"` } - type PostRecord struct { Type string `json:"$type,omitempty"` Cid string `json:"cid,omitempty"` URI string `json:"uri,omitempty"` Record *Record `json:"record,omitempty"` } - type Embed struct { Type string `json:"$type,omitempty"` Media *Media `json:"media,omitempty"` @@ -90,59 +79,35 @@ type Embed struct { Record *PostRecord `json:"record,omitempty"` External *External `json:"external,omitempty"` } - type Values struct { Val string `json:"val,omitempty"` } - type Labels struct { Type string `json:"$type,omitempty"` Values *[]Values `json:"values,omitempty"` } - type Root struct { Cid string `json:"cid,omitempty"` URI string `json:"uri,omitempty"` } - -func (r *Root) GetDID() string { - return strings.Split(r.URI, "/")[2] -} - -func (r *Root) GetRKey() string { - return strings.Split(r.URI, "/")[4] -} - type Parent struct { Cid string `json:"cid,omitempty"` URI string `json:"uri,omitempty"` } - -func (p *Parent) GetDID() string { - return strings.Split(p.URI, "/")[2] -} - -func (p *Parent) GetRKey() string { - return strings.Split(p.URI, "/")[4] -} - type Reply struct { Root *Root `json:"root,omitempty"` Parent *Parent `json:"parent,omitempty"` } - type Index struct { ByteEnd int `json:"byteEnd,omitempty"` ByteStart int `json:"byteStart,omitempty"` } - type Features struct { Did string `json:"did,omitempty"` URI string `json:"uri,omitempty"` Tag string `json:"tag,omitempty"` Type string `json:"$type,omitempty"` } - type Facets struct { Type string `json:"$type"` Index *Index `json:"index,omitempty"` @@ -153,7 +118,6 @@ type ParsedEmbeds struct { Type string MimeType string Ref string - Cid string URI string Width int64 Height int64 diff --git a/main.go b/main.go index f7ada17..433fcd0 100644 --- a/main.go +++ b/main.go @@ -32,7 +32,7 @@ const ( serverAddr = "wss://jetstream2.us-west.bsky.network/subscribe" // serverAddr = "wss://stream.zio.blue/subscribe" postFormat = "%s\nā\nš¦ @%s" - quotePostFormat = "
%s\nā”ļø @%s\nā\nš¦ @%s" + quotePostFormat = "
%s\nā”ļø @%s\nā\nš¦ @%s" ) type handler struct { @@ -327,7 +327,7 @@ func (h *handler) ProcessPost(event *models.Event) error { } func buildBlobURL(server string, did string, cid string) string { - return server + "/xrpc/com.atproto.sync.getBlob?did=" + url.QueryEscape(did) + "&cid=" + cid + return server + "/xrpc/com.atproto.sync.getBlob?did=" + url.QueryEscape(did) + "&cid=" + url.QueryEscape(cid) } func getLink(event *models.Event) (string, string) {