this repo has no description
0
fork

Configure Feed

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

at main 45 lines 882 B view raw
1package main 2 3import ( 4 "fmt" 5 "log/slog" 6 "net/http" 7 8 "github.com/willdot/bskyfeedgen/frontend" 9) 10 11const ( 12 bskyBaseURL = "https://bsky.social/xrpc" 13) 14 15type loginRequest struct { 16 Handle string `json:"handle"` 17} 18 19func (s *Server) authMiddleware(next func(http.ResponseWriter, *http.Request)) func(http.ResponseWriter, *http.Request) { 20 return func(w http.ResponseWriter, r *http.Request) { 21 _, ok := s.getDidFromSession(r) 22 if !ok { 23 slog.Warn("did not found in session") 24 _ = frontend.Login("", "").Render(r.Context(), w) 25 return 26 } 27 28 next(w, r) 29 } 30} 31 32func (s *Server) getDidFromSession(r *http.Request) (string, bool) { 33 session, err := s.sessionStore.Get(r, "oauth-session") 34 if err != nil { 35 slog.Error("getting session", "error", err) 36 return "", false 37 } 38 39 did, ok := session.Values["did"] 40 if !ok { 41 return "", false 42 } 43 44 return fmt.Sprintf("%s", did), true 45}