this repo has no description
0
fork

Configure Feed

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

add profile to test

Hailey 2e46cf03 e39d8a88

+62
+51
cmd/client_test/handle_profile.go
··· 1 + package main 2 + 3 + import ( 4 + "github.com/bluesky-social/indigo/api/bsky" 5 + "github.com/bluesky-social/indigo/xrpc" 6 + "github.com/labstack/echo-contrib/session" 7 + "github.com/labstack/echo/v4" 8 + ) 9 + 10 + func (s *TestServer) handleProfile(e echo.Context) error { 11 + sess, err := session.Get("session", e) 12 + if err != nil { 13 + return err 14 + } 15 + 16 + did, ok := sess.Values["did"] 17 + if !ok { 18 + return e.Redirect(302, "/login") 19 + } 20 + 21 + var oauthSession OauthSession 22 + if err := s.db.Raw("SELECT * FROM oauth_sessions WHERE did = ?", did).Scan(&oauthSession).Error; err != nil { 23 + return err 24 + } 25 + 26 + args, err := authedReqArgsFromSession(&oauthSession) 27 + if err != nil { 28 + return err 29 + } 30 + 31 + var out bsky.ActorDefs_ProfileViewDetailed 32 + if err := s.xrpcCli.Do(e.Request().Context(), args, xrpc.Query, "", "app.bsky.actor.getProfile", map[string]any{"actor": oauthSession.Did}, nil, &out); err != nil { 33 + return err 34 + } 35 + 36 + var dn string 37 + if out.DisplayName != nil { 38 + dn = *out.DisplayName 39 + } 40 + 41 + var desc string 42 + if out.Description != nil { 43 + desc = *out.Description 44 + } 45 + 46 + return e.Render(200, "profile.html", map[any]any{ 47 + "DisplayName": dn, 48 + "Description": desc, 49 + "Handle": out.Handle, 50 + }) 51 + }
+3
cmd/client_test/html/index.html
··· 7 7 <ul> 8 8 {{ if .Did }} 9 9 <li> 10 + <a href="/profile">Profile</a> 11 + </li> 12 + <li> 10 13 <a href="/make-post">Make a Post</a> 11 14 </li> 12 15 <li>
+7
cmd/client_test/html/profile.html
··· 1 + <!doctype html> 2 + <html> 3 + <h2>{{ .DisplayName }}</h2> 4 + <p>{{ .Handle }}</p> 5 + <p>{{ .Description }}</p> 6 + <a href="/">Go Home</a> 7 + </html>
+1
cmd/client_test/main.go
··· 155 155 s.e.File("/login", getFilePath("login.html")) 156 156 s.e.POST("/login", s.handleLoginSubmit) 157 157 s.e.GET("/logout", s.handleLogout) 158 + s.e.GET("/profile", s.handleProfile) 158 159 s.e.GET("/make-post", s.handleMakePost) 159 160 s.e.GET("/callback", s.handleCallback) 160 161 s.e.GET("/oauth/client-metadata.json", s.handleClientMetadata)