diff --git a/packages/backend/migration/1699949373507-schedulenote2.js b/packages/backend/migration/1699949373507-schedulenote2.js new file mode 100644 index 0000000000..b8d8a6394b --- /dev/null +++ b/packages/backend/migration/1699949373507-schedulenote2.js @@ -0,0 +1,11 @@ +export class Schedulenote21699949373507 { + name = 'Schedulenote21699949373507' + + async up(queryRunner) { + await queryRunner.query(`ALTER TABLE "note_schedule" RENAME COLUMN "expiresAt" TO "scheduledAt"`); + } + + async down(queryRunner) { + await queryRunner.query(`ALTER TABLE "note_schedule" RENAME COLUMN "scheduledAt" TO "expiresAt"`); + } +} diff --git a/packages/backend/src/models/ScheduledNote.ts b/packages/backend/src/models/ScheduledNote.ts index 7099f1f366..513ad2f845 100644 --- a/packages/backend/src/models/ScheduledNote.ts +++ b/packages/backend/src/models/ScheduledNote.ts @@ -23,5 +23,5 @@ export class MiScheduledNote { public userId: MiUser['id']; @Column('timestamp with time zone') - public expiresAt: Date; + public scheduledAt: Date; } diff --git a/packages/backend/src/server/api/endpoints/notes/create.ts b/packages/backend/src/server/api/endpoints/notes/create.ts index 698b57ade9..20f1cfd4e7 100644 --- a/packages/backend/src/server/api/endpoints/notes/create.ts +++ b/packages/backend/src/server/api/endpoints/notes/create.ts @@ -202,7 +202,7 @@ export const paramDef = { type: 'object', nullable: true, properties: { - expiresAt: { type: 'integer', nullable: false }, + scheduledAt: { type: 'integer', nullable: false }, }, }, }, @@ -388,7 +388,7 @@ export default class extends Endpoint { // eslint- throw new ApiError(meta.errors.rolePermissionDenied); } - if (!ps.schedule.expiresAt) { + if (!ps.schedule.scheduledAt) { throw new ApiError(meta.errors.specifyScheduleDate); } @@ -398,10 +398,10 @@ export default class extends Endpoint { // eslint- id: scheduledNoteId, note: note, userId: me.id, - expiresAt: new Date(ps.schedule.expiresAt), + scheduledAt: new Date(ps.schedule.scheduledAt), }); - const delay = new Date(ps.schedule.expiresAt).getTime() - Date.now(); + const delay = new Date(ps.schedule.scheduledAt).getTime() - Date.now(); await this.queueService.ScheduleNotePostQueue.add(String(delay), { scheduledNoteId, }, { diff --git a/packages/backend/src/server/api/endpoints/notes/schedule/list.ts b/packages/backend/src/server/api/endpoints/notes/schedule/list.ts index 0362805465..83c8a2597d 100644 --- a/packages/backend/src/server/api/endpoints/notes/schedule/list.ts +++ b/packages/backend/src/server/api/endpoints/notes/schedule/list.ts @@ -45,7 +45,7 @@ export const meta = { }, }, userId: { type: 'string', optional: false, nullable: false }, - expiresAt: { type: 'string', optional: false, nullable: false }, + scheduledAt: { type: 'string', optional: false, nullable: false }, }, }, }, @@ -97,14 +97,14 @@ export default class extends Endpoint { // eslint- isSchedule: boolean; }; userId: string; - expiresAt: string; + scheduledAt: string; }[] = scheduleNotes.map((item: any) => { return { ...item, note: { ...item.note, user: user, - createdAt: new Date(item.expiresAt), + createdAt: new Date(item.scheduledAt), isSchedule: true, // ↓TODO: NoteのIDに予約投稿IDを入れたくない(本来別ものなため) id: item.id, diff --git a/packages/frontend/src/components/MkPostForm.vue b/packages/frontend/src/components/MkPostForm.vue index e43c540ee2..8f0737b146 100644 --- a/packages/frontend/src/components/MkPostForm.vue +++ b/packages/frontend/src/components/MkPostForm.vue @@ -177,7 +177,7 @@ let poll = $ref<{ expiredAfter: string | null; } | null>(null); let schedule = $ref<{ - expiresAt: string | null; + scheduledAt: string | null; }| null>(null); let useCw = $ref(false); let showPreview = $ref(defaultStore.state.showPreview); @@ -405,7 +405,7 @@ function toggleSchedule() { schedule = null; } else { schedule = { - expiresAt: null, + scheduledAt: null, }; } } @@ -775,8 +775,8 @@ async function post(ev?: MouseEvent) { } } - if (postData.schedule?.expiresAt && typeof postData.schedule.expiresAt === 'string') { - postData.schedule.expiresAt = parseInt(postData.schedule.expiresAt); + if (postData.schedule?.scheduledAt && typeof postData.schedule.scheduledAt === 'string') { + postData.schedule.scheduledAt = parseInt(postData.schedule.scheduledAt); } let token = undefined; @@ -935,7 +935,7 @@ function openOtherSettingsMenu(ev: MouseEvent) { icon: 'ti ti-calendar-time', indicate: (schedule != null), action: toggleSchedule, - } : undefined, ...(($i.policies?.canScheduleNote) ? [ null, { + } : undefined, ...(($i.policies?.canScheduleNote) ? [null, { type: 'button', text: i18n.ts._schedulePost.list, icon: 'ti ti-calendar-event', diff --git a/packages/frontend/src/components/MkScheduleEditor.vue b/packages/frontend/src/components/MkScheduleEditor.vue index d53451f5bb..f6336ddf69 100644 --- a/packages/frontend/src/components/MkScheduleEditor.vue +++ b/packages/frontend/src/components/MkScheduleEditor.vue @@ -26,19 +26,19 @@ import { i18n } from '@/i18n.js'; const props = defineProps<{ modelValue: { - expiresAt: string; + scheduledAt: string; }; }>(); const emit = defineEmits<{ (ev: 'update:modelValue', v: { - expiresAt: string; + scheduledAt: string; }): void; }>(); const atDate = ref(formatDateTimeString(addTime(new Date(), 1, 'day'), 'yyyy-MM-dd')); const atTime = ref('00:00'); -if ( props.modelValue && props.modelValue.expiresAt) { - atDate.value = atTime.value = props.modelValue.expiresAt; +if ( props.modelValue && props.modelValue.scheduledAt) { + atDate.value = atTime.value = props.modelValue.scheduledAt; } function get() { @@ -48,7 +48,7 @@ function get() { return { ...( - props.modelValue ? { expiresAt: calcAt() } : {} + props.modelValue ? { scheduledAt: calcAt() } : {} ), }; }