this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

style: go fmt

+19 -19
+7 -7
cmd/feedweb/did.go
··· 9 9 const NgrokHostname = "routinely-right-barnacle.ngrok-free.app" 10 10 11 11 type DidDocument struct { 12 - Context []string `json:"@context"` 13 - ID string `json:"id"` 12 + Context []string `json:"@context"` 13 + ID string `json:"id"` 14 14 Services []DidService `json:"service"` 15 15 } 16 16 17 17 type DidService struct { 18 - ID string `json:"id"` 19 - ServiceType string `json:"type"` 18 + ID string `json:"id"` 19 + ServiceType string `json:"type"` 20 20 ServiceEndpoint string `json:"serviceEndpoint"` 21 21 } 22 22 23 23 func didDoc(c echo.Context) error { 24 24 doc := DidDocument{ 25 25 Context: []string{"https://www.w3.org/ns/did/v1"}, 26 - ID: `did:web:` + NgrokHostname, 26 + ID: `did:web:` + NgrokHostname, 27 27 Services: []DidService{ 28 28 DidService{ 29 - ID: "#bsky_fg", 30 - ServiceType: "BskyFeedGenerator", 29 + ID: "#bsky_fg", 30 + ServiceType: "BskyFeedGenerator", 31 31 ServiceEndpoint: `https://` + NgrokHostname, 32 32 }, 33 33 },
+3 -3
cmd/feedweb/main.go
··· 15 15 16 16 type SkeletonRequest struct { 17 17 Feed string `query:"feed"` 18 - Limit string `query:"limit"` 18 + Limit string `query:"limit"` 19 19 Cursor string `query:"cursor"` 20 20 } 21 21 ··· 27 27 } 28 28 29 29 var generators = FeedLookup{ 30 - "at://did:plc:4nsduwlpivpuur4mqkbfvm6a/app.bsky.feed.generator/most-liked": mostliked.Feed, 30 + "at://did:plc:4nsduwlpivpuur4mqkbfvm6a/app.bsky.feed.generator/most-liked": mostliked.Feed, 31 31 "at://did:plc:4nsduwlpivpuur4mqkbfvm6a/app.bsky.feed.generator/most-liked-dev": mostliked.Feed, 32 32 } 33 33 ··· 65 65 } 66 66 67 67 type gen struct { 68 - DID string `json:"did"` 68 + DID string `json:"did"` 69 69 Feeds []feed `json:"feeds"` 70 70 } 71 71
+2 -2
cmd/mostliked/main.go
··· 1 1 package main 2 2 3 3 import ( 4 + "context" 4 5 "database/sql" 5 6 "log" 6 7 "os" 7 8 "os/signal" 8 9 "syscall" 9 - "context" 10 10 11 11 "github.com/edavis/bsky-feeds/pkg/mostliked" 12 12 "github.com/gorilla/websocket" 13 13 _ "github.com/mattn/go-sqlite3" 14 14 ) 15 15 16 - //const JetstreamUrl = `wss://jetstream1.us-west.bsky.network/subscribe?wantedCollections=app.bsky.feed.post&wantedCollections=app.bsky.feed.like&cursor=1728846514000000` 16 + // const JetstreamUrl = `wss://jetstream1.us-west.bsky.network/subscribe?wantedCollections=app.bsky.feed.post&wantedCollections=app.bsky.feed.like&cursor=1728846514000000` 17 17 const JetstreamUrl = `ws://localhost:6008/subscribe?wantedCollections=app.bsky.feed.post&wantedCollections=app.bsky.feed.like` 18 18 19 19 func main() {
+2 -2
pkg/mostliked/generator.go
··· 3 3 import ( 4 4 "context" 5 5 "database/sql" 6 + "fmt" 6 7 "log" 7 8 "strconv" 8 9 "strings" 9 - "fmt" 10 10 11 11 appbsky "github.com/bluesky-social/indigo/api/bsky" 12 12 "github.com/edavis/bsky-feeds/pkg/feeds" ··· 14 14 ) 15 15 16 16 type PostRow struct { 17 - Uri string 17 + Uri string 18 18 } 19 19 20 20 func getPosts(ctx context.Context, dbCnx *sql.DB, langs []string, limit, offset int) ([]PostRow, error) {
+5 -5
pkg/mostliked/handler.go
··· 87 87 go trimPostsTable(ctx, queries) 88 88 89 89 var ( 90 - dbTx *sql.Tx 91 - queriesTx *db.Queries 92 - txOpen bool 93 - err error 90 + dbTx *sql.Tx 91 + queriesTx *db.Queries 92 + txOpen bool 93 + err error 94 94 eventCount int 95 95 ) 96 96 ··· 182 182 } 183 183 184 184 eventCount += 1 185 - if eventCount % 1000 == 0 { 185 + if eventCount%1000 == 0 { 186 186 if err := dbTx.Commit(); err != nil { 187 187 log.Printf("commit failed: %v\n", err) 188 188 } else {