diff --git a/packages/backend/src/server/api/endpoints/admin/abuse-report-resolver/create.ts b/packages/backend/src/server/api/endpoints/admin/abuse-report-resolver/create.ts index 76a0f3ad19..d6f98d30c3 100644 --- a/packages/backend/src/server/api/endpoints/admin/abuse-report-resolver/create.ts +++ b/packages/backend/src/server/api/endpoints/admin/abuse-report-resolver/create.ts @@ -108,15 +108,15 @@ export default class extends Endpoint { } const now = new Date(); let expirationDate: Date | null = new Date(); - + const previousMonth = expirationDate.getUTCMonth(); (ps.expiresAt === '1hour' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('1 hour')); } : ps.expiresAt === '12hours' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('12 hours')); } : ps.expiresAt === '1day' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('1 day')); } : ps.expiresAt === '1week' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('1 week')); } : - ps.expiresAt === '1month' ? function () { expirationDate!.setUTCMonth((expirationDate!.getUTCMonth() + 1 + 1) % 12 - 1); expirationDate!.setUTCFullYear(expirationDate!.getUTCFullYear() + (Math.floor((expirationDate!.getUTCMonth() + 1 + 1) / 12))); } : - ps.expiresAt === '3months' ? function () {expirationDate!.setUTCMonth((expirationDate!.getUTCMonth() + 3 + 1) % 12 - 1); expirationDate!.setUTCFullYear(expirationDate!.getUTCFullYear() + (Math.floor((expirationDate!.getUTCMonth() + 3 + 1) / 12 ))); } : - ps.expiresAt === '6months' ? function () { expirationDate!.setUTCMonth((expirationDate!.getUTCMonth() + 6 + 1) % 12 - 1); expirationDate!.setUTCFullYear(expirationDate!.getUTCFullYear() + (Math.floor((expirationDate!.getUTCMonth() + 6 + 1) / 12))); } : - ps.expiresAt === '1year' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('1 year')); } : function () { expirationDate = null; })(); + ps.expiresAt === '1month' ? function () { expirationDate!.setUTCMonth((expirationDate!.getUTCMonth() + 1 + 1) % 12 - 1); expirationDate!.setUTCFullYear(expirationDate!.getUTCFullYear() + (Math.floor((previousMonth + 1 + 1) / 12))); } : + ps.expiresAt === '3months' ? function () {expirationDate!.setUTCMonth((expirationDate!.getUTCMonth() + 3 + 1) % 12 - 1); expirationDate!.setUTCFullYear(expirationDate!.getUTCFullYear() + (Math.floor((previousMonth + 3 + 1) / 12))); } : + ps.expiresAt === '6months' ? function () { expirationDate!.setUTCMonth((expirationDate!.getUTCMonth() + 6 + 1) % 12 - 1); expirationDate!.setUTCFullYear(expirationDate!.getUTCFullYear() + (Math.floor((previousMonth + 6 + 1) / 12))); } : + ps.expiresAt === '1year' ? function () { expirationDate!.setUTCFullYear(expirationDate!.getUTCFullYear() + 1); } : function () { expirationDate = null; })(); return await this.abuseReportResolverRepository.insert({ id: this.idService.genId(), diff --git a/packages/backend/src/server/api/endpoints/admin/abuse-report-resolver/update.ts b/packages/backend/src/server/api/endpoints/admin/abuse-report-resolver/update.ts index f4c70a849c..4d8297429b 100644 --- a/packages/backend/src/server/api/endpoints/admin/abuse-report-resolver/update.ts +++ b/packages/backend/src/server/api/endpoints/admin/abuse-report-resolver/update.ts @@ -95,14 +95,15 @@ export default class extends Endpoint { if (ps.forward) properties.forward = ps.forward; if (ps.expiresAt) { let expirationDate: Date | null = new Date(); + const previousMonth = expirationDate.getUTCMonth(); (ps.expiresAt === '1hour' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('1 hour')); } : ps.expiresAt === '12hours' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('12 hours')); } : ps.expiresAt === '1day' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('1 day')); } : ps.expiresAt === '1week' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('1 week')); } : - ps.expiresAt === '1month' ? function () { expirationDate!.setUTCMonth((expirationDate!.getUTCMonth() + 1 + 1) % 12 - 1); expirationDate!.setUTCFullYear(expirationDate!.getUTCFullYear() + (Math.floor((expirationDate!.getUTCMonth() + 1 + 1) / 12))); } : - ps.expiresAt === '3months' ? function () {expirationDate!.setUTCMonth((expirationDate!.getUTCMonth() + 3 + 1) % 12 - 1); expirationDate!.setUTCFullYear(expirationDate!.getUTCFullYear() + (Math.floor((expirationDate!.getUTCMonth() + 3 + 1) / 12))); } : - ps.expiresAt === '6months' ? function () { expirationDate!.setUTCMonth((expirationDate!.getUTCMonth() + 6 + 1) % 12 - 1); expirationDate!.setUTCFullYear(expirationDate!.getUTCFullYear() + (Math.floor((expirationDate!.getUTCMonth() + 6 + 1) / 12))); } : - ps.expiresAt === '1year' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('1 year')); } : function () { expirationDate = null; })(); + ps.expiresAt === '1month' ? function () { expirationDate!.setUTCMonth((expirationDate!.getUTCMonth() + 1 + 1) % 12 - 1); expirationDate!.setUTCFullYear(expirationDate!.getUTCFullYear() + (Math.floor((previousMonth + 1 + 1) / 12))); } : + ps.expiresAt === '3months' ? function () {expirationDate!.setUTCMonth((expirationDate!.getUTCMonth() + 3 + 1) % 12 - 1); expirationDate!.setUTCFullYear(expirationDate!.getUTCFullYear() + (Math.floor((previousMonth + 3 + 1) / 12))); } : + ps.expiresAt === '6months' ? function () { expirationDate!.setUTCMonth((expirationDate!.getUTCMonth() + 6 + 1) % 12 - 1); expirationDate!.setUTCFullYear(expirationDate!.getUTCFullYear() + (Math.floor((previousMonth + 6 + 1) / 12))); } : + ps.expiresAt === '1year' ? function () { expirationDate!.setUTCFullYear(expirationDate!.getUTCFullYear() + 1); } : function () { expirationDate = null; })(); properties.expiresAt = ps.expiresAt; properties.expirationDate = expirationDate; diff --git a/packages/frontend/src/components/MkAbuseReportResolver.vue b/packages/frontend/src/components/MkAbuseReportResolver.vue index a3a50b2ea0..6b181f3e06 100644 --- a/packages/frontend/src/components/MkAbuseReportResolver.vue +++ b/packages/frontend/src/components/MkAbuseReportResolver.vue @@ -5,18 +5,18 @@
{{ i18n.ts._abuse._resolver.targetUserPattern }}
- +
{{ i18n.ts._abuse._resolver.reporterPattern }}
- +
{{ i18n.ts._abuse._resolver.reportContentPattern }}
- +
- + @@ -70,7 +70,7 @@ const props = defineProps<{ previousExpiresAt?: string; } }>(); -let expirationDate: string | null = $ref(null); +let expirationDate: Date | null = $ref(null); type NonNullType = { [P in keyof T]: NonNullable @@ -113,7 +113,7 @@ function highlighter(code) { function renderExpirationDate(empty = false) { if (value.value.expirationDate && !empty) { - expirationDate = new Date(value.value.expirationDate).toLocaleString(); + expirationDate = new Date(value.value.expirationDate); } else { expirationDate = null; } diff --git a/packages/frontend/src/pages/admin/abuses.vue b/packages/frontend/src/pages/admin/abuses.vue index f55de26449..86113d6b7c 100644 --- a/packages/frontend/src/pages/admin/abuses.vue +++ b/packages/frontend/src/pages/admin/abuses.vue @@ -57,7 +57,7 @@