You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pixelfed/app/Http/Resources/AdminReport.php

69 lines
2.1 KiB
PHTML

<?php
namespace App\Http\Resources;
use App\Models\DmMessage;
use App\Models\Status;
use App\Models\Story;
use App\Services\AccountService;
use App\Services\DirectMessagePayloadService;
use App\Services\StatusService;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
4 weeks ago
use Illuminate\Support\Carbon;
Staging (#6343) * Prepared new docker * Docker setup improvements and fixes * Update DOCKER_SETUP.md * Update DOCKER_SETUP.md * Update DOCKER_SETUP.md * Update DOCKER_SETUP.md * Update DOCKER_SETUP.md * Update DOCKER_SETUP.md * Update .dockerignore * DB/Redis health check * updated health checks * updated install guide * updated DOCKER_SETUP * Updated DOCKER_SETUP * Updated DOCKER_SETUP * Update and rename DOCKER_SETUP.md to DOCKER_COMPOSE_SETUP.md * RemoveUnreachableStatementRector * Update GroupActivityPubService.php * Larastan: Add @property * Delete rector.php * more properties * 2fa_enabled needs to be refactored * Fix AdminUser.php syntax error - remove invalid property declaration * Update AdminUser.php * update * Upgrade predis from v2.0 to v3.2 - Update predis/predis from ^2.0 to ^3.2 - Predis v3.2.0 includes RESP3 support, improved pipeline abstractions - No code changes required, configuration remains compatible - Tested successfully with tinker * Upgrade predis from v2.0 to v3.2 * Update * Update .env.docker.example * Update DOCKER_COMPOSE_SETUP.md * Create ImageDriverManager.php * Update image.php * Update ImageResizePipeline.php * Update StoryComposeController.php * Update AvatarOptimize.php * Update Image.php * Update composer.json * Update AvatarOptimize.php * update lock * Update composer.lock * update * update * update * Allow to set new image types in admin interface * Update composer, fix deps * Update composer --------- Co-authored-by: Shlee <github@shl.ee> Co-authored-by: Your Name <you@example.com> Co-authored-by: Severin <savewish@icloud.com>
10 months ago
/**
* @property int $id
* @property int $profile_id
* @property string|null $type
* @property int $object_id
* @property string $object_type
* @property int $reported_profile_id
* @property string|null $message
4 weeks ago
* @property Carbon|null $admin_seen
* @property Carbon $created_at
Staging (#6343) * Prepared new docker * Docker setup improvements and fixes * Update DOCKER_SETUP.md * Update DOCKER_SETUP.md * Update DOCKER_SETUP.md * Update DOCKER_SETUP.md * Update DOCKER_SETUP.md * Update DOCKER_SETUP.md * Update .dockerignore * DB/Redis health check * updated health checks * updated install guide * updated DOCKER_SETUP * Updated DOCKER_SETUP * Updated DOCKER_SETUP * Update and rename DOCKER_SETUP.md to DOCKER_COMPOSE_SETUP.md * RemoveUnreachableStatementRector * Update GroupActivityPubService.php * Larastan: Add @property * Delete rector.php * more properties * 2fa_enabled needs to be refactored * Fix AdminUser.php syntax error - remove invalid property declaration * Update AdminUser.php * update * Upgrade predis from v2.0 to v3.2 - Update predis/predis from ^2.0 to ^3.2 - Predis v3.2.0 includes RESP3 support, improved pipeline abstractions - No code changes required, configuration remains compatible - Tested successfully with tinker * Upgrade predis from v2.0 to v3.2 * Update * Update .env.docker.example * Update DOCKER_COMPOSE_SETUP.md * Create ImageDriverManager.php * Update image.php * Update ImageResizePipeline.php * Update StoryComposeController.php * Update AvatarOptimize.php * Update Image.php * Update composer.json * Update AvatarOptimize.php * update lock * Update composer.lock * update * update * update * Allow to set new image types in admin interface * Update composer, fix deps * Update composer --------- Co-authored-by: Shlee <github@shl.ee> Co-authored-by: Your Name <you@example.com> Co-authored-by: Severin <savewish@icloud.com>
10 months ago
*/
class AdminReport extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
$res = [
'id' => $this->id,
'reporter' => AccountService::get($this->profile_id, true),
'type' => $this->type,
'object_id' => (string) $this->object_id,
'object_type' => $this->object_type,
'reported' => AccountService::get($this->reported_profile_id, true),
'status' => null,
'reporter_message' => $this->message,
'admin_seen_at' => $this->admin_seen,
'created_at' => $this->created_at,
];
if ($this->object_id && in_array($this->object_type, [Status::class, 'App\Status'])) {
$res['status'] = StatusService::get($this->object_id, false);
}
if ($this->object_id && $this->object_type === DmMessage::class) {
$message = DmMessage::withTrashed()->with('media')->find($this->object_id);
if ($message) {
$res['direct_message'] = app(DirectMessagePayloadService::class)->message($message, (int) $this->profile_id);
}
}
if ($this->object_id && in_array($this->object_type, [Story::class, 'App\Story'])) {
$story = Story::find($this->object_id);
if ($story) {
$res['story'] = $story->toAdminEntity();
}
}
return $res;
}
}