Documentation
¶
Overview ¶
Package report handles complaints about textures. A user reports a texture they can see; an administrator upholds the report (deleting the texture or banning its uploader) or rejects it. Score changes follow Blessing Skin's reporter_* settings, but every one goes through the ledger, and refunds reverse what was actually paid.
Index ¶
- Constants
- Variables
- type Filter
- type Service
- func (s *Service) Count(ctx context.Context, f Filter) (int, error)
- func (s *Service) Get(ctx context.Context, id int64) (*ent.Report, error)
- func (s *Service) List(ctx context.Context, f Filter) ([]*ent.Report, int64, error)
- func (s *Service) PendingCount(ctx context.Context) (int, error)
- func (s *Service) Review(ctx context.Context, handler *int64, id int64, action string, r score.Rates, ...) (*ent.Report, error)
- func (s *Service) SetHooks(b *hook.Bus)
- func (s *Service) Submit(ctx context.Context, v texture.Viewer, textureID int64, reason string, ...) (*ent.Report, int64, error)
Constants ¶
const ( ActionDelete = "delete" // delete the texture ActionBan = "ban" // ban the uploader ActionReject = "reject" )
Actions an administrator can take on a report.
const MaxReason = 500
MaxReason is the longest reason, in characters.
Variables ¶
var ( // ErrNotFound means there is no such report. ErrNotFound = errors.New("report not found") // ErrDuplicate means the user reported this texture already. ErrDuplicate = errors.New("you have reported this texture already") // ErrOwnTexture refuses a report of the reporter's own upload. ErrOwnTexture = errors.New("you cannot report your own texture") // ErrReviewed means the report is no longer pending. ErrReviewed = errors.New("the report has been reviewed already") // ErrNoUploader refuses a ban when the uploader's account is gone. ErrNoUploader = errors.New("the uploader's account no longer exists") )
Functions ¶
This section is empty.
Types ¶
type Filter ¶
type Filter struct {
Status string // pending | resolved | rejected; empty for all
ReporterID int64
UploaderID int64 // reports against one uploader
TextureID int64
Before int64 // reports with smaller ids (the next page)
Offset int // or skip this many (numbered pages)
Limit int // 1–100, default 20
}
Filter selects reports, newest first.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service implements reports.
func NewService ¶
NewService creates the service.
func (*Service) Count ¶
Count is how many reports the filter matches (Before, Offset and Limit aside).
func (*Service) List ¶
List returns one page of reports with their texture (and its uploader), reporter, reported uploader and handler, and the id to pass as Before for the next page (0 on the last page).
func (*Service) PendingCount ¶
PendingCount is how many reports wait for review.
func (*Service) Review ¶
func (s *Service) Review(ctx context.Context, handler *int64, id int64, action string, r score.Rates, refund bool, ban func(ctx context.Context, userID int64) error, rec *audit.Entry) (*ent.Report, error)
Review settles a pending report as an administrator (handler; nil for the admin token):
- reject: a submit reward is taken back (if the reporter can cover it); a charge is kept, as in Blessing Skin.
- delete: the texture is deleted through the one deletion path (closets refunded, the file reference-counted, Blessing Skin C06), in the same transaction as the report. The reporter gets a charge back and r.ReporterReward. Other pending reports of the texture are settled with it: charges back, no reward (the first report reviewed is the one rewarded, as in Blessing Skin). If the uploader had deleted the texture already, the charge comes back without a reward.
- ban: ban(uploader) runs first and decides whether the administrator may; then the reporter is settled as for delete.
Only one review of a report can win; a later one gets ErrReviewed. refund is score.return_on_delete, for the texture deletion. rec, if not nil, is written to the audit log in the same transaction, with the uploader the report was about.
func (*Service) SetHooks ¶
SetHooks sets the bus report events are published to (none before it is set).
func (*Service) Submit ¶
func (s *Service) Submit(ctx context.Context, v texture.Viewer, textureID int64, reason string, r score.Rates) (*ent.Report, int64, error)
Submit files a report about a texture the viewer can see, applying r.ReporterModification to the reporter's score: a charge must be affordable (score.ErrInsufficient). Reporting a texture twice is refused by the unique index.