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:
- the target advert must exist (otherwise
ITEM_NOT_FOUND), - 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, - a logged-in reporter spends the creation quota (ContentCreationLimitTrait), a cooldown against a script that bypasses the deduplication through many adverts.
Tags
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
guardAdvertReport()
private
guardAdvertReport(bool $isInsert, AdvertReport|AdvertReport $report, class-string $advertClass, string $scope) : Result|null
Parameters
- $isInsert : bool
- $report : AdvertReport|AdvertReport
- $advertClass : class-string
-
Api advert entity of the module
- $scope : string
Return values
Result|nullhasUnsolvedReport()
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