diff --git a/pkg/database/migrations/006_post_reports.sql b/pkg/database/migrations/006_post_reports.sql index 18cb294..94a24d7 100644 --- a/pkg/database/migrations/006_post_reports.sql +++ b/pkg/database/migrations/006_post_reports.sql @@ -2,7 +2,7 @@ CREATE TYPE ReportType AS ENUM ( 'duplicate', 'missing_data', - 'rating_abuse' + 'rating_abuse', 'illegal_content' ); diff --git a/pkg/error/validation.go b/pkg/error/validation.go index ab53258..5693903 100644 --- a/pkg/error/validation.go +++ b/pkg/error/validation.go @@ -26,7 +26,7 @@ const ( UserFavoriteIsWrongLength = "userFavoriteID has the wrong length" PostListIsEmpty = "userFavoriteList cannot be empty" - PostIDIsEmpty = "userFavoriteID cannot be empty" + PostIDIsEmpty = "PostID cannot be empty" PostIDIsWrongLength = "PostID has the wrong length" BatchSizeIsEmpty = "batchSize cannot be empty" @@ -38,6 +38,9 @@ const ( ScrapeTaskIDIsEmpty = "ScrapeTaskID cannot be empty" ScrapeTaskIDIsWrongLength = "ScrapeTaskID has the wrong length, needs to be 25 characters long" + + PostReportIDIsEmpty = "PostReportID cannot be empty" + PostReportIDIsWrongLength = "PostReportID has the wrong length" ) type EntityValidationFailed struct { diff --git a/pkg/models/const.go b/pkg/models/const.go index fb7a04f..abf13d9 100644 --- a/pkg/models/const.go +++ b/pkg/models/const.go @@ -25,6 +25,10 @@ type ( UserFavoriteID string ScrapeTaskID string + + PostReportID string + ReportType string + ReportState string ) const ( @@ -50,6 +54,21 @@ const ( Copyright TagType = "copyright" ) +const ( + Duplicate ReportType = "duplicate" + MissingData ReportType = "missing_data" + RatingAbuse ReportType = "rating_abuse" + IllegalContent ReportType = "illegal_content" +) + +const ( + PendingUnclaimed ReportState = "pending_unclaimed" + Pending ReportState = "pending" + Approved ReportState = "approved" + Partial ReportState = "partial" + Rejected ReportState = "rejected" +) + func (r *Rating) Convert(e621Rating string) { switch e621Rating { case "e": diff --git a/pkg/models/orm.go b/pkg/models/orm.go index 4ce9b06..bd02ec5 100644 --- a/pkg/models/orm.go +++ b/pkg/models/orm.go @@ -8,7 +8,7 @@ import ( ) type ID interface { - UserID | SourceID | PostID | UserSourceID | UserFavoriteID | PoolID + UserID | SourceID | PostID | UserSourceID | UserFavoriteID | PoolID | PostReportID } type BaseModel[T ID] struct { diff --git a/pkg/models/postReport.go b/pkg/models/postReport.go new file mode 100644 index 0000000..fe7ea4f --- /dev/null +++ b/pkg/models/postReport.go @@ -0,0 +1,16 @@ +package models + +type PostReport struct { + BaseModel[PostReportID] + PostID PostID `json:"post_id"` + ReportBy UserID `json:"report_by"` + ReportDescription string `json:"report_description"` + AuditBy *UserID `json:"audit_by"` + AuditDescription string `json:"audit_description"` + ReportType ReportType `json:"report_type" gorm:"type:enum('duplicate','missing_data','rating_abuse','illegal_content')"` + ReportState ReportState `json:"report_state" gorm:"type:enum('pending_unclaimed', 'pending', 'approved', 'partial', 'rejected')"` +} + +func (PostReport) TableName() string { + return "PostReport" +}