this repo has no description
0
fork

Configure Feed

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

labelmaker: more error handling

+16 -6
+16 -6
labeling/xrpc_handlers.go
··· 5 5 "strconv" 6 6 "strings" 7 7 "time" 8 + "errors" 8 9 9 10 atproto "github.com/bluesky-social/indigo/api/atproto" 10 11 label "github.com/bluesky-social/indigo/api/label" ··· 12 13 "github.com/bluesky-social/indigo/util" 13 14 14 15 "github.com/labstack/echo/v4" 16 + "gorm.io/gorm" 15 17 ) 16 18 17 19 func (s *Server) handleComAtprotoIdentityResolveHandle(ctx context.Context, handle string) (*atproto.IdentityResolveHandle_Output, error) { ··· 292 294 if body.CreatedBy == "" { 293 295 return nil, echo.NewHTTPError(400, "createBy param must be non-empty") 294 296 } 295 - /* XXX: 296 297 if body.Reason == "" { 297 298 return nil, echo.NewHTTPError(400, "reason param was provided, but empty string") 298 299 } 299 - */ 300 300 301 301 row := models.ModerationAction{ID: uint64(body.Id)} 302 302 result := s.db.First(&row) 303 303 if result.Error != nil { 304 - // XXX: if not found, 404 305 - //return nil, echo.NewHTTPError(404, "moderation action not found: %d", body.Id) 306 - return nil, result.Error 304 + if errors.Is(result.Error, gorm.ErrRecordNotFound) { 305 + return nil, echo.NewHTTPError(404, "moderation action not found: %d", body.Id) 306 + } else { 307 + return nil, result.Error 308 + } 307 309 } 308 310 309 311 if row.ReversedAt != nil { ··· 325 327 326 328 func (s *Server) handleComAtprotoAdminTakeModerationAction(ctx context.Context, body *atproto.AdminTakeModerationAction_Input) (*atproto.AdminDefs_ActionView, error) { 327 329 328 - // XXX: check that Action, CreatedBy, and Reason are all non-empty 330 + if body.Action == "" { 331 + return nil, echo.NewHTTPError(400, "action param must be non-empty") 332 + } 333 + if body.CreatedBy == "" { 334 + return nil, echo.NewHTTPError(400, "createBy param must be non-empty") 335 + } 336 + if body.Reason == "" { 337 + return nil, echo.NewHTTPError(400, "reason param was provided, but empty string") 338 + } 329 339 330 340 // XXX: SubjectBlobCids (how does atproto do it? array in postgresql?) 331 341 row := models.ModerationAction{