fix (backend): fix condition

This commit is contained in:
naskya 2024-06-06 10:08:34 +09:00
parent 02101e04dc
commit 195701d297
No known key found for this signature in database
GPG key ID: 712D413B3A9FED5C

View file

@ -44,8 +44,11 @@ export async function scheduledNote(
})
: [];
const reply = await Notes.findOneBy({ id: job.data.option.replyId });
if (reply == null) {
const reply =
job.data.option.replyId != null
? await Notes.findOneBy({ id: job.data.option.replyId })
: undefined;
if (job.data.option.replyId != null && reply == null) {
logger.warn(
`Note ${job.data.option.replyId} (reply) does not exist, aborting`,
);
@ -53,10 +56,13 @@ export async function scheduledNote(
return;
}
const renote = await Notes.findOneBy({ id: job.data.option.renoteId });
if (renote == null) {
const renote =
job.data.option.renoteId != null
? await Notes.findOneBy({ id: job.data.option.renoteId })
: undefined;
if (job.data.option.renoteId != null && renote == null) {
logger.warn(
`Note ${job.data.option.replyId} (renote) does not exist, aborting`,
`Note ${job.data.option.renoteId} (renote) does not exist, aborting`,
);
done();
return;