Compare commits
2 commits
aff13c04dd
...
5ff08f5acc
Author | SHA1 | Date | |
---|---|---|---|
5ff08f5acc | |||
dc7382f162 |
2 changed files with 38 additions and 2 deletions
|
@ -18,42 +18,50 @@ type Post struct {
|
||||||
Facets *[]Facets `json:"facets,omitempty"`
|
Facets *[]Facets `json:"facets,omitempty"`
|
||||||
CreatedAt time.Time `json:"createdAt"`
|
CreatedAt time.Time `json:"createdAt"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Ref struct {
|
type Ref struct {
|
||||||
Link string `json:"$link,omitempty"`
|
Link string `json:"$link,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Thumb struct {
|
type Thumb struct {
|
||||||
Type string `json:"$type,omitempty"`
|
Type string `json:"$type,omitempty"`
|
||||||
Ref *Ref `json:"ref,omitempty"`
|
Ref *Ref `json:"ref,omitempty"`
|
||||||
MimeType string `json:"mimeType,omitempty"`
|
MimeType string `json:"mimeType,omitempty"`
|
||||||
Size int `json:"size,omitempty"`
|
Size int `json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type External struct {
|
type External struct {
|
||||||
URI string `json:"uri,omitempty"`
|
URI string `json:"uri,omitempty"`
|
||||||
Thumb *Thumb `json:"thumb,omitempty"`
|
Thumb *Thumb `json:"thumb,omitempty"`
|
||||||
Title string `json:"title,omitempty"`
|
Title string `json:"title,omitempty"`
|
||||||
Description string `json:"description,omitempty"`
|
Description string `json:"description,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Video struct {
|
type Video struct {
|
||||||
Type string `json:"$type,omitempty"`
|
Type string `json:"$type,omitempty"`
|
||||||
Ref *Ref `json:"ref,omitempty"`
|
Ref *Ref `json:"ref,omitempty"`
|
||||||
MimeType string `json:"mimeType,omitempty"`
|
MimeType string `json:"mimeType,omitempty"`
|
||||||
Size int `json:"size,omitempty"`
|
Size int `json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Image struct {
|
type Image struct {
|
||||||
Type string `json:"$type,omitempty"`
|
Type string `json:"$type,omitempty"`
|
||||||
Ref *Ref `json:"ref,omitempty"`
|
Ref *Ref `json:"ref,omitempty"`
|
||||||
MimeType string `json:"mimeType,omitempty"`
|
MimeType string `json:"mimeType,omitempty"`
|
||||||
Size int `json:"size,omitempty"`
|
Size int `json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AspectRatio struct {
|
type AspectRatio struct {
|
||||||
Width int `json:"width,omitempty"`
|
Width int `json:"width,omitempty"`
|
||||||
Height int `json:"height,omitempty"`
|
Height int `json:"height,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Images struct {
|
type Images struct {
|
||||||
Alt string `json:"alt,omitempty"`
|
Alt string `json:"alt,omitempty"`
|
||||||
Image *Image `json:"image,omitempty"`
|
Image *Image `json:"image,omitempty"`
|
||||||
AspectRatio *AspectRatio `json:"aspectRatio,omitempty"`
|
AspectRatio *AspectRatio `json:"aspectRatio,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Media struct {
|
type Media struct {
|
||||||
Type string `json:"$type,omitempty"`
|
Type string `json:"$type,omitempty"`
|
||||||
External *External `json:"external,omitempty"`
|
External *External `json:"external,omitempty"`
|
||||||
|
@ -61,16 +69,19 @@ type Media struct {
|
||||||
Images *[]Images `json:"images,omitempty"`
|
Images *[]Images `json:"images,omitempty"`
|
||||||
AspectRatio *AspectRatio `json:"aspectRatio,omitempty"`
|
AspectRatio *AspectRatio `json:"aspectRatio,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Record struct {
|
type Record struct {
|
||||||
Cid string `json:"cid,omitempty"`
|
Cid string `json:"cid,omitempty"`
|
||||||
URI string `json:"uri,omitempty"`
|
URI string `json:"uri,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type PostRecord struct {
|
type PostRecord struct {
|
||||||
Type string `json:"$type,omitempty"`
|
Type string `json:"$type,omitempty"`
|
||||||
Cid string `json:"cid,omitempty"`
|
Cid string `json:"cid,omitempty"`
|
||||||
URI string `json:"uri,omitempty"`
|
URI string `json:"uri,omitempty"`
|
||||||
Record *Record `json:"record,omitempty"`
|
Record *Record `json:"record,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Embed struct {
|
type Embed struct {
|
||||||
Type string `json:"$type,omitempty"`
|
Type string `json:"$type,omitempty"`
|
||||||
Media *Media `json:"media,omitempty"`
|
Media *Media `json:"media,omitempty"`
|
||||||
|
@ -79,35 +90,59 @@ type Embed struct {
|
||||||
Record *PostRecord `json:"record,omitempty"`
|
Record *PostRecord `json:"record,omitempty"`
|
||||||
External *External `json:"external,omitempty"`
|
External *External `json:"external,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Values struct {
|
type Values struct {
|
||||||
Val string `json:"val,omitempty"`
|
Val string `json:"val,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Labels struct {
|
type Labels struct {
|
||||||
Type string `json:"$type,omitempty"`
|
Type string `json:"$type,omitempty"`
|
||||||
Values *[]Values `json:"values,omitempty"`
|
Values *[]Values `json:"values,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Root struct {
|
type Root struct {
|
||||||
Cid string `json:"cid,omitempty"`
|
Cid string `json:"cid,omitempty"`
|
||||||
URI string `json:"uri,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 {
|
type Parent struct {
|
||||||
Cid string `json:"cid,omitempty"`
|
Cid string `json:"cid,omitempty"`
|
||||||
URI string `json:"uri,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 {
|
type Reply struct {
|
||||||
Root *Root `json:"root,omitempty"`
|
Root *Root `json:"root,omitempty"`
|
||||||
Parent *Parent `json:"parent,omitempty"`
|
Parent *Parent `json:"parent,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Index struct {
|
type Index struct {
|
||||||
ByteEnd int `json:"byteEnd,omitempty"`
|
ByteEnd int `json:"byteEnd,omitempty"`
|
||||||
ByteStart int `json:"byteStart,omitempty"`
|
ByteStart int `json:"byteStart,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Features struct {
|
type Features struct {
|
||||||
Did string `json:"did,omitempty"`
|
Did string `json:"did,omitempty"`
|
||||||
URI string `json:"uri,omitempty"`
|
URI string `json:"uri,omitempty"`
|
||||||
Tag string `json:"tag,omitempty"`
|
Tag string `json:"tag,omitempty"`
|
||||||
Type string `json:"$type,omitempty"`
|
Type string `json:"$type,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Facets struct {
|
type Facets struct {
|
||||||
Type string `json:"$type"`
|
Type string `json:"$type"`
|
||||||
Index *Index `json:"index,omitempty"`
|
Index *Index `json:"index,omitempty"`
|
||||||
|
@ -118,6 +153,7 @@ type ParsedEmbeds struct {
|
||||||
Type string
|
Type string
|
||||||
MimeType string
|
MimeType string
|
||||||
Ref string
|
Ref string
|
||||||
|
Cid string
|
||||||
URI string
|
URI string
|
||||||
Width int64
|
Width int64
|
||||||
Height int64
|
Height int64
|
||||||
|
|
4
main.go
4
main.go
|
@ -32,7 +32,7 @@ const (
|
||||||
serverAddr = "wss://jetstream2.us-west.bsky.network/subscribe"
|
serverAddr = "wss://jetstream2.us-west.bsky.network/subscribe"
|
||||||
// serverAddr = "wss://stream.zio.blue/subscribe"
|
// serverAddr = "wss://stream.zio.blue/subscribe"
|
||||||
postFormat = "%s\n—\n<a href=\"https://bsky.app/profile/%s/post/%s\">🦋 @%s</a>"
|
postFormat = "%s\n—\n<a href=\"https://bsky.app/profile/%s/post/%s\">🦋 @%s</a>"
|
||||||
quotePostFormat = "<blockquote>%s</blockquote>\n<a href=\"https://bsky.app/profile/%s/post/%s\">➡️ @%s</a>\n—\n<a href=\"https://bsky.app/profile/%s/post/%s\">🦋 @%s</a>"
|
quotePostFormat = "<blockquote>%s</blockquote>\n<a href=\"https://deer.social/profile/%s/post/%s\">➡️ @%s</a>\n—\n<a href=\"https://bsky.app/profile/%s/post/%s\">🦋 @%s</a>"
|
||||||
)
|
)
|
||||||
|
|
||||||
type handler struct {
|
type handler struct {
|
||||||
|
@ -327,7 +327,7 @@ func (h *handler) ProcessPost(event *models.Event) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildBlobURL(server string, did string, cid string) string {
|
func buildBlobURL(server string, did string, cid string) string {
|
||||||
return server + "/xrpc/com.atproto.sync.getBlob?did=" + url.QueryEscape(did) + "&cid=" + url.QueryEscape(cid)
|
return server + "/xrpc/com.atproto.sync.getBlob?did=" + url.QueryEscape(did) + "&cid=" + cid
|
||||||
}
|
}
|
||||||
|
|
||||||
func getLink(event *models.Event) (string, string) {
|
func getLink(event *models.Event) (string, string) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue