CoolCMS API

AdvertReportGuardTrait

Guards a new advert report (Bazaar and Comcat) in `beforeSave()`.

beforeSave() is the one place both the front signal (ApiBridge) and the external :Api:*:AdvertReport:save with a JWT go through:

  1. the target advert must exist (otherwise ITEM_NOT_FOUND),
  2. the same reporter must not already have an unresolved report on the same advert (DB_DUPLICATE_ENTRY; a logged-in user is identified by account, an anonymous one by IP, the same policy as votes and ratings); after a moderator resolves it the reporter may report again,
  3. a logged-in reporter spends the creation quota (ContentCreationLimitTrait), a cooldown against a script that bypasses the deduplication through many adverts.
Tags
requires

AdvertReportManager – expects:

Table of Contents

Methods

guardAdvertReport()  : Result|null
hasUnsolvedReport()  : bool
Tells whether this reporter already has an unresolved report on the advert. An anonymous reporter without an IP is not deduplicated (nothing is known about them); such a path exists only in the CLI.

Methods

hasUnsolvedReport()

Tells whether this reporter already has an unresolved report on the advert. An anonymous reporter without an IP is not deduplicated (nothing is known about them); such a path exists only in the CLI.

private hasUnsolvedReport(int $advertId, int|null $userId, string|null $insertIp) : bool
Parameters
$advertId : int
$userId : int|null
$insertIp : string|null
Return values
bool
On this page

Search results