Commit workspace changes
This commit is contained in:
@@ -10,6 +10,8 @@ use App\Models\Collection;
|
||||
use App\Models\CollectionComment;
|
||||
use App\Models\CollectionSubmission;
|
||||
use App\Models\ConversationParticipant;
|
||||
use App\Models\Group;
|
||||
use App\Models\GroupPost;
|
||||
use App\Models\Message;
|
||||
use App\Models\NovaCard;
|
||||
use App\Models\NovaCardChallenge;
|
||||
@@ -38,6 +40,8 @@ class ReportTargetResolver
|
||||
'message',
|
||||
'conversation',
|
||||
'user',
|
||||
'group',
|
||||
'group_post',
|
||||
'story',
|
||||
'story_comment',
|
||||
'artwork_comment',
|
||||
@@ -87,6 +91,22 @@ class ReportTargetResolver
|
||||
User::query()->findOrFail($targetId);
|
||||
return;
|
||||
|
||||
case 'group':
|
||||
$group = Group::query()->findOrFail($targetId);
|
||||
abort_unless($group->canBeViewedBy($user), 403, 'You are not allowed to report this group.');
|
||||
return;
|
||||
|
||||
case 'group_post':
|
||||
$post = GroupPost::query()->with('group')->findOrFail($targetId);
|
||||
abort_unless(
|
||||
$post->group !== null
|
||||
&& $post->status === GroupPost::STATUS_PUBLISHED
|
||||
&& $post->group->canBeViewedBy($user),
|
||||
403,
|
||||
'You are not allowed to report this group post.'
|
||||
);
|
||||
return;
|
||||
|
||||
case 'story':
|
||||
Story::query()->findOrFail($targetId);
|
||||
return;
|
||||
@@ -164,6 +184,8 @@ class ReportTargetResolver
|
||||
|
||||
try {
|
||||
return match ($report->target_type) {
|
||||
'group' => $this->summarizeGroup($report->target_id),
|
||||
'group_post' => $this->summarizeGroupPost($report->target_id),
|
||||
'nova_card' => $this->summarizeNovaCard($report->target_id),
|
||||
'nova_card_comment' => $this->summarizeNovaCardComment($report->target_id),
|
||||
'nova_card_challenge' => $this->summarizeNovaCardChallenge($report->target_id),
|
||||
@@ -185,6 +207,38 @@ class ReportTargetResolver
|
||||
};
|
||||
}
|
||||
|
||||
private function summarizeGroup(int $targetId): array
|
||||
{
|
||||
$group = Group::query()->with('owner')->findOrFail($targetId);
|
||||
|
||||
return [
|
||||
'exists' => true,
|
||||
'type' => 'group',
|
||||
'id' => (int) $group->id,
|
||||
'label' => (string) $group->name,
|
||||
'subtitle' => trim(sprintf('@%s%s', (string) $group->owner?->username, $group->headline ? ' • '.$group->headline : '')),
|
||||
'public_url' => $group->publicUrl(),
|
||||
'moderation_url' => null,
|
||||
'moderation_target' => null,
|
||||
];
|
||||
}
|
||||
|
||||
private function summarizeGroupPost(int $targetId): array
|
||||
{
|
||||
$post = GroupPost::query()->with(['group.owner'])->findOrFail($targetId);
|
||||
|
||||
return [
|
||||
'exists' => $post->group !== null,
|
||||
'type' => 'group_post',
|
||||
'id' => (int) $post->id,
|
||||
'label' => (string) $post->title,
|
||||
'subtitle' => trim(sprintf('%s • %s', (string) $post->group?->name, ucfirst((string) $post->type))),
|
||||
'public_url' => $post->group ? route('groups.posts.show', ['group' => $post->group, 'post' => $post]) : null,
|
||||
'moderation_url' => null,
|
||||
'moderation_target' => null,
|
||||
];
|
||||
}
|
||||
|
||||
private function summarizeNovaCard(int $targetId): array
|
||||
{
|
||||
$card = NovaCard::query()
|
||||
|
||||
Reference in New Issue
Block a user