diff --git a/packages/backend/package.json b/packages/backend/package.json index 702b788061..dd6c9cc792 100644 --- a/packages/backend/package.json +++ b/packages/backend/package.json @@ -141,11 +141,11 @@ "juice": "11.0.0", "megalodon": "workspace:*", "meilisearch": "0.45.0", - "juice": "11.0.0", "microformats-parser": "2.0.2", "mime-types": "2.1.35", "misskey-js": "workspace:*", "misskey-reversi": "workspace:*", + "moment": "^2.30.1", "ms": "3.0.0-canary.1", "nanoid": "5.0.8", "nested-property": "4.0.0", diff --git a/packages/backend/src/server/api/endpoints/notes/schedule/create.ts b/packages/backend/src/server/api/endpoints/notes/schedule/create.ts index 7d20b6b82a..c6032fbdae 100644 --- a/packages/backend/src/server/api/endpoints/notes/schedule/create.ts +++ b/packages/backend/src/server/api/endpoints/notes/schedule/create.ts @@ -6,6 +6,7 @@ import ms from 'ms'; import { In } from 'typeorm'; import { Inject, Injectable } from '@nestjs/common'; +import moment from 'moment'; import { isPureRenote } from '@/misc/is-renote.js'; import type { MiUser } from '@/models/User.js'; import type { @@ -307,7 +308,7 @@ export default class extends Endpoint { // eslint- if (ps.poll) { let scheduleNote_scheduledAt = Date.now(); if (typeof ps.scheduleNote.scheduledAt === 'number') { - scheduleNote_scheduledAt = ps.scheduleNote.scheduledAt; + scheduleNote_scheduledAt = moment.utc(ps.scheduleNote.scheduledAt).local().valueOf(); } if (typeof ps.poll.expiresAt === 'number') { if (ps.poll.expiresAt < scheduleNote_scheduledAt) { @@ -318,7 +319,7 @@ export default class extends Endpoint { // eslint- } } if (typeof ps.scheduleNote.scheduledAt === 'number') { - if (ps.scheduleNote.scheduledAt < Date.now()) { + if (moment.utc(ps.scheduleNote.scheduledAt).local().valueOf() < Date.now()) { throw new ApiError(meta.errors.cannotCreateAlreadyExpiredSchedule); } } else { @@ -347,14 +348,15 @@ export default class extends Endpoint { // eslint- if (ps.scheduleNote.scheduledAt) { me.token = null; const noteId = this.idService.gen(new Date().getTime()); + const schedNoteLocalTime = moment.utc(ps.scheduleNote.scheduledAt).local().valueOf(); await this.noteScheduleRepository.insert({ id: noteId, note: note, userId: me.id, - scheduledAt: new Date(ps.scheduleNote.scheduledAt), + scheduledAt: new Date(schedNoteLocalTime), }); - const delay = new Date(ps.scheduleNote.scheduledAt).getTime() - Date.now(); + const delay = new Date(schedNoteLocalTime).getTime() - Date.now(); await this.queueService.ScheduleNotePostQueue.add(String(delay), { scheduleNoteId: noteId, }, { diff --git a/packages/frontend/package.json b/packages/frontend/package.json index 752b6cb388..ce3fd90a86 100644 --- a/packages/frontend/package.json +++ b/packages/frontend/package.json @@ -57,6 +57,7 @@ "misskey-bubble-game": "workspace:*", "misskey-js": "workspace:*", "misskey-reversi": "workspace:*", + "moment": "^2.30.1", "photoswipe": "5.4.4", "punycode": "2.3.1", "rollup": "4.26.0", diff --git a/packages/frontend/src/components/MkScheduleEditor.vue b/packages/frontend/src/components/MkScheduleEditor.vue index f40d37c962..695a474998 100644 --- a/packages/frontend/src/components/MkScheduleEditor.vue +++ b/packages/frontend/src/components/MkScheduleEditor.vue @@ -18,6 +18,7 @@ SPDX-License-Identifier: AGPL-3.0-only