idの混同を修正
This commit is contained in:
parent
a2ea072deb
commit
6c3d6ba955
1
locales/index.d.ts
vendored
1
locales/index.d.ts
vendored
|
@ -2493,6 +2493,7 @@ export interface Locale {
|
||||||
"localTime": string;
|
"localTime": string;
|
||||||
"addSchedule": string;
|
"addSchedule": string;
|
||||||
"willBePostedAtX": string;
|
"willBePostedAtX": string;
|
||||||
|
"deleteAreYouSure": string;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
declare const locales: {
|
declare const locales: {
|
||||||
|
|
|
@ -2381,3 +2381,4 @@ _schedulePost:
|
||||||
localTime: "端末に設定されているタイムゾーンの時刻で投稿されます。"
|
localTime: "端末に設定されているタイムゾーンの時刻で投稿されます。"
|
||||||
addSchedule: "予約設定"
|
addSchedule: "予約設定"
|
||||||
willBePostedAtX: "{date}に投稿予約しました。"
|
willBePostedAtX: "{date}に投稿予約しました。"
|
||||||
|
deleteAreYouSure: "予約投稿を削除しますか?"
|
||||||
|
|
|
@ -311,7 +311,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
if (renote.channelId && renote.channelId !== ps.channelId) {
|
if (renote.channelId && renote.channelId !== ps.channelId) {
|
||||||
// チャンネルのノートに対しリノート要求がきたとき、チャンネル外へのリノート可否をチェック
|
// チャンネルのノートに対しリノート要求がきたとき、チャンネル外へのリノート可否をチェック
|
||||||
// リノートのユースケースのうち、チャンネル内→チャンネル外は少数だと考えられるため、JOINはせず必要な時に都度取得する
|
// リノートのユースケースのうち、チャンネル内→チャンネル外は少数だと考えられるため、JOINはせず必要な時に都度取得する
|
||||||
const renoteChannel = await this.channelsRepository.findOneById(renote.channelId);
|
const renoteChannel = await this.channelsRepository.findOneBy({ id: renote.channelId });
|
||||||
if (renoteChannel == null) {
|
if (renoteChannel == null) {
|
||||||
// リノートしたいノートが書き込まれているチャンネルが無い
|
// リノートしたいノートが書き込まれているチャンネルが無い
|
||||||
throw new ApiError(meta.errors.noSuchChannel);
|
throw new ApiError(meta.errors.noSuchChannel);
|
||||||
|
@ -391,6 +391,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
};
|
};
|
||||||
|
|
||||||
if (ps.schedule) {
|
if (ps.schedule) {
|
||||||
|
// 予約投稿
|
||||||
const canCreateScheduledNote = (await this.roleService.getUserPolicies(me.id)).canScheduleNote;
|
const canCreateScheduledNote = (await this.roleService.getUserPolicies(me.id)).canScheduleNote;
|
||||||
if (!canCreateScheduledNote) {
|
if (!canCreateScheduledNote) {
|
||||||
throw new ApiError(meta.errors.rolePermissionDenied);
|
throw new ApiError(meta.errors.rolePermissionDenied);
|
||||||
|
@ -410,7 +411,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
});
|
});
|
||||||
|
|
||||||
const delay = new Date(ps.schedule.scheduledAt).getTime() - Date.now();
|
const delay = new Date(ps.schedule.scheduledAt).getTime() - Date.now();
|
||||||
await this.queueService.ScheduleNotePostQueue.add(String(delay), {
|
await this.queueService.ScheduleNotePostQueue.add(delay.toString(), {
|
||||||
scheduledNoteId,
|
scheduledNoteId,
|
||||||
}, {
|
}, {
|
||||||
jobId: scheduledNoteId,
|
jobId: scheduledNoteId,
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import ms from 'ms';
|
|
||||||
import { Inject, Injectable } from '@nestjs/common';
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
|
@ -23,37 +22,8 @@ export const meta = {
|
||||||
items: {
|
items: {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
optional: false, nullable: false,
|
optional: false, nullable: false,
|
||||||
properties: {
|
|
||||||
id: { type: 'string', optional: false, nullable: false },
|
|
||||||
note: {
|
|
||||||
type: 'object',
|
|
||||||
optional: false, nullable: false,
|
|
||||||
properties: {
|
|
||||||
id: { type: 'string', optional: false, nullable: false },
|
|
||||||
text: { type: 'string', optional: false, nullable: false },
|
|
||||||
files: { type: 'array', optional: false, nullable: false, items: { type: 'any' } },
|
|
||||||
localOnly: { type: 'boolean', optional: false, nullable: false },
|
|
||||||
visibility: { type: 'string', optional: false, nullable: false },
|
|
||||||
visibleUsers: { type: 'array', optional: false, nullable: false, items: { type: 'any' } },
|
|
||||||
reactionAcceptance: { type: 'string', optional: false, nullable: false },
|
|
||||||
user: {
|
|
||||||
type: 'object',
|
|
||||||
optional: false, nullable: false,
|
|
||||||
ref: 'User',
|
|
||||||
},
|
|
||||||
createdAt: { type: 'string', optional: false, nullable: false },
|
|
||||||
isSchedule: { type: 'boolean', optional: false, nullable: false },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
userId: { type: 'string', optional: false, nullable: false },
|
|
||||||
scheduledAt: { type: 'string', optional: false, nullable: false },
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
limit: {
|
|
||||||
duration: ms('1hour'),
|
|
||||||
max: 300,
|
|
||||||
},
|
|
||||||
|
|
||||||
errors: {
|
errors: {
|
||||||
},
|
},
|
||||||
|
@ -84,32 +54,17 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
|
|
||||||
const scheduleNotes = await query.limit(ps.limit).getMany();
|
const scheduleNotes = await query.limit(ps.limit).getMany();
|
||||||
const user = await this.userEntityService.pack(me, me);
|
const user = await this.userEntityService.pack(me, me);
|
||||||
const scheduleNotesPack: {
|
const scheduleNotesPack = scheduleNotes.map((item) => {
|
||||||
id: string;
|
|
||||||
note: {
|
|
||||||
id: string;
|
|
||||||
text: string;
|
|
||||||
files: any[];
|
|
||||||
localOnly: boolean;
|
|
||||||
visibility: string;
|
|
||||||
visibleUsers: any[];
|
|
||||||
reactionAcceptance: string;
|
|
||||||
user: any;
|
|
||||||
createdAt: string;
|
|
||||||
isSchedule: boolean;
|
|
||||||
};
|
|
||||||
userId: string;
|
|
||||||
scheduledAt: string;
|
|
||||||
}[] = scheduleNotes.map((item: any) => {
|
|
||||||
return {
|
return {
|
||||||
...item,
|
...item,
|
||||||
|
scheduledAt: new Date(item.scheduledAt).toISOString(),
|
||||||
note: {
|
note: {
|
||||||
...item.note,
|
...item.note,
|
||||||
user: user,
|
user: user,
|
||||||
createdAt: new Date(item.scheduledAt),
|
createdAt: new Date(item.scheduledAt).toISOString(),
|
||||||
isSchedule: true,
|
isSchedule: true,
|
||||||
// ↓TODO: NoteのIDに予約投稿IDを入れたくない(本来別ものなため)
|
id: null,
|
||||||
id: this.idService.gen(item.scheduledAt.getTime()),
|
scheduledNoteId: item.id,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
|
@ -36,13 +36,23 @@ import MkButton from '@/components/MkButton.vue';
|
||||||
import * as os from '@/os.js';
|
import * as os from '@/os.js';
|
||||||
const isDeleted = ref(false);
|
const isDeleted = ref(false);
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
note: Misskey.entities.Note & {isSchedule? : boolean};
|
note: Misskey.entities.Note & {
|
||||||
|
id: string | null;
|
||||||
|
isSchedule?: boolean;
|
||||||
|
scheduledNoteId?: string;
|
||||||
|
};
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
async function deleteScheduleNote() {
|
async function deleteScheduleNote() {
|
||||||
if (!props.note.isSchedule) return;
|
if (!props.note.isSchedule || !props.note.scheduledNoteId) return;
|
||||||
// スケジュールつきノートの場合は、ノートIDのフィールドに予約投稿ID(scheduledNoteId)が入るので注意!!!!
|
|
||||||
await os.apiWithDialog('notes/schedule/delete', { scheduledNoteId: props.note.id })
|
const { canceled } = await os.confirm({
|
||||||
|
type: 'warning',
|
||||||
|
text: i18n.ts._schedulePost.deleteAreYouSure,
|
||||||
|
});
|
||||||
|
if (canceled) return;
|
||||||
|
|
||||||
|
await os.apiWithDialog('notes/schedule/delete', { scheduledNoteId: props.note.scheduledNoteId })
|
||||||
.then(() => {
|
.then(() => {
|
||||||
isDeleted.value = true;
|
isDeleted.value = true;
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue