build: switch from yarn to npm to manage js dependencies and move js contents to root
yarn v1 is being deprecated and starts to have some issues Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
482
src/views/Moderation/LogsView.vue
Normal file
482
src/views/Moderation/LogsView.vue
Normal file
@@ -0,0 +1,482 @@
|
||||
<template>
|
||||
<div>
|
||||
<breadcrumbs-nav
|
||||
:links="[
|
||||
{
|
||||
name: RouteName.MODERATION,
|
||||
text: $t('Moderation'),
|
||||
},
|
||||
{
|
||||
name: RouteName.REPORT_LOGS,
|
||||
text: $t('Moderation log'),
|
||||
},
|
||||
]"
|
||||
/>
|
||||
<section v-if="actionLogs.total > 0 && actionLogs.elements.length > 0">
|
||||
<ul>
|
||||
<li
|
||||
v-for="log in actionLogs.elements"
|
||||
:key="log.id"
|
||||
class="bg-mbz-yellow-alt-50 hover:bg-mbz-yellow-alt-100 dark:bg-zinc-700 hover:dark:bg-zinc-600 rounded p-2 my-1"
|
||||
>
|
||||
<div class="flex gap-1">
|
||||
<div class="flex gap-1">
|
||||
<figure class="h-10 w-10" v-if="log.actor?.avatar">
|
||||
<img
|
||||
alt=""
|
||||
:src="log.actor.avatar?.url"
|
||||
class="object-cover rounded-full h-full w-full"
|
||||
width="36"
|
||||
height="36"
|
||||
/>
|
||||
</figure>
|
||||
<AccountCircle v-else :size="36" />
|
||||
</div>
|
||||
<div>
|
||||
<i18n-t
|
||||
v-if="log.action === ActionLogAction.REPORT_UPDATE_CLOSED"
|
||||
tag="span"
|
||||
keypath="{moderator} closed {report}"
|
||||
>
|
||||
<template #moderator>
|
||||
<router-link
|
||||
class="underline"
|
||||
:to="{
|
||||
name: RouteName.ADMIN_PROFILE,
|
||||
params: { id: log.actor.id },
|
||||
}"
|
||||
>{{ displayName(log.actor) }}</router-link
|
||||
>
|
||||
</template>
|
||||
<template #report>
|
||||
<router-link
|
||||
class="underline"
|
||||
:to="{
|
||||
name: RouteName.REPORT,
|
||||
params: { reportId: log.object.id },
|
||||
}"
|
||||
>{{
|
||||
$t("report #{report_number}", {
|
||||
report_number: log.object.id,
|
||||
})
|
||||
}}
|
||||
</router-link>
|
||||
</template>
|
||||
</i18n-t>
|
||||
<i18n-t
|
||||
v-else-if="log.action === ActionLogAction.REPORT_UPDATE_OPENED"
|
||||
tag="span"
|
||||
keypath="{moderator} reopened {report}"
|
||||
>
|
||||
<template #moderator>
|
||||
<router-link
|
||||
class="underline"
|
||||
:to="{
|
||||
name: RouteName.ADMIN_PROFILE,
|
||||
params: { id: log.actor.id },
|
||||
}"
|
||||
>{{ displayName(log.actor) }}</router-link
|
||||
>
|
||||
</template>
|
||||
<template #report>
|
||||
<router-link
|
||||
class="underline"
|
||||
:to="{
|
||||
name: RouteName.REPORT,
|
||||
params: { reportId: log.object.id },
|
||||
}"
|
||||
>{{
|
||||
$t("report #{report_number}", {
|
||||
report_number: log.object.id,
|
||||
})
|
||||
}}
|
||||
</router-link>
|
||||
</template>
|
||||
</i18n-t>
|
||||
<i18n-t
|
||||
v-else-if="
|
||||
log.action === ActionLogAction.REPORT_UPDATE_RESOLVED
|
||||
"
|
||||
tag="span"
|
||||
keypath="{moderator} marked {report} as resolved"
|
||||
>
|
||||
<template #moderator>
|
||||
<router-link
|
||||
class="underline"
|
||||
:to="{
|
||||
name: RouteName.ADMIN_PROFILE,
|
||||
params: { id: log.actor.id },
|
||||
}"
|
||||
>{{ displayName(log.actor) }}</router-link
|
||||
>
|
||||
</template>
|
||||
<template #report>
|
||||
<router-link
|
||||
class="underline"
|
||||
:to="{
|
||||
name: RouteName.REPORT,
|
||||
params: { reportId: log.object.id },
|
||||
}"
|
||||
>{{
|
||||
$t("report #{report_number}", {
|
||||
report_number: log.object.id,
|
||||
})
|
||||
}}
|
||||
</router-link>
|
||||
</template>
|
||||
</i18n-t>
|
||||
<i18n-t
|
||||
v-else-if="log.action === ActionLogAction.NOTE_CREATION"
|
||||
tag="span"
|
||||
keypath="{moderator} added a note on {report}"
|
||||
>
|
||||
<template #moderator>
|
||||
<router-link
|
||||
class="underline"
|
||||
:to="{
|
||||
name: RouteName.ADMIN_PROFILE,
|
||||
params: { id: log.actor.id },
|
||||
}"
|
||||
>{{ displayName(log.actor) }}</router-link
|
||||
>
|
||||
</template>
|
||||
<template #report>
|
||||
<router-link
|
||||
class="underline"
|
||||
v-if="log.object.report"
|
||||
:to="{
|
||||
name: RouteName.REPORT,
|
||||
params: { reportId: log.object.report.id },
|
||||
}"
|
||||
>{{
|
||||
$t("report #{report_number}", {
|
||||
report_number: log.object.report.id,
|
||||
})
|
||||
}}
|
||||
</router-link>
|
||||
<span v-else>{{ $t("a non-existent report") }}</span>
|
||||
</template>
|
||||
</i18n-t>
|
||||
<i18n-t
|
||||
v-else-if="log.action === ActionLogAction.EVENT_DELETION"
|
||||
tag="span"
|
||||
keypath='{moderator} deleted an event named "{title}"'
|
||||
>
|
||||
<template #moderator>
|
||||
<router-link
|
||||
class="underline"
|
||||
:to="{
|
||||
name: RouteName.ADMIN_PROFILE,
|
||||
params: { id: log.actor.id },
|
||||
}"
|
||||
>{{ displayName(log.actor) }}</router-link
|
||||
>
|
||||
</template>
|
||||
<template #title>
|
||||
<b>{{ log.object.title }}</b>
|
||||
</template>
|
||||
</i18n-t>
|
||||
<i18n-t
|
||||
v-else-if="
|
||||
log.action === ActionLogAction.ACTOR_SUSPENSION &&
|
||||
log.object.__typename == 'Person'
|
||||
"
|
||||
tag="span"
|
||||
keypath="{moderator} suspended profile {profile}"
|
||||
>
|
||||
<template #moderator>
|
||||
<router-link
|
||||
class="underline"
|
||||
:to="{
|
||||
name: RouteName.ADMIN_PROFILE,
|
||||
params: { id: log.actor.id },
|
||||
}"
|
||||
>{{ displayName(log.actor) }}</router-link
|
||||
>
|
||||
</template>
|
||||
<template #profile>
|
||||
<router-link
|
||||
class="underline"
|
||||
:to="{
|
||||
name: RouteName.ADMIN_PROFILE,
|
||||
params: { id: log.object.id },
|
||||
}"
|
||||
>{{ displayNameAndUsername(log.object) }}
|
||||
</router-link>
|
||||
</template>
|
||||
</i18n-t>
|
||||
<i18n-t
|
||||
v-else-if="
|
||||
log.action === ActionLogAction.ACTOR_UNSUSPENSION &&
|
||||
log.object.__typename == 'Person'
|
||||
"
|
||||
tag="span"
|
||||
keypath="{moderator} has unsuspended profile {profile}"
|
||||
>
|
||||
<template #moderator>
|
||||
<router-link
|
||||
class="underline"
|
||||
:to="{
|
||||
name: RouteName.ADMIN_PROFILE,
|
||||
params: { id: log.actor.id },
|
||||
}"
|
||||
>{{ displayName(log.actor) }}</router-link
|
||||
>
|
||||
</template>
|
||||
<template #profile>
|
||||
<router-link
|
||||
class="underline"
|
||||
:to="{
|
||||
name: RouteName.ADMIN_PROFILE,
|
||||
params: { id: log.object.id },
|
||||
}"
|
||||
>{{ displayNameAndUsername(log.object) }}
|
||||
</router-link>
|
||||
</template>
|
||||
</i18n-t>
|
||||
<i18n-t
|
||||
v-else-if="
|
||||
log.action === ActionLogAction.ACTOR_SUSPENSION &&
|
||||
log.object.__typename == 'Group'
|
||||
"
|
||||
tag="span"
|
||||
keypath="{moderator} suspended group {profile}"
|
||||
>
|
||||
<template #moderator>
|
||||
<router-link
|
||||
class="underline"
|
||||
:to="{
|
||||
name: RouteName.ADMIN_PROFILE,
|
||||
params: { id: log.actor.id },
|
||||
}"
|
||||
>{{ displayName(log.actor) }}</router-link
|
||||
>
|
||||
</template>
|
||||
<template #profile>
|
||||
<router-link
|
||||
class="underline"
|
||||
:to="{
|
||||
name: RouteName.ADMIN_GROUP_PROFILE,
|
||||
params: { id: log.object.id },
|
||||
}"
|
||||
>{{ displayNameAndUsername(log.object) }}
|
||||
</router-link>
|
||||
</template>
|
||||
</i18n-t>
|
||||
<i18n-t
|
||||
v-else-if="
|
||||
log.action === ActionLogAction.ACTOR_UNSUSPENSION &&
|
||||
log.object.__typename == 'Group'
|
||||
"
|
||||
tag="span"
|
||||
keypath="{moderator} has unsuspended group {profile}"
|
||||
>
|
||||
<template #moderator>
|
||||
<router-link
|
||||
class="underline"
|
||||
:to="{
|
||||
name: RouteName.ADMIN_PROFILE,
|
||||
params: { id: log.actor.id },
|
||||
}"
|
||||
>{{ displayName(log.actor) }}</router-link
|
||||
>
|
||||
</template>
|
||||
<template #profile>
|
||||
<router-link
|
||||
class="underline"
|
||||
:to="{
|
||||
name: RouteName.ADMIN_GROUP_PROFILE,
|
||||
params: { id: log.object.id },
|
||||
}"
|
||||
>{{ displayNameAndUsername(log.object) }}
|
||||
</router-link>
|
||||
</template>
|
||||
</i18n-t>
|
||||
<i18n-t
|
||||
v-else-if="log.action === ActionLogAction.USER_DELETION"
|
||||
tag="span"
|
||||
keypath="{moderator} has deleted user {user}"
|
||||
>
|
||||
<template #moderator>
|
||||
<router-link
|
||||
class="underline"
|
||||
:to="{
|
||||
name: RouteName.ADMIN_PROFILE,
|
||||
params: { id: log.actor.id },
|
||||
}"
|
||||
>{{ displayName(log.actor) }}</router-link
|
||||
>
|
||||
</template>
|
||||
<template #user>
|
||||
<router-link
|
||||
class="underline"
|
||||
v-if="log.object.confirmedAt"
|
||||
:to="{
|
||||
name: RouteName.ADMIN_USER_PROFILE,
|
||||
params: { id: log.object.id },
|
||||
}"
|
||||
>{{ log.object.email }}
|
||||
</router-link>
|
||||
<b v-else>{{ log.object.email }}</b>
|
||||
</template>
|
||||
</i18n-t>
|
||||
<span
|
||||
v-else-if="
|
||||
log.action === ActionLogAction.COMMENT_DELETION &&
|
||||
log.object.event
|
||||
"
|
||||
>
|
||||
<i18n-t
|
||||
tag="span"
|
||||
keypath="{moderator} has deleted a comment from {author} under the event {event}"
|
||||
>
|
||||
<template #moderator>
|
||||
<router-link
|
||||
class="underline"
|
||||
:to="{
|
||||
name: RouteName.ADMIN_PROFILE,
|
||||
params: { id: log.actor.id },
|
||||
}"
|
||||
>{{ displayName(log.actor) }}</router-link
|
||||
>
|
||||
</template>
|
||||
<template #event>
|
||||
<router-link
|
||||
class="underline"
|
||||
v-if="log.object.event && log.object.event.uuid"
|
||||
:to="{
|
||||
name: RouteName.EVENT,
|
||||
params: { uuid: log.object.event.uuid },
|
||||
}"
|
||||
>{{ log.object.event.title }}
|
||||
</router-link>
|
||||
<b v-else>{{ log.object.event.title }}</b>
|
||||
</template>
|
||||
<template #author>
|
||||
<router-link
|
||||
class="underline"
|
||||
:to="{
|
||||
name: RouteName.ADMIN_PROFILE,
|
||||
params: { id: log.object.actor.id },
|
||||
}"
|
||||
>{{ displayNameAndUsername(log.object.actor) }}
|
||||
</router-link>
|
||||
</template>
|
||||
</i18n-t>
|
||||
<pre v-html="log.object.text" />
|
||||
</span>
|
||||
<span v-else-if="log.action === ActionLogAction.COMMENT_DELETION">
|
||||
<i18n-t
|
||||
tag="span"
|
||||
keypath="{moderator} has deleted a comment from {author}"
|
||||
>
|
||||
<template #moderator>
|
||||
<router-link
|
||||
class="underline"
|
||||
:to="{
|
||||
name: RouteName.ADMIN_PROFILE,
|
||||
params: { id: log.actor.id },
|
||||
}"
|
||||
>{{ displayName(log.actor) }}</router-link
|
||||
>
|
||||
</template>
|
||||
<template #author>
|
||||
<router-link
|
||||
class="underline"
|
||||
:to="{
|
||||
name: RouteName.ADMIN_PROFILE,
|
||||
params: { id: log.object.actor.id },
|
||||
}"
|
||||
>{{ displayNameAndUsername(log.object.actor) }}
|
||||
</router-link>
|
||||
</template>
|
||||
</i18n-t>
|
||||
<pre v-html="log.object.text" />
|
||||
</span>
|
||||
<i18n-t
|
||||
v-else
|
||||
tag="span"
|
||||
keypath="{moderator} has done an unknown action"
|
||||
>
|
||||
<template #moderator>
|
||||
<router-link
|
||||
class="underline"
|
||||
:to="{
|
||||
name: RouteName.ADMIN_PROFILE,
|
||||
params: { id: log.actor.id },
|
||||
}"
|
||||
>{{ displayName(log.actor) }}</router-link
|
||||
>
|
||||
</template>
|
||||
</i18n-t>
|
||||
<br />
|
||||
<small>{{ formatDateTimeString(log.insertedAt) }}</small>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
<o-pagination
|
||||
:total="actionLogs.total"
|
||||
v-model:current="page"
|
||||
:per-page="LOGS_PER_PAGE"
|
||||
:aria-next-label="$t('Next page')"
|
||||
:aria-previous-label="$t('Previous page')"
|
||||
:aria-page-label="$t('Page')"
|
||||
:aria-current-label="$t('Current page')"
|
||||
>
|
||||
</o-pagination>
|
||||
</section>
|
||||
<div v-else>
|
||||
<o-notification variant="info">{{
|
||||
$t("No moderation logs yet")
|
||||
}}</o-notification>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { IActionLog } from "@/types/report.model";
|
||||
import { LOGS } from "@/graphql/report";
|
||||
import { ActionLogAction } from "@/types/enums";
|
||||
import RouteName from "../../router/name";
|
||||
import { displayNameAndUsername, displayName } from "../../types/actor";
|
||||
import { Paginate } from "@/types/paginate";
|
||||
import { useQuery } from "@vue/apollo-composable";
|
||||
import { integerTransformer, useRouteQuery } from "vue-use-route-query";
|
||||
import { useHead } from "@vueuse/head";
|
||||
import { computed } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { formatDateTimeString } from "@/filters/datetime";
|
||||
import AccountCircle from "vue-material-design-icons/AccountCircle.vue";
|
||||
|
||||
const LOGS_PER_PAGE = 10;
|
||||
|
||||
const page = useRouteQuery("page", 1, integerTransformer);
|
||||
|
||||
const { result: actionLogsResult } = useQuery<{
|
||||
actionLogs: Paginate<IActionLog>;
|
||||
}>(LOGS, () => ({
|
||||
page: page.value,
|
||||
limit: LOGS_PER_PAGE,
|
||||
}));
|
||||
|
||||
const actionLogs = computed(
|
||||
() => actionLogsResult.value?.actionLogs ?? { total: 0, elements: [] }
|
||||
);
|
||||
|
||||
const { t } = useI18n({ useScope: "global" });
|
||||
|
||||
useHead({
|
||||
title: computed(() => t("Moderation logs")),
|
||||
});
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
img.image {
|
||||
display: inline-block;
|
||||
height: 1.5em;
|
||||
vertical-align: text-bottom;
|
||||
}
|
||||
|
||||
section ul li {
|
||||
margin: 0.5rem auto;
|
||||
}
|
||||
</style>
|
||||
160
src/views/Moderation/ReportListView.vue
Normal file
160
src/views/Moderation/ReportListView.vue
Normal file
@@ -0,0 +1,160 @@
|
||||
<template>
|
||||
<div>
|
||||
<breadcrumbs-nav
|
||||
:links="[
|
||||
{
|
||||
name: RouteName.MODERATION,
|
||||
text: t('Moderation'),
|
||||
},
|
||||
{
|
||||
name: RouteName.REPORTS,
|
||||
text: t('Reports'),
|
||||
},
|
||||
]"
|
||||
/>
|
||||
<section>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<o-field :label="t('Report status')">
|
||||
<o-radio v-model="status" :native-value="ReportStatusEnum.OPEN">{{
|
||||
t("Open")
|
||||
}}</o-radio>
|
||||
<o-radio v-model="status" :native-value="ReportStatusEnum.RESOLVED">{{
|
||||
t("Resolved")
|
||||
}}</o-radio>
|
||||
<o-radio v-model="status" :native-value="ReportStatusEnum.CLOSED">{{
|
||||
t("Closed")
|
||||
}}</o-radio>
|
||||
</o-field>
|
||||
<o-field
|
||||
:label="t('Domain')"
|
||||
label-for="domain-filter"
|
||||
class="flex-auto"
|
||||
>
|
||||
<o-input
|
||||
id="domain-filter"
|
||||
:placeholder="t('mobilizon-instance.tld')"
|
||||
:value="filterDomain"
|
||||
@input="debouncedUpdateDomainFilter"
|
||||
/>
|
||||
</o-field>
|
||||
</div>
|
||||
<ul v-if="reports.elements.length > 0">
|
||||
<li v-for="report in reports.elements" :key="report.id">
|
||||
<router-link
|
||||
:to="{ name: RouteName.REPORT, params: { reportId: report.id } }"
|
||||
>
|
||||
<report-card :report="report" />
|
||||
</router-link>
|
||||
</li>
|
||||
</ul>
|
||||
<div v-else class="no-reports">
|
||||
<empty-content
|
||||
icon="chat-alert"
|
||||
inline
|
||||
v-if="status === ReportStatusEnum.OPEN"
|
||||
>
|
||||
{{ t("No open reports yet") }}
|
||||
</empty-content>
|
||||
<empty-content
|
||||
icon="chat-alert"
|
||||
inline
|
||||
v-if="status === ReportStatusEnum.RESOLVED"
|
||||
>
|
||||
{{ t("No resolved reports yet") }}
|
||||
</empty-content>
|
||||
<empty-content
|
||||
icon="chat-alert"
|
||||
inline
|
||||
v-if="status === ReportStatusEnum.CLOSED"
|
||||
>
|
||||
{{ t("No closed reports yet") }}
|
||||
</empty-content>
|
||||
</div>
|
||||
<o-pagination
|
||||
:total="reports.total"
|
||||
v-model:current="page"
|
||||
:simple="true"
|
||||
:per-page="REPORT_PAGE_LIMIT"
|
||||
:aria-next-label="t('Next page')"
|
||||
:aria-previous-label="t('Previous page')"
|
||||
:aria-page-label="t('Page')"
|
||||
:aria-current-label="t('Current page')"
|
||||
>
|
||||
</o-pagination>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { IReport } from "@/types/report.model";
|
||||
import { REPORTS } from "@/graphql/report";
|
||||
import ReportCard from "@/components/Report/ReportCard.vue";
|
||||
import EmptyContent from "@/components/Utils/EmptyContent.vue";
|
||||
import { ReportStatusEnum } from "@/types/enums";
|
||||
import RouteName from "../../router/name";
|
||||
import { Paginate } from "@/types/paginate";
|
||||
import debounce from "lodash/debounce";
|
||||
import { useQuery } from "@vue/apollo-composable";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { useHead } from "@vueuse/head";
|
||||
import { computed } from "vue";
|
||||
import {
|
||||
enumTransformer,
|
||||
integerTransformer,
|
||||
useRouteQuery,
|
||||
} from "vue-use-route-query";
|
||||
|
||||
const REPORT_PAGE_LIMIT = 10;
|
||||
const page = useRouteQuery("page", 1, integerTransformer);
|
||||
const filterDomain = useRouteQuery("filterDomain", "");
|
||||
const status = useRouteQuery(
|
||||
"status",
|
||||
ReportStatusEnum.OPEN,
|
||||
enumTransformer(ReportStatusEnum)
|
||||
);
|
||||
|
||||
const { result: reportsResult } = useQuery<{ reports: Paginate<IReport> }>(
|
||||
REPORTS,
|
||||
() => ({
|
||||
page: page.value,
|
||||
status: status.value,
|
||||
limit: REPORT_PAGE_LIMIT,
|
||||
domain: filterDomain.value,
|
||||
}),
|
||||
{
|
||||
fetchPolicy: "cache-and-network",
|
||||
}
|
||||
);
|
||||
|
||||
const reports = computed(
|
||||
() => reportsResult.value?.reports ?? { elements: [], total: 0 }
|
||||
);
|
||||
|
||||
const { t } = useI18n({ useScope: "global" });
|
||||
|
||||
useHead({
|
||||
title: computed(() => t("Reports")),
|
||||
});
|
||||
|
||||
// const filterReports = ref<ReportStatusEnum>(ReportStatusEnum.OPEN);
|
||||
|
||||
const updateDomainFilter = (event: InputEvent) => {
|
||||
filterDomain.value = event.target?.value;
|
||||
};
|
||||
|
||||
const debouncedUpdateDomainFilter = debounce(updateDomainFilter, 500);
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
section {
|
||||
.no-reports {
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
& > ul li {
|
||||
margin: 0.5rem auto;
|
||||
|
||||
& > a {
|
||||
text-decoration: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
868
src/views/Moderation/ReportView.vue
Normal file
868
src/views/Moderation/ReportView.vue
Normal file
@@ -0,0 +1,868 @@
|
||||
<template>
|
||||
<breadcrumbs-nav
|
||||
v-if="report"
|
||||
:links="[
|
||||
{
|
||||
name: RouteName.MODERATION,
|
||||
text: t('Moderation'),
|
||||
},
|
||||
{
|
||||
name: RouteName.REPORTS,
|
||||
text: t('Reports'),
|
||||
},
|
||||
{
|
||||
name: RouteName.REPORT,
|
||||
params: { id: report.id },
|
||||
text: t('Report #{reportNumber}', { reportNumber: report.id }),
|
||||
},
|
||||
]"
|
||||
/>
|
||||
<o-notification
|
||||
title="Error"
|
||||
variant="danger"
|
||||
v-for="error in errors"
|
||||
:key="error"
|
||||
>
|
||||
{{ error }}
|
||||
</o-notification>
|
||||
<div class="container mx-auto" v-if="report">
|
||||
<div class="flex flex-wrap gap-2 my-2">
|
||||
<o-button
|
||||
v-if="report.status !== ReportStatusEnum.RESOLVED"
|
||||
@click="updateReport(ReportStatusEnum.RESOLVED)"
|
||||
variant="primary"
|
||||
>{{ t("Mark as resolved") }}</o-button
|
||||
>
|
||||
<o-button
|
||||
v-if="report.status !== ReportStatusEnum.OPEN"
|
||||
@click="updateReport(ReportStatusEnum.OPEN)"
|
||||
variant="success"
|
||||
>{{ t("Reopen") }}</o-button
|
||||
>
|
||||
<o-button
|
||||
v-if="report.status !== ReportStatusEnum.CLOSED"
|
||||
@click="updateReport(ReportStatusEnum.CLOSED)"
|
||||
variant="danger"
|
||||
>{{ t("Close") }}</o-button
|
||||
>
|
||||
<o-button
|
||||
v-if="antispamEnabled"
|
||||
outlined
|
||||
@click="reportToAntispam(true)"
|
||||
variant="text"
|
||||
class="!text-mbz-danger"
|
||||
>{{ t("Report as spam") }}</o-button
|
||||
>
|
||||
<o-button
|
||||
v-if="antispamEnabled"
|
||||
outlined
|
||||
@click="reportToAntispam(false)"
|
||||
variant="text"
|
||||
class="!text-mbz-success"
|
||||
>{{ t("Report as ham") }}</o-button
|
||||
>
|
||||
</div>
|
||||
<section class="w-full">
|
||||
<table class="table w-full">
|
||||
<tbody>
|
||||
<tr v-if="report.reported?.type === ActorType.GROUP">
|
||||
<td>{{ t("Reported group") }}</td>
|
||||
<td>
|
||||
<router-link
|
||||
:to="{
|
||||
name: RouteName.ADMIN_GROUP_PROFILE,
|
||||
params: { id: report.reported.id },
|
||||
}"
|
||||
>
|
||||
<img
|
||||
v-if="report.reported.avatar"
|
||||
class="image"
|
||||
:src="report.reported.avatar.url"
|
||||
alt=""
|
||||
/>
|
||||
{{ displayNameAndUsername(report.reported) }}
|
||||
</router-link>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-else-if="report.reported?.type === ActorType.PERSON">
|
||||
<td>
|
||||
{{ t("Reported identity") }}
|
||||
</td>
|
||||
<td class="flex items-center justify-between pr-6">
|
||||
<router-link
|
||||
:to="{
|
||||
name: RouteName.ADMIN_PROFILE,
|
||||
params: { id: report.reported.id },
|
||||
}"
|
||||
class="inline-flex gap-1"
|
||||
>
|
||||
<img
|
||||
v-if="report.reported.avatar"
|
||||
class="image rounded-full"
|
||||
:src="report.reported.avatar.url"
|
||||
alt=""
|
||||
/>
|
||||
<template v-if="report.reported.suspended">
|
||||
<i18n-t keypath="{profileName} (suspended)">
|
||||
<template #profileName>
|
||||
{{ displayNameAndUsername(report.reported) }}
|
||||
</template>
|
||||
</i18n-t>
|
||||
</template>
|
||||
<template v-else>{{
|
||||
displayNameAndUsername(report.reported)
|
||||
}}</template>
|
||||
</router-link>
|
||||
<o-button
|
||||
v-if="report.reported.domain && !report.reported.suspended"
|
||||
variant="danger"
|
||||
@click="suspendProfile(report.reported.id as string)"
|
||||
icon-left="delete"
|
||||
size="small"
|
||||
>{{ t("Suspend the profile") }}</o-button
|
||||
>
|
||||
<o-button
|
||||
v-else-if="
|
||||
(report.reported as IPerson).user &&
|
||||
!((report.reported as IPerson).user as IUser).disabled
|
||||
"
|
||||
variant="danger"
|
||||
@click="suspendUser((report.reported as IPerson).user as IUser)"
|
||||
icon-left="delete"
|
||||
size="small"
|
||||
>{{ t("Suspend the account") }}</o-button
|
||||
>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-else>
|
||||
<td>
|
||||
{{ t("Reported identity") }}
|
||||
</td>
|
||||
<td>
|
||||
{{ t("Unknown actor") }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{{ t("Reported by") }}</td>
|
||||
<td v-if="report.reporter?.type === ActorType.APPLICATION">
|
||||
{{ report.reporter.domain }}
|
||||
</td>
|
||||
<td v-else-if="report.reporter?.type === ActorType.PERSON">
|
||||
<router-link
|
||||
:to="{
|
||||
name: RouteName.ADMIN_PROFILE,
|
||||
params: { id: report.reporter.id },
|
||||
}"
|
||||
>
|
||||
<img
|
||||
v-if="report.reporter.avatar"
|
||||
class="image rounded-full"
|
||||
:src="report.reporter.avatar.url"
|
||||
alt=""
|
||||
/>
|
||||
{{ displayNameAndUsername(report.reporter) }}
|
||||
</router-link>
|
||||
</td>
|
||||
<td v-else>
|
||||
{{ t("Unknown actor") }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{{ t("Reported at") }}</td>
|
||||
<td>{{ formatDateTimeString(report.insertedAt) }}</td>
|
||||
</tr>
|
||||
<tr v-if="report.updatedAt !== report.insertedAt">
|
||||
<td>{{ t("Updated at") }}</td>
|
||||
<td>{{ formatDateTimeString(report.updatedAt) }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{{ t("Status") }}</td>
|
||||
<td>
|
||||
<span v-if="report.status === ReportStatusEnum.OPEN">{{
|
||||
t("Open")
|
||||
}}</span>
|
||||
<span v-else-if="report.status === ReportStatusEnum.CLOSED">
|
||||
{{ t("Closed") }}
|
||||
</span>
|
||||
<span v-else-if="report.status === ReportStatusEnum.RESOLVED">
|
||||
{{ t("Resolved") }}
|
||||
</span>
|
||||
<span v-else>{{ t("Unknown") }}</span>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
<section class="bg-white dark:bg-zinc-700 rounded px-2 pt-1 pb-2 my-3">
|
||||
<h2 class="mb-1">{{ t("Report reason") }}</h2>
|
||||
<div class="">
|
||||
<div class="flex gap-1">
|
||||
<figure class="" v-if="report.reported?.avatar">
|
||||
<img
|
||||
alt=""
|
||||
:src="report.reported.avatar.url"
|
||||
class="rounded-full"
|
||||
width="36"
|
||||
height="36"
|
||||
/>
|
||||
</figure>
|
||||
<AccountCircle v-else :size="36" />
|
||||
<div class="" v-if="report.reported">
|
||||
<p class="" v-if="report.reported?.name">
|
||||
{{ report.reported.name }}
|
||||
</p>
|
||||
<p class="">@{{ usernameWithDomain(report.reported) }}</p>
|
||||
</div>
|
||||
<p v-else>{{ t("Unknown actor") }}</p>
|
||||
</div>
|
||||
<div
|
||||
class="prose dark:prose-invert"
|
||||
v-if="report.content"
|
||||
v-html="nl2br(report.content)"
|
||||
/>
|
||||
<p v-else>{{ t("No comment") }}</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section
|
||||
class="bg-white dark:bg-zinc-700 rounded px-2 pt-1 pb-2 my-3"
|
||||
v-if="
|
||||
report.events &&
|
||||
report.events?.length > 0 &&
|
||||
report.comments.length === 0
|
||||
"
|
||||
>
|
||||
<h2 class="mb-1">{{ t("Reported content") }}</h2>
|
||||
<ul>
|
||||
<li v-for="event in report.events" :key="event.id">
|
||||
<EventCard :event="event" mode="row" class="my-2 max-w-4xl" />
|
||||
<o-button
|
||||
variant="danger"
|
||||
@click="confirmEventDelete(event)"
|
||||
icon-left="delete"
|
||||
><template v-if="isOnlyReportedContent">{{
|
||||
t("Delete event and resolve report")
|
||||
}}</template
|
||||
><template v-else>{{ t("Delete event") }}</template></o-button
|
||||
>
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<section
|
||||
class="bg-white dark:bg-zinc-700 rounded px-2 pt-1 pb-2 my-3"
|
||||
v-if="report.comments.length > 0"
|
||||
>
|
||||
<h2 class="mb-1">{{ t("Reported content") }}</h2>
|
||||
<ul v-for="comment in report.comments" :key="comment.id">
|
||||
<li>
|
||||
<template v-if="comment.conversation && comment.event">
|
||||
<i18n-t keypath="Comment from an event announcement" tag="p">
|
||||
<template #eventTitle>
|
||||
<router-link
|
||||
:to="{
|
||||
name: RouteName.EVENT,
|
||||
params: { uuid: comment.event?.uuid },
|
||||
}"
|
||||
>
|
||||
<b>{{ comment.event?.title }}</b>
|
||||
</router-link>
|
||||
</template>
|
||||
</i18n-t>
|
||||
<DiscussionComment
|
||||
:modelValue="comment"
|
||||
:current-actor="currentActor as IPerson"
|
||||
:readOnly="true"
|
||||
/>
|
||||
</template>
|
||||
<template v-else-if="comment.conversation">
|
||||
<i18n-t keypath="Comment from a private conversation" tag="p">
|
||||
<template #eventTitle>
|
||||
<router-link
|
||||
:to="{
|
||||
name: RouteName.EVENT,
|
||||
params: { uuid: comment.event?.uuid },
|
||||
}"
|
||||
>
|
||||
<b>{{ comment.event?.title }}</b>
|
||||
</router-link>
|
||||
</template>
|
||||
</i18n-t>
|
||||
<DiscussionComment
|
||||
:modelValue="comment"
|
||||
:current-actor="currentActor as IPerson"
|
||||
:readOnly="true"
|
||||
/>
|
||||
</template>
|
||||
<template v-else>
|
||||
<i18n-t keypath="Comment under event {eventTitle}" tag="p">
|
||||
<template #eventTitle>
|
||||
<router-link
|
||||
:to="{
|
||||
name: RouteName.EVENT,
|
||||
params: { uuid: comment.event?.uuid },
|
||||
}"
|
||||
>
|
||||
<b>{{ comment.event?.title }}</b>
|
||||
</router-link>
|
||||
</template>
|
||||
</i18n-t>
|
||||
<EventComment
|
||||
:root-comment="true"
|
||||
:comment="comment"
|
||||
:event="comment.event as IEvent"
|
||||
:current-actor="currentActor as IPerson"
|
||||
:readOnly="true"
|
||||
/>
|
||||
</template>
|
||||
<o-button
|
||||
v-if="!comment.deletedAt"
|
||||
variant="danger"
|
||||
@click="confirmCommentDelete(comment)"
|
||||
icon-left="delete"
|
||||
><template v-if="isOnlyReportedContent">{{
|
||||
t("Delete comment and resolve report")
|
||||
}}</template
|
||||
><template v-else>{{ t("Delete comment") }}</template></o-button
|
||||
>
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<section
|
||||
class="bg-white dark:bg-zinc-700 rounded px-2 pt-1 pb-2 my-3"
|
||||
v-if="
|
||||
report.events &&
|
||||
report.events?.length === 0 &&
|
||||
report.comments.length === 0
|
||||
"
|
||||
>
|
||||
<EmptyContent inline center icon="alert-circle">
|
||||
{{ t("No content found") }}
|
||||
<template #desc>
|
||||
{{ t("Maybe the content was removed by the author or a moderator") }}
|
||||
</template>
|
||||
</EmptyContent>
|
||||
</section>
|
||||
|
||||
<section class="bg-white dark:bg-zinc-700 rounded px-2 pt-1 pb-2 my-3">
|
||||
<h2 class="mb-1">{{ t("Notes") }}</h2>
|
||||
<div
|
||||
class=""
|
||||
v-for="note in report.notes"
|
||||
:id="`note-${note.id}`"
|
||||
:key="note.id"
|
||||
>
|
||||
<p>{{ note.content }}</p>
|
||||
<router-link
|
||||
:to="{
|
||||
name: RouteName.ADMIN_PROFILE,
|
||||
params: { id: note.moderator.id },
|
||||
}"
|
||||
>
|
||||
<img
|
||||
alt=""
|
||||
class="rounded-full"
|
||||
:src="note.moderator.avatar.url"
|
||||
v-if="note.moderator.avatar"
|
||||
/>
|
||||
@{{ note.moderator.preferredUsername }}
|
||||
</router-link>
|
||||
<br />
|
||||
<small>
|
||||
<a :href="`#note-${note.id}`" v-if="note.insertedAt">
|
||||
{{ formatDateTimeString(note.insertedAt) }}
|
||||
</a>
|
||||
</small>
|
||||
</div>
|
||||
|
||||
<form
|
||||
@submit="
|
||||
createReportNoteMutation({
|
||||
reportId: report?.id,
|
||||
content: noteContent,
|
||||
})
|
||||
"
|
||||
>
|
||||
<o-field :label="t('New note')" label-for="newNoteInput">
|
||||
<o-input
|
||||
type="textarea"
|
||||
v-model="noteContent"
|
||||
id="newNoteInput"
|
||||
></o-input>
|
||||
</o-field>
|
||||
<o-button class="mt-2" type="submit">{{ t("Add a note") }}</o-button>
|
||||
</form>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { CREATE_REPORT_NOTE, REPORT, UPDATE_REPORT } from "@/graphql/report";
|
||||
import { IReport, IReportNote } from "@/types/report.model";
|
||||
import {
|
||||
IPerson,
|
||||
displayNameAndUsername,
|
||||
usernameWithDomain,
|
||||
} from "@/types/actor";
|
||||
import { DELETE_EVENT } from "@/graphql/event";
|
||||
import uniq from "lodash/uniq";
|
||||
import { nl2br } from "@/utils/html";
|
||||
import { DELETE_COMMENT } from "@/graphql/comment";
|
||||
import { IComment } from "@/types/comment.model";
|
||||
import { ActorType, AntiSpamFeedback, ReportStatusEnum } from "@/types/enums";
|
||||
import RouteName from "@/router/name";
|
||||
import { GraphQLError } from "graphql";
|
||||
import { ApolloCache, FetchResult } from "@apollo/client/core";
|
||||
import { useLazyQuery, useMutation, useQuery } from "@vue/apollo-composable";
|
||||
import { useCurrentActorClient } from "@/composition/apollo/actor";
|
||||
import { useHead } from "@vueuse/head";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { useRouter } from "vue-router";
|
||||
import { ref, computed, inject } from "vue";
|
||||
import { formatDateTimeString } from "@/filters/datetime";
|
||||
import AccountCircle from "vue-material-design-icons/AccountCircle.vue";
|
||||
import { Dialog } from "@/plugins/dialog";
|
||||
import { Notifier } from "@/plugins/notifier";
|
||||
import EventCard from "@/components/Event/EventCard.vue";
|
||||
import { useFeatures } from "@/composition/apollo/config";
|
||||
import { IEvent } from "@/types/event.model";
|
||||
import EmptyContent from "@/components/Utils/EmptyContent.vue";
|
||||
import EventComment from "@/components/Comment/EventComment.vue";
|
||||
import DiscussionComment from "@/components/Discussion/DiscussionComment.vue";
|
||||
import { SUSPEND_PROFILE } from "@/graphql/actor";
|
||||
import { GET_USER, SUSPEND_USER } from "@/graphql/user";
|
||||
import { IUser } from "@/types/current-user.model";
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
const props = defineProps<{ reportId: string }>();
|
||||
|
||||
const { currentActor } = useCurrentActorClient();
|
||||
|
||||
const { features } = useFeatures();
|
||||
|
||||
const antispamEnabled = computed(() => features.value?.antispam);
|
||||
|
||||
const { result: reportResult, onError: onReportQueryError } = useQuery<{
|
||||
report: IReport;
|
||||
}>(REPORT, () => ({
|
||||
id: props.reportId,
|
||||
}));
|
||||
|
||||
const report = computed(() => reportResult.value?.report);
|
||||
|
||||
onReportQueryError(({ graphQLErrors }) => {
|
||||
errors.value = uniq(
|
||||
graphQLErrors.map(({ message }: GraphQLError) => message)
|
||||
);
|
||||
});
|
||||
|
||||
const { t } = useI18n({ useScope: "global" });
|
||||
|
||||
useHead({
|
||||
title: computed(() => t("Report")),
|
||||
});
|
||||
|
||||
const notifier = inject<Notifier>("notifier");
|
||||
|
||||
const errors = ref<string[]>([]);
|
||||
|
||||
const noteContent = ref("");
|
||||
|
||||
const reportedContent = computed(() => {
|
||||
return [...(report.value?.events ?? []), ...(report.value?.comments ?? [])];
|
||||
});
|
||||
|
||||
const isOnlyReportedContent = computed(
|
||||
() => reportedContent.value.length === 1
|
||||
);
|
||||
|
||||
const {
|
||||
mutate: createReportNoteMutation,
|
||||
onDone: createReportNoteMutationDone,
|
||||
onError: createReportNoteMutationError,
|
||||
} = useMutation<{
|
||||
createReportNote: IReportNote;
|
||||
}>(CREATE_REPORT_NOTE, () => ({
|
||||
update: (
|
||||
store: ApolloCache<{ createReportNote: IReportNote }>,
|
||||
{ data }: FetchResult
|
||||
) => {
|
||||
if (data == null) return;
|
||||
const cachedData = store.readQuery<{ report: IReport }>({
|
||||
query: REPORT,
|
||||
variables: { id: report.value?.id },
|
||||
});
|
||||
if (cachedData == null) return;
|
||||
const { report: cachedReport } = cachedData;
|
||||
if (cachedReport === null) {
|
||||
console.error("Cannot update event notes cache, because of null value.");
|
||||
return;
|
||||
}
|
||||
const note = data.createReportNote;
|
||||
note.moderator = currentActor.value;
|
||||
|
||||
cachedReport.notes = cachedReport.notes.concat([note]);
|
||||
|
||||
store.writeQuery({
|
||||
query: REPORT,
|
||||
variables: { id: report.value?.id },
|
||||
data: { report },
|
||||
});
|
||||
},
|
||||
}));
|
||||
|
||||
createReportNoteMutationDone(() => {
|
||||
noteContent.value = "";
|
||||
});
|
||||
|
||||
createReportNoteMutationError((error) => {
|
||||
console.error(error);
|
||||
});
|
||||
|
||||
const dialog = inject<Dialog>("dialog");
|
||||
|
||||
const addResolveReportPart = computed(() => {
|
||||
if (isOnlyReportedContent.value) {
|
||||
return "<p>" + t("This will also resolve the report.") + "</p>";
|
||||
}
|
||||
return "";
|
||||
});
|
||||
|
||||
const confirmEventDelete = (event: IEvent): void => {
|
||||
dialog?.confirm({
|
||||
title: t("Deleting event"),
|
||||
message:
|
||||
t(
|
||||
"Are you sure you want to <b>delete</b> this event? <b>This action cannot be undone</b>. You may want to engage the discussion with the event creator and ask them to edit their event instead."
|
||||
) + addResolveReportPart.value,
|
||||
confirmText: isOnlyReportedContent.value
|
||||
? t("Delete event and resolve report")
|
||||
: t("Delete event"),
|
||||
variant: "danger",
|
||||
hasIcon: true,
|
||||
onConfirm: () => deleteEvent(event),
|
||||
});
|
||||
};
|
||||
|
||||
const confirmCommentDelete = (comment: IComment): void => {
|
||||
dialog?.confirm({
|
||||
title: t("Deleting comment"),
|
||||
message:
|
||||
t(
|
||||
"Are you sure you want to <b>delete</b> this comment? <b>This action cannot be undone</b>."
|
||||
) + addResolveReportPart.value,
|
||||
confirmText: isOnlyReportedContent.value
|
||||
? t("Delete comment and resolve report")
|
||||
: t("Delete comment"),
|
||||
variant: "danger",
|
||||
hasIcon: true,
|
||||
onConfirm: () => deleteCommentMutation({ commentId: comment.id }),
|
||||
});
|
||||
};
|
||||
|
||||
const {
|
||||
mutate: deleteEventMutation,
|
||||
onDone: deleteEventMutationDone,
|
||||
onError: deleteEventMutationError,
|
||||
} = useMutation<{ deleteEvent: { id: string } }>(DELETE_EVENT, () => ({
|
||||
update: (
|
||||
store: ApolloCache<{ deleteEvent: { id: string } }>,
|
||||
{ data }: FetchResult
|
||||
) => {
|
||||
if (data == null) return;
|
||||
const reportCachedData = store.readQuery<{ report: IReport }>({
|
||||
query: REPORT,
|
||||
variables: { id: report.value?.id },
|
||||
});
|
||||
if (reportCachedData == null) return;
|
||||
const { report: cachedReport } = reportCachedData;
|
||||
if (cachedReport === null) {
|
||||
console.error(
|
||||
"Cannot update report events cache, because of null value."
|
||||
);
|
||||
return;
|
||||
}
|
||||
const updatedReport = {
|
||||
...cachedReport,
|
||||
events: cachedReport.events?.filter(
|
||||
(cachedEvent) => cachedEvent.id !== data.deleteEvent.id
|
||||
),
|
||||
};
|
||||
|
||||
store.writeQuery({
|
||||
query: REPORT,
|
||||
variables: { id: report.value?.id },
|
||||
data: { report: updatedReport },
|
||||
});
|
||||
},
|
||||
}));
|
||||
|
||||
deleteEventMutationDone(async () => {
|
||||
if (reportedContent.value.length === 0) {
|
||||
await updateReport(ReportStatusEnum.RESOLVED);
|
||||
notifier?.success(t("Event deleted and report resolved"));
|
||||
} else {
|
||||
notifier?.success(t("Event deleted"));
|
||||
}
|
||||
});
|
||||
|
||||
deleteEventMutationError((error) => {
|
||||
console.error(error);
|
||||
});
|
||||
|
||||
const deleteEvent = async (event: IEvent): Promise<void> => {
|
||||
if (!event?.id) return;
|
||||
|
||||
deleteEventMutation(
|
||||
{ eventId: event.id },
|
||||
{ context: { eventTitle: event.title } }
|
||||
);
|
||||
};
|
||||
|
||||
const {
|
||||
mutate: deleteCommentMutation,
|
||||
onDone: deleteCommentMutationDone,
|
||||
onError: deleteCommentMutationError,
|
||||
} = useMutation<{ deleteComment: { id: string } }>(DELETE_COMMENT, () => ({
|
||||
update: (
|
||||
store: ApolloCache<{ deleteComment: { id: string } }>,
|
||||
{ data }: FetchResult
|
||||
) => {
|
||||
if (data == null) return;
|
||||
const reportCachedData = store.readQuery<{ report: IReport }>({
|
||||
query: REPORT,
|
||||
variables: { id: report.value?.id },
|
||||
});
|
||||
if (reportCachedData == null) return;
|
||||
const { report: cachedReport } = reportCachedData;
|
||||
if (cachedReport === null) {
|
||||
console.error(
|
||||
"Cannot update report comments cache, because of null value."
|
||||
);
|
||||
return;
|
||||
}
|
||||
const updatedReport = {
|
||||
...cachedReport,
|
||||
comments: cachedReport.comments.filter(
|
||||
(cachedComment) => cachedComment.id !== data.deleteComment.id
|
||||
),
|
||||
};
|
||||
|
||||
store.writeQuery({
|
||||
query: REPORT,
|
||||
variables: { id: report.value?.id },
|
||||
data: { report: updatedReport },
|
||||
});
|
||||
},
|
||||
}));
|
||||
|
||||
deleteCommentMutationDone(async () => {
|
||||
if (reportedContent.value.length === 0) {
|
||||
await updateReport(ReportStatusEnum.RESOLVED);
|
||||
notifier?.success(t("Comment deleted and report resolved"));
|
||||
} else {
|
||||
notifier?.success(t("Comment deleted"));
|
||||
}
|
||||
});
|
||||
|
||||
deleteCommentMutationError((error) => {
|
||||
console.error(error);
|
||||
});
|
||||
|
||||
const {
|
||||
mutate: updateReportMutation,
|
||||
onDone: onUpdateReportMutation,
|
||||
onError: onUpdateReportError,
|
||||
} = useMutation<
|
||||
Record<string, any>,
|
||||
{
|
||||
reportId: string;
|
||||
status: ReportStatusEnum;
|
||||
antispamFeedback?: AntiSpamFeedback;
|
||||
}
|
||||
>(UPDATE_REPORT, () => ({
|
||||
update: (
|
||||
store: ApolloCache<{ updateReportStatus: IReport }>,
|
||||
{ data }: FetchResult
|
||||
) => {
|
||||
if (data == null) return;
|
||||
const reportCachedData = store.readQuery<{ report: IReport }>({
|
||||
query: REPORT,
|
||||
variables: { id: report.value?.id },
|
||||
});
|
||||
if (reportCachedData == null) return;
|
||||
const { report: cachedReport } = reportCachedData;
|
||||
if (cachedReport === null) {
|
||||
console.error("Cannot update event notes cache, because of null value.");
|
||||
return;
|
||||
}
|
||||
const updatedReport = {
|
||||
...cachedReport,
|
||||
status: data.updateReportStatus.status,
|
||||
};
|
||||
|
||||
store.writeQuery({
|
||||
query: REPORT,
|
||||
variables: { id: report.value?.id },
|
||||
data: { report: updatedReport },
|
||||
});
|
||||
},
|
||||
}));
|
||||
|
||||
onUpdateReportMutation(async () => {
|
||||
await router.push({ name: RouteName.REPORTS });
|
||||
});
|
||||
|
||||
onUpdateReportError((error) => {
|
||||
console.error(error);
|
||||
});
|
||||
|
||||
const updateReport = async (status: ReportStatusEnum): Promise<void> => {
|
||||
if (report.value) {
|
||||
updateReportMutation({
|
||||
reportId: report.value?.id,
|
||||
status,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const reportToAntispam = (spam: boolean) => {
|
||||
dialog?.confirm({
|
||||
title: spam ? t("Report as undetected spam") : t("Report as ham"),
|
||||
message: t(
|
||||
"The report contents (eventual comments and event) and the reported profile details will be transmitted to Akismet."
|
||||
),
|
||||
confirmText: t("Submit to Akismet"),
|
||||
variant: "warning",
|
||||
hasIcon: true,
|
||||
onConfirm: () => {
|
||||
if (report.value) {
|
||||
updateReportMutation({
|
||||
reportId: report.value.id,
|
||||
status: report.value.status,
|
||||
antispamFeedback: spam ? AntiSpamFeedback.SPAM : AntiSpamFeedback.HAM,
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const { mutate: doSuspendProfile, onDone: onSuspendProfileDone } = useMutation<
|
||||
{
|
||||
suspendProfile: { id: string };
|
||||
},
|
||||
{ id: string }
|
||||
>(SUSPEND_PROFILE);
|
||||
|
||||
const { mutate: doSuspendUser, onDone: onSuspendUserDone } = useMutation<
|
||||
{ suspendProfile: { id: string } },
|
||||
{ userId: string }
|
||||
>(SUSPEND_USER);
|
||||
|
||||
const { load: loadUserLazyQuery } = useLazyQuery<
|
||||
{ user: IUser },
|
||||
{ id: string }
|
||||
>(GET_USER);
|
||||
|
||||
const suspendProfile = async (actorId: string): Promise<void> => {
|
||||
dialog?.confirm({
|
||||
title: t("Suspend the profile?"),
|
||||
message:
|
||||
t(
|
||||
"Do you really want to suspend this profile? All of the profiles content will be deleted."
|
||||
) +
|
||||
`<p><b>` +
|
||||
t("There will be no way to restore the profile's data!") +
|
||||
`</b></p>`,
|
||||
confirmText: t("Suspend the profile"),
|
||||
cancelText: t("Cancel"),
|
||||
variant: "danger",
|
||||
onConfirm: async () => {
|
||||
doSuspendProfile({
|
||||
id: actorId,
|
||||
});
|
||||
return router.push({ name: RouteName.USERS });
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const userSuspendedProfilesMessages = (user: IUser) => {
|
||||
return (
|
||||
t("The following user's profiles will be deleted, with all their data:") +
|
||||
`<ul class="list-disc pl-3">` +
|
||||
user.actors
|
||||
.map((person) => `<li>${displayNameAndUsername(person)}</li>`)
|
||||
.join("") +
|
||||
`</ul><b>`
|
||||
);
|
||||
};
|
||||
|
||||
const cachedReportedUser = ref<IUser | undefined>();
|
||||
|
||||
const suspendUser = async (user: IUser): Promise<void> => {
|
||||
try {
|
||||
if (!cachedReportedUser.value) {
|
||||
try {
|
||||
const result = await loadUserLazyQuery(GET_USER, { id: user.id });
|
||||
if (!result) return;
|
||||
cachedReportedUser.value = result.user;
|
||||
} catch (e) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
dialog?.confirm({
|
||||
title: t("Suspend the account?"),
|
||||
message:
|
||||
t("Do you really want to suspend the account « {emailAccount} » ?", {
|
||||
emailAccount: cachedReportedUser.value.email,
|
||||
}) +
|
||||
" " +
|
||||
userSuspendedProfilesMessages(cachedReportedUser.value) +
|
||||
"<b>" +
|
||||
t("There will be no way to restore the user's data!") +
|
||||
`</b>`,
|
||||
confirmText: t("Suspend the account"),
|
||||
cancelText: t("Cancel"),
|
||||
variant: "danger",
|
||||
onConfirm: async () => {
|
||||
doSuspendUser({
|
||||
userId: user.id,
|
||||
});
|
||||
return router.push({ name: RouteName.USERS });
|
||||
},
|
||||
});
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
};
|
||||
|
||||
onSuspendUserDone(async () => {
|
||||
await router.push({ name: RouteName.REPORTS });
|
||||
notifier?.success(t("User suspended and report resolved"));
|
||||
});
|
||||
|
||||
onSuspendProfileDone(async () => {
|
||||
await router.push({ name: RouteName.REPORTS });
|
||||
notifier?.success(t("Profile suspended and report resolved"));
|
||||
});
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
tbody td img.image,
|
||||
.note img.image {
|
||||
display: inline;
|
||||
height: 1.5em;
|
||||
vertical-align: text-bottom;
|
||||
}
|
||||
|
||||
.dialog .modal-card-foot {
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.box a {
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user