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