mirror of
https://github.com/kokonect-link/cherrypick
synced 2024-12-13 06:08:58 +09:00
Fix: 有効期限を指定するアルゴリズムが間違っていたのを修正
This commit is contained in:
parent
2134a79353
commit
7c7ca57bd7
@ -108,14 +108,15 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
|||||||
const now = new Date();
|
const now = new Date();
|
||||||
let expirationDate: Date | null = 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 === '1hour' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('1 hour')); } :
|
||||||
ps.expiresAt === '12hours' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('12 hours')); } :
|
ps.expiresAt === '12hours' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('12 hours')); } :
|
||||||
ps.expiresAt === '1day' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('1 day')); } :
|
ps.expiresAt === '1day' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('1 day')); } :
|
||||||
ps.expiresAt === '1week' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('1 week')); } :
|
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 === '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((expirationDate!.getUTCMonth() + 3 + 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((expirationDate!.getUTCMonth() + 6 + 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!.setTime(expirationDate!.getTime() + ms('1 year')); } : function () { expirationDate = null; })();
|
ps.expiresAt === '1year' ? function () { expirationDate!.setUTCFullYear(expirationDate!.getFullYear() + 1); } : function () { expirationDate = null; })();
|
||||||
|
|
||||||
return await this.abuseReportResolverRepository.insert({
|
return await this.abuseReportResolverRepository.insert({
|
||||||
id: this.idService.genId(),
|
id: this.idService.genId(),
|
||||||
|
@ -94,14 +94,15 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
|||||||
if (ps.forward) properties.forward = ps.forward;
|
if (ps.forward) properties.forward = ps.forward;
|
||||||
if (ps.expiresAt) {
|
if (ps.expiresAt) {
|
||||||
let expirationDate: Date | null = 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 === '1hour' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('1 hour')); } :
|
||||||
ps.expiresAt === '12hours' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('12 hours')); } :
|
ps.expiresAt === '12hours' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('12 hours')); } :
|
||||||
ps.expiresAt === '1day' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('1 day')); } :
|
ps.expiresAt === '1day' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('1 day')); } :
|
||||||
ps.expiresAt === '1week' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('1 week')); } :
|
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 === '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((expirationDate!.getUTCMonth() + 3 + 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((expirationDate!.getUTCMonth() + 6 + 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!.setTime(expirationDate!.getTime() + ms('1 year')); } : function () { expirationDate = null; })();
|
ps.expiresAt === '1year' ? function () { expirationDate!.setUTCFullYear(expirationDate!.getFullYear() + 1); } : function () { expirationDate = null; })();
|
||||||
|
|
||||||
properties.expiresAt = ps.expiresAt;
|
properties.expiresAt = ps.expiresAt;
|
||||||
properties.expirationDate = expirationDate;
|
properties.expirationDate = expirationDate;
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
<PrismEditor v-model="value.reportContentPattern" class="_code code" :class="$style.highlight" :highlight="highlighter" :lineNumbers="false" :readonly="!props.editable"/>
|
<PrismEditor v-model="value.reportContentPattern" class="_code code" :class="$style.highlight" :highlight="highlighter" :lineNumbers="false" :readonly="!props.editable"/>
|
||||||
</div>
|
</div>
|
||||||
<MkSelect v-model="value.expiresAt" :disabled="!props.editable">
|
<MkSelect v-model="value.expiresAt" :disabled="!props.editable">
|
||||||
<template #label>{{ i18n.ts._abuse._resolver.expiresAt }}<span v-if="expirationDate" style="float: right;">{{ expirationDate }}</span></template>
|
<template #label>{{ i18n.ts._abuse._resolver.expiresAt }}<span v-if="expirationDate" style="float: right;"><MkDate :time="expirationDate" mode="absolute">{{ expirationDate }}</MkDate></span></template>
|
||||||
<option value="1hour">{{ i18n.ts._abuse._resolver['1hour'] }}</option>
|
<option value="1hour">{{ i18n.ts._abuse._resolver['1hour'] }}</option>
|
||||||
<option value="12hours">{{ i18n.ts._abuse._resolver['12hours'] }}</option>
|
<option value="12hours">{{ i18n.ts._abuse._resolver['12hours'] }}</option>
|
||||||
<option value="1day">{{ i18n.ts._abuse._resolver['1day'] }}</option>
|
<option value="1day">{{ i18n.ts._abuse._resolver['1day'] }}</option>
|
||||||
@ -70,7 +70,7 @@ const props = defineProps<{
|
|||||||
previousExpiresAt?: string;
|
previousExpiresAt?: string;
|
||||||
}
|
}
|
||||||
}>();
|
}>();
|
||||||
let expirationDate: string | null = $ref(null);
|
let expirationDate: Date | null = $ref(null);
|
||||||
|
|
||||||
type NonNullType<T> = {
|
type NonNullType<T> = {
|
||||||
[P in keyof T]: NonNullable<T[P]>
|
[P in keyof T]: NonNullable<T[P]>
|
||||||
@ -113,7 +113,7 @@ function highlighter(code) {
|
|||||||
|
|
||||||
function renderExpirationDate(empty = false) {
|
function renderExpirationDate(empty = false) {
|
||||||
if (value.value.expirationDate && !empty) {
|
if (value.value.expirationDate && !empty) {
|
||||||
expirationDate = new Date(value.value.expirationDate).toLocaleString();
|
expirationDate = new Date(value.value.expirationDate);
|
||||||
} else {
|
} else {
|
||||||
expirationDate = null;
|
expirationDate = null;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user