this repo has no description
1package server 2 3import ( 4 "context" 5 "time" 6 7 "github.com/Azure/go-autorest/autorest/to" 8 "github.com/bluesky-social/indigo/api/atproto" 9 "github.com/bluesky-social/indigo/events" 10 "github.com/bluesky-social/indigo/util" 11 "github.com/haileyok/cocoon/internal/helpers" 12 "github.com/haileyok/cocoon/models" 13 "github.com/labstack/echo/v4" 14) 15 16type ComAtprotoServerDeactivateAccountRequest struct { 17 // NOTE: this implementation will not pay attention to this value 18 DeleteAfter time.Time `json:"deleteAfter"` 19} 20 21func (s *Server) handleServerDeactivateAccount(e echo.Context) error { 22 ctx := e.Request().Context() 23 24 var req ComAtprotoServerDeactivateAccountRequest 25 if err := e.Bind(&req); err != nil { 26 s.logger.Error("error binding", "error", err) 27 return helpers.ServerError(e, nil) 28 } 29 30 urepo := e.Get("repo").(*models.RepoActor) 31 32 if err := s.db.Exec(ctx, "UPDATE repos SET deactivated = ? WHERE did = ?", nil, true, urepo.Repo.Did).Error; err != nil { 33 s.logger.Error("error updating account status to deactivated", "error", err) 34 return helpers.ServerError(e, nil) 35 } 36 37 s.evtman.AddEvent(context.TODO(), &events.XRPCStreamEvent{ 38 RepoAccount: &atproto.SyncSubscribeRepos_Account{ 39 Active: false, 40 Did: urepo.Repo.Did, 41 Status: to.StringPtr("deactivated"), 42 Seq: time.Now().UnixMicro(), // TODO: bad puppy 43 Time: time.Now().Format(util.ISO8601), 44 }, 45 }) 46 47 return e.NoContent(200) 48}