A community based topic aggregation platform built on atproto
at main 36 lines 817 B view raw
1package adminreports 2 3import ( 4 "context" 5) 6 7// service implements the Service interface for admin reports 8type service struct { 9 repo Repository 10} 11 12// NewService creates a new admin reports service 13func NewService(repo Repository) Service { 14 return &service{ 15 repo: repo, 16 } 17} 18 19// SubmitReport validates the report request and creates a new report 20// Returns the report ID on success 21func (s *service) SubmitReport(ctx context.Context, req SubmitReportRequest) (*SubmitReportResult, error) { 22 // Use the constructor which handles validation and target type determination 23 report, err := NewReport(req) 24 if err != nil { 25 return nil, err 26 } 27 28 // Create the report in the database 29 if err := s.repo.Create(ctx, report); err != nil { 30 return nil, err 31 } 32 33 return &SubmitReportResult{ 34 ReportID: report.ID, 35 }, nil 36}