this repo has no description
0
fork

Configure Feed

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

empty feed handling

+11 -10
+6 -4
feed.go
··· 16 16 } 17 17 } 18 18 19 - func (f *FeedGenerator) GetFeed(ctx context.Context, userDID, feed, cursor string, limit int) (*FeedReponse, error) { 20 - resp := FeedReponse{} 19 + func (f *FeedGenerator) GetFeed(ctx context.Context, userDID, feed, cursor string, limit int) (FeedReponse, error) { 20 + resp := FeedReponse{ 21 + Feed: make([]FeedItem, 0, 0), 22 + } 21 23 22 24 f.mu.Lock() 23 25 defer f.mu.Unlock() 24 26 25 27 usersFeed, ok := f.posts[userDID] 26 28 if !ok { 27 - return nil, nil 29 + return resp, nil 28 30 } 29 31 30 32 feedItems := make([]FeedItem, 0, len(f.posts)) ··· 37 39 resp.Feed = feedItems 38 40 resp.Cursor = "" 39 41 40 - return &resp, nil 42 + return resp, nil 41 43 } 42 44 43 45 func (f *FeedGenerator) AddToFeedPosts(usersDids []string, postURI string) {
+4
go.mod
··· 7 7 github.com/bluesky-social/jetstream v0.0.0-20241031234625-0ab10bd041fe 8 8 github.com/golang-jwt/jwt/v5 v5.2.1 9 9 github.com/gorilla/websocket v1.5.1 10 + github.com/stretchr/testify v1.9.0 10 11 ) 11 12 12 13 require ( 13 14 github.com/beorn7/perks v1.0.1 // indirect 14 15 github.com/carlmjohnson/versioninfo v0.22.5 // indirect 15 16 github.com/cespare/xxhash/v2 v2.3.0 // indirect 17 + github.com/davecgh/go-spew v1.1.1 // indirect 16 18 github.com/felixge/httpsnoop v1.0.4 // indirect 17 19 github.com/go-logr/logr v1.4.1 // indirect 18 20 github.com/go-logr/stdr v1.2.2 // indirect ··· 47 49 github.com/multiformats/go-multihash v0.2.3 // indirect 48 50 github.com/multiformats/go-varint v0.0.7 // indirect 49 51 github.com/opentracing/opentracing-go v1.2.0 // indirect 52 + github.com/pmezard/go-difflib v1.0.0 // indirect 50 53 github.com/polydawn/refmt v0.89.1-0.20221221234430-40501e09de1f // indirect 51 54 github.com/prometheus/client_golang v1.19.1 // indirect 52 55 github.com/prometheus/client_model v0.6.1 // indirect ··· 69 72 golang.org/x/time v0.5.0 // indirect 70 73 golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect 71 74 google.golang.org/protobuf v1.34.2 // indirect 75 + gopkg.in/yaml.v3 v3.0.1 // indirect 72 76 lukechampine.com/blake3 v1.2.1 // indirect 73 77 )
+1 -6
server.go
··· 10 10 ) 11 11 12 12 type Feeder interface { 13 - GetFeed(ctx context.Context, userDID, feed, cursor string, limit int) (*FeedReponse, error) 13 + GetFeed(ctx context.Context, userDID, feed, cursor string, limit int) (FeedReponse, error) 14 14 } 15 15 16 16 type Server struct { ··· 108 108 if err != nil { 109 109 slog.Error("get feed", "error", err, "feed", feed) 110 110 http.Error(w, "error getting feed", http.StatusInternalServerError) 111 - return 112 - } 113 - 114 - if resp == nil { 115 - slog.Info("no feed posts found") 116 111 return 117 112 } 118 113