fix (backend): scheduled reply/renote
This commit is contained in:
parent
167d89e03e
commit
02101e04dc
3 changed files with 29 additions and 4 deletions
|
@ -16,20 +16,23 @@ export async function scheduledNote(
|
||||||
|
|
||||||
const user = await Users.findOneBy({ id: job.data.user.id });
|
const user = await Users.findOneBy({ id: job.data.user.id });
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
|
logger.warn(`User ${job.data.user.id} does not exist, aborting`);
|
||||||
done();
|
done();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const draftNote = await Notes.findOneBy({ id: job.data.noteId });
|
const draftNote = await Notes.findOneBy({ id: job.data.noteId });
|
||||||
if (draftNote == null) {
|
if (draftNote == null) {
|
||||||
logger.warn(`Note ${job.data.noteId} does not exist`);
|
logger.warn(`Note ${job.data.noteId} does not exist, aborting`);
|
||||||
done();
|
done();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const files = await DriveFiles.findBy({ id: In(draftNote.fileIds) });
|
const files = await DriveFiles.findBy({ id: In(draftNote.fileIds) });
|
||||||
|
|
||||||
if (user.isSuspended) {
|
if (user.isSuspended) {
|
||||||
logger.info(`Cancelled due to user ${job.data.user.id} being suspended`);
|
logger.info(
|
||||||
|
`Cancelled due to user ${job.data.user.id} being suspended, aborting`,
|
||||||
|
);
|
||||||
deleteNote(user, draftNote);
|
deleteNote(user, draftNote);
|
||||||
done();
|
done();
|
||||||
return;
|
return;
|
||||||
|
@ -41,6 +44,24 @@ export async function scheduledNote(
|
||||||
})
|
})
|
||||||
: [];
|
: [];
|
||||||
|
|
||||||
|
const reply = await Notes.findOneBy({ id: job.data.option.replyId });
|
||||||
|
if (reply == null) {
|
||||||
|
logger.warn(
|
||||||
|
`Note ${job.data.option.replyId} (reply) does not exist, aborting`,
|
||||||
|
);
|
||||||
|
done();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const renote = await Notes.findOneBy({ id: job.data.option.renoteId });
|
||||||
|
if (renote == null) {
|
||||||
|
logger.warn(
|
||||||
|
`Note ${job.data.option.replyId} (renote) does not exist, aborting`,
|
||||||
|
);
|
||||||
|
done();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Create scheduled (actual) note
|
// Create scheduled (actual) note
|
||||||
await createNote(user, {
|
await createNote(user, {
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
|
@ -49,8 +70,8 @@ export async function scheduledNote(
|
||||||
poll: job.data.option.poll,
|
poll: job.data.option.poll,
|
||||||
text: draftNote.text || undefined,
|
text: draftNote.text || undefined,
|
||||||
lang: draftNote.lang,
|
lang: draftNote.lang,
|
||||||
reply: draftNote.reply,
|
reply,
|
||||||
renote: draftNote.renote,
|
renote,
|
||||||
cw: draftNote.cw,
|
cw: draftNote.cw,
|
||||||
localOnly: draftNote.localOnly,
|
localOnly: draftNote.localOnly,
|
||||||
visibility: job.data.option.visibility,
|
visibility: job.data.option.visibility,
|
||||||
|
|
|
@ -62,6 +62,8 @@ export type DbUserScheduledNoteData = {
|
||||||
option: {
|
option: {
|
||||||
visibility: string;
|
visibility: string;
|
||||||
visibleUserIds?: string[] | null;
|
visibleUserIds?: string[] | null;
|
||||||
|
replyId?: string;
|
||||||
|
renoteId?: string;
|
||||||
poll?: IPoll;
|
poll?: IPoll;
|
||||||
};
|
};
|
||||||
noteId: Note["id"];
|
noteId: Note["id"];
|
||||||
|
|
|
@ -365,6 +365,8 @@ export default define(meta, paramDef, async (ps, user) => {
|
||||||
: undefined,
|
: undefined,
|
||||||
visibility: ps.visibility,
|
visibility: ps.visibility,
|
||||||
visibleUserIds: ps.visibleUserIds,
|
visibleUserIds: ps.visibleUserIds,
|
||||||
|
replyId: ps.replyId ?? undefined,
|
||||||
|
renoteId: ps.renoteId ?? undefined,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
delay,
|
delay,
|
||||||
|
|
Loading…
Reference in a new issue