this repo has no description
0
fork

Configure Feed

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

updates from review

+64 -3
+1 -1
HACKING.md
··· 15 15 - `cmd/sonar`: event stream monitoring tool 16 16 - `cmd/hepa`: auto-moderation rule engine service 17 17 - `cmd/rainbow`: firehose fanout service 18 - - `cmd/domesbook`: identity directory service 18 + - `cmd/domesday`: identity directory service 19 19 - `gen`: dev tool to run CBOR type codegen 20 20 21 21 Packages:
+18 -2
cmd/domesday/handlers.go
··· 12 12 "github.com/labstack/echo/v4" 13 13 ) 14 14 15 + // GET /xrpc/com.atproto.identity.resolveHandle 15 16 func (srv *Server) ResolveHandle(c echo.Context) error { 16 17 ctx := c.Request().Context() 17 18 ··· 40 41 }) 41 42 } 42 43 44 + // GET /xrpc/com.atproto.identity.resolveDid 43 45 func (srv *Server) ResolveDid(c echo.Context) error { 44 46 ctx := c.Request().Context() 45 47 ··· 68 70 }) 69 71 } 70 72 73 + // helper for resolveIdentity 71 74 func (srv *Server) resolveIdentityFromHandle(c echo.Context, handle syntax.Handle) error { 72 75 ctx := c.Request().Context() 73 76 ··· 123 126 }) 124 127 } 125 128 129 + // helper for resolveIdentity 126 130 func (srv *Server) resolveIdentityFromDID(c echo.Context, did syntax.DID) error { 127 131 ctx := c.Request().Context() 128 132 ··· 167 171 }) 168 172 } 169 173 174 + // GET /xrpc/com.atproto.identity.resolveIdentity 170 175 func (srv *Server) ResolveIdentity(c echo.Context) error { 171 176 // we partially re-implement the "Lookup()" logic here, but returning the full DID document, not `identity.Identity` 172 177 atid, err := syntax.ParseAtIdentifier(c.QueryParam("identifier")) ··· 188 193 return fmt.Errorf("unreachable code path") 189 194 } 190 195 196 + // POST /xrpc/com.atproto.identity.refreshIdentity 191 197 func (srv *Server) RefreshIdentity(c echo.Context) error { 192 198 ctx := c.Request().Context() 193 199 194 - atid, err := syntax.ParseAtIdentifier(c.QueryParam("identifier")) 200 + var body comatproto.IdentityRefreshIdentity_Input 201 + if err := c.Bind(&body); err != nil { 202 + return c.JSON(400, GenericError{ 203 + Error: "InvalidRequestBody", 204 + Message: err.Error(), 205 + }) 206 + } 207 + 208 + atid, err := syntax.ParseAtIdentifier(body.Identifier) 195 209 if err != nil { 196 210 return c.JSON(400, GenericError{ 197 211 Error: "InvalidIdentifierSyntax", ··· 204 218 if err := srv.dir.PurgeDID(ctx, did); err != nil { 205 219 return err 206 220 } 221 + return srv.resolveIdentityFromDID(c, did) 207 222 } 208 223 handle, err := atid.AsHandle() 209 224 if nil == err { 210 225 if err := srv.dir.PurgeHandle(ctx, handle); err != nil { 211 226 return err 212 227 } 228 + return srv.resolveIdentityFromHandle(c, handle) 213 229 } 214 230 215 - return srv.ResolveIdentity(c) 231 + return fmt.Errorf("unreachable code path") 216 232 } 217 233 218 234 type GenericStatus struct {
+45
cmd/domesday/main.go
··· 126 126 }, 127 127 }, 128 128 }, 129 + &cli.Command{ 130 + Name: "refresh", 131 + ArgsUsage: `<at-identifier>`, 132 + Usage: "ask service to refresh identity", 133 + Action: runRefreshCmd, 134 + Flags: []cli.Flag{ 135 + &cli.StringFlag{ 136 + Name: "host", 137 + Usage: "domesday server to send request to", 138 + Value: "http://localhost:6600", 139 + EnvVars: []string{"DOMESDAY_HOST"}, 140 + }, 141 + }, 142 + }, 129 143 }, 130 144 } 131 145 ··· 259 273 fmt.Println(string(b)) 260 274 return nil 261 275 } 276 + 277 + func runRefreshCmd(cctx *cli.Context) error { 278 + ctx := context.Background() 279 + dir := configClient(cctx) 280 + 281 + s := cctx.Args().First() 282 + if s == "" { 283 + return fmt.Errorf("need to provide identifier for resolution") 284 + } 285 + atid, err := syntax.ParseAtIdentifier(s) 286 + if err != nil { 287 + return err 288 + } 289 + 290 + err = dir.Purge(ctx, *atid) 291 + if err != nil { 292 + return err 293 + } 294 + 295 + ident, err := dir.Lookup(ctx, *atid) 296 + if err != nil { 297 + return err 298 + } 299 + 300 + b, err := json.MarshalIndent(ident, "", " ") 301 + if err != nil { 302 + return err 303 + } 304 + fmt.Println(string(b)) 305 + return nil 306 + }