diff options
author | bnewbold <bnewbold@robocracy.org> | 2023-12-22 17:07:25 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-22 17:07:25 +0100 |
commit | a5c151c04177e539543b6ad3e9c4504efc722468 (patch) | |
tree | 08b0c0e99e67a575abdc47253945a68490e997f6 /bskyweb | |
parent | 64dc8ff34245f602fbf2c207dac7c5865bef541b (diff) | |
download | voidsky-a5c151c04177e539543b6ad3e9c4504efc722468.tar.zst |
bskyweb: iterate on RSS format, based on feedback (#2269)
Thanks to Dave Winer (@scripting)!
Diffstat (limited to 'bskyweb')
-rw-r--r-- | bskyweb/cmd/bskyweb/rss.go | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/bskyweb/cmd/bskyweb/rss.go b/bskyweb/cmd/bskyweb/rss.go index f7caf8fe7..cf7b24346 100644 --- a/bskyweb/cmd/bskyweb/rss.go +++ b/bskyweb/cmd/bskyweb/rss.go @@ -1,8 +1,10 @@ package main import ( + "encoding/xml" "fmt" "net/http" + "time" appbsky "github.com/bluesky-social/indigo/api/bsky" "github.com/bluesky-social/indigo/atproto/syntax" @@ -10,6 +12,12 @@ import ( "github.com/labstack/echo/v4" ) +type ItemGUID struct { + XMLName xml.Name `xml:"guid"` + Value string `xml:",chardata"` + IsPerma bool `xml:"isPermalink,attr"` +} + // We don't actually populate the title for "posts". // Some background: https://book.micro.blog/rss-for-microblogs/ type Item struct { @@ -17,8 +25,7 @@ type Item struct { Link string `xml:"link,omitempty"` Description string `xml:"description,omitempty"` PubDate string `xml:"pubDate,omitempty"` - Author string `xml:"author,omitempty"` - GUID string `xml:"guid,omitempty"` + GUID ItemGUID } type rss struct { @@ -71,12 +78,19 @@ func (srv *Server) WebProfileRSS(c echo.Context) error { if rec.Reply != nil { continue } + pubDate := "" + createdAt, err := syntax.ParseDatetimeLenient(rec.CreatedAt) + if nil == err { + pubDate = createdAt.Time().Format(time.RFC822Z) + } posts = append(posts, Item{ Link: fmt.Sprintf("https://bsky.app/profile/%s/post/%s", pv.Handle, aturi.RecordKey().String()), Description: rec.Text, - PubDate: rec.CreatedAt, - Author: "@" + pv.Handle, - GUID: aturi.String(), + PubDate: pubDate, + GUID: ItemGUID{ + Value: aturi.String(), + IsPerma: false, + }, }) } |