fix(reports): make front-end handle nullified reported_id and reported_id

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2023-08-31 19:04:05 +02:00
parent b9a165a7fc
commit afd2ffe722
No known key found for this signature in database
GPG Key ID: A061B9DDE0CA0773
5 changed files with 48 additions and 21 deletions

View File

@ -5,7 +5,7 @@
> >
<div class="flex justify-between gap-1 border-b p-2"> <div class="flex justify-between gap-1 border-b p-2">
<div class="flex gap-1"> <div class="flex gap-1">
<figure class="" v-if="report.reported.avatar"> <figure class="" v-if="report.reported?.avatar">
<img <img
alt="" alt=""
:src="report.reported.avatar.url" :src="report.reported.avatar.url"
@ -16,14 +16,20 @@
</figure> </figure>
<AccountCircle v-else :size="24" /> <AccountCircle v-else :size="24" />
<div class=""> <div class="">
<p class="" v-if="report.reported.name">{{ report.reported.name }}</p> <p class="" v-if="report.reported?.name">
<p class="text-zinc-700 dark:text-zinc-100 text-sm"> {{ report.reported.name }}
</p>
<p
class="text-zinc-700 dark:text-zinc-100 text-sm"
v-else-if="report.reported?.preferredUsername"
>
@{{ usernameWithDomain(report.reported) }} @{{ usernameWithDomain(report.reported) }}
</p> </p>
<p v-else>{{ t("Unknown actor") }}</p>
</div> </div>
</div> </div>
<div> <div>
<p v-if="report.reported.suspended" class="text-red-700 font-bold"> <p v-if="report.reported?.suspended" class="text-red-700 font-bold">
{{ t("Suspended") }} {{ t("Suspended") }}
</p> </p>
</div> </div>
@ -31,7 +37,7 @@
<div class="p-2"> <div class="p-2">
<div class=""> <div class="">
<span v-if="report.reporter.type === ActorType.APPLICATION"> <span v-if="report.reporter?.type === ActorType.APPLICATION">
{{ {{
t("Reported by someone on {domain}", { t("Reported by someone on {domain}", {
domain: report.reporter.domain, domain: report.reporter.domain,
@ -40,19 +46,22 @@
</span> </span>
<span <span
v-if=" v-if="
report.reporter.preferredUsername === 'anonymous' && report.reporter?.preferredUsername === 'anonymous' &&
!report.reporter.domain !report.reporter?.domain
" "
> >
{{ t("Reported by someone anonymously") }} {{ t("Reported by someone anonymously") }}
</span> </span>
<span v-else> <span v-else-if="report.reporter?.preferredUsername">
{{ {{
t("Reported by {reporter}", { t("Reported by {reporter}", {
reporter: usernameWithDomain(report.reporter), reporter: usernameWithDomain(report.reporter),
}) })
}} }}
</span> </span>
<span v-else>
{{ t("Reported by an unknown actor") }}
</span>
</div> </div>
<div class="" v-if="report.content" v-html="report.content" /> <div class="" v-if="report.content" v-html="report.content" />
</div> </div>

View File

@ -1593,7 +1593,6 @@
"Event deleted": "Event deleted", "Event deleted": "Event deleted",
"Comment deleted and report resolved": "Comment deleted and report resolved", "Comment deleted and report resolved": "Comment deleted and report resolved",
"Comment under event {eventTitle}": "Comment under event {eventTitle}", "Comment under event {eventTitle}": "Comment under event {eventTitle}",
"Suspend profile": "Suspend profile",
"Do you really want to suspend this profile? All of the profiles content will be deleted.": "Do you really want to suspend this profile? All of the profiles content will be deleted.", "Do you really want to suspend this profile? All of the profiles content will be deleted.": "Do you really want to suspend this profile? All of the profiles content will be deleted.",
"There will be no way to restore the profile's data!": "There will be no way to restore the profile's data!", "There will be no way to restore the profile's data!": "There will be no way to restore the profile's data!",
"Suspend the profile": "Suspend the profile", "Suspend the profile": "Suspend the profile",
@ -1602,5 +1601,9 @@
"There will be no way to restore the user's data!": "There will be no way to restore the user's data!", "There will be no way to restore the user's data!": "There will be no way to restore the user's data!",
"User suspended and report resolved": "User suspended and report resolved", "User suspended and report resolved": "User suspended and report resolved",
"Profile suspended and report resolved": "Profile suspended and report resolved", "Profile suspended and report resolved": "Profile suspended and report resolved",
"{profileName} (suspended)": "{profileName} (suspended)" "{profileName} (suspended)": "{profileName} (suspended)",
"Reported by an unknown actor": "Reported by an unknown actor",
"Reported at": "Reported at",
"Updated at": "Updated at",
"Suspend the profile?": "Suspend the profile?"
} }

View File

@ -1600,5 +1600,8 @@
"There will be no way to restore the user's data!": "Il n'y aura aucun moyen de restorer les données de l'utilisateur·ice !", "There will be no way to restore the user's data!": "Il n'y aura aucun moyen de restorer les données de l'utilisateur·ice !",
"User suspended and report resolved": "Utilisateur suspendu et signalement résolu", "User suspended and report resolved": "Utilisateur suspendu et signalement résolu",
"Profile suspended and report resolved": "Profil suspendu et signalement résolu", "Profile suspended and report resolved": "Profil suspendu et signalement résolu",
"{profileName} (suspended)": "{profileName} (suspendu·e)" "{profileName} (suspended)": "{profileName} (suspendu·e)",
"Reported by an unknown actor": "Signalé par un·e acteur·ice inconnu·e",
"Reported at": "Signalé à",
"Updated at": "Mis à jour à"
} }

View File

@ -14,7 +14,7 @@ export interface IReportNote extends IActionLogObject {
} }
export interface IReport extends IActionLogObject { export interface IReport extends IActionLogObject {
id: string; id: string;
reported: IActor; reported: IActor | undefined;
reporter: IPerson; reporter: IPerson;
events?: IEvent[]; events?: IEvent[];
comments: IComment[]; comments: IComment[];

View File

@ -65,7 +65,7 @@
<section class="w-full"> <section class="w-full">
<table class="table w-full"> <table class="table w-full">
<tbody> <tbody>
<tr v-if="report.reported.type === ActorType.GROUP"> <tr v-if="report.reported?.type === ActorType.GROUP">
<td>{{ t("Reported group") }}</td> <td>{{ t("Reported group") }}</td>
<td> <td>
<router-link <router-link
@ -84,7 +84,7 @@
</router-link> </router-link>
</td> </td>
</tr> </tr>
<tr v-else> <tr v-else-if="report.reported?.type === ActorType.PERSON">
<td> <td>
{{ t("Reported identity") }} {{ t("Reported identity") }}
</td> </td>
@ -134,12 +134,20 @@
> >
</td> </td>
</tr> </tr>
<tr v-else>
<td>
{{ t("Reported identity") }}
</td>
<td>
{{ t("Unknown actor") }}
</td>
</tr>
<tr> <tr>
<td>{{ t("Reported by") }}</td> <td>{{ t("Reported by") }}</td>
<td v-if="report.reporter.type === ActorType.APPLICATION"> <td v-if="report.reporter?.type === ActorType.APPLICATION">
{{ report.reporter.domain }} {{ report.reporter.domain }}
</td> </td>
<td v-else> <td v-else-if="report.reporter?.type === ActorType.PERSON">
<router-link <router-link
:to="{ :to="{
name: RouteName.ADMIN_PROFILE, name: RouteName.ADMIN_PROFILE,
@ -155,13 +163,16 @@
{{ displayNameAndUsername(report.reporter) }} {{ displayNameAndUsername(report.reporter) }}
</router-link> </router-link>
</td> </td>
<td v-else>
{{ t("Unknown actor") }}
</td>
</tr> </tr>
<tr> <tr>
<td>{{ t("Reported") }}</td> <td>{{ t("Reported at") }}</td>
<td>{{ formatDateTimeString(report.insertedAt) }}</td> <td>{{ formatDateTimeString(report.insertedAt) }}</td>
</tr> </tr>
<tr v-if="report.updatedAt !== report.insertedAt"> <tr v-if="report.updatedAt !== report.insertedAt">
<td>{{ t("Updated") }}</td> <td>{{ t("Updated at") }}</td>
<td>{{ formatDateTimeString(report.updatedAt) }}</td> <td>{{ formatDateTimeString(report.updatedAt) }}</td>
</tr> </tr>
<tr> <tr>
@ -187,7 +198,7 @@
<h2 class="mb-1">{{ t("Report reason") }}</h2> <h2 class="mb-1">{{ t("Report reason") }}</h2>
<div class=""> <div class="">
<div class="flex gap-1"> <div class="flex gap-1">
<figure class="" v-if="report.reported.avatar"> <figure class="" v-if="report.reported?.avatar">
<img <img
alt="" alt=""
:src="report.reported.avatar.url" :src="report.reported.avatar.url"
@ -197,12 +208,13 @@
/> />
</figure> </figure>
<AccountCircle v-else :size="36" /> <AccountCircle v-else :size="36" />
<div class=""> <div class="" v-if="report.reported">
<p class="" v-if="report.reported.name"> <p class="" v-if="report.reported?.name">
{{ report.reported.name }} {{ report.reported.name }}
</p> </p>
<p class="">@{{ usernameWithDomain(report.reported) }}</p> <p class="">@{{ usernameWithDomain(report.reported) }}</p>
</div> </div>
<p v-else>{{ t("Unknown actor") }}</p>
</div> </div>
<div <div
class="prose dark:prose-invert" class="prose dark:prose-invert"