wip
This commit is contained in:
parent
17289803e8
commit
52d2688d22
|
@ -97,18 +97,20 @@ export class NoteDraftService {
|
||||||
|
|
||||||
await this.validate(me, data);
|
await this.validate(me, data);
|
||||||
|
|
||||||
await this.noteDraftsRepository.update(draftId, data);
|
const updatedDraft = await this.noteDraftsRepository.createQueryBuilder().update()
|
||||||
|
.set(data)
|
||||||
|
.where('id = :id', { id: draftId })
|
||||||
|
.returning('*')
|
||||||
|
.execute()
|
||||||
|
.then((response) => response.raw[0]);
|
||||||
|
|
||||||
this.clearSchedule(draft).then(() => {
|
this.clearSchedule(draftId).then(() => {
|
||||||
if (data.scheduledAt != null && data.isActuallyScheduled) {
|
if (updatedDraft.scheduledAt != null && updatedDraft.isActuallyScheduled) {
|
||||||
this.schedule(draft);
|
this.schedule(updatedDraft);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return updatedDraft;
|
||||||
...draft,
|
|
||||||
...data,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
|
@ -124,7 +126,7 @@ export class NoteDraftService {
|
||||||
|
|
||||||
await this.noteDraftsRepository.delete(draft.id);
|
await this.noteDraftsRepository.delete(draft.id);
|
||||||
|
|
||||||
this.clearSchedule(draft);
|
this.clearSchedule(draftId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
|
@ -293,10 +295,10 @@ export class NoteDraftService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public async clearSchedule(draft: MiNoteDraft): Promise<void> {
|
public async clearSchedule(draftId: MiNoteDraft['id']): Promise<void> {
|
||||||
const jobs = await this.queueService.postScheduledNoteQueue.getJobs(['delayed', 'waiting', 'active']);
|
const jobs = await this.queueService.postScheduledNoteQueue.getJobs(['delayed', 'waiting', 'active']);
|
||||||
for (const job of jobs) {
|
for (const job of jobs) {
|
||||||
if (job.data.noteDraftId === draft.id) {
|
if (job.data.noteDraftId === draftId) {
|
||||||
await job.remove();
|
await job.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -238,7 +238,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
replyId: ps.replyId,
|
replyId: ps.replyId,
|
||||||
renoteId: ps.renoteId,
|
renoteId: ps.renoteId,
|
||||||
cw: ps.cw,
|
cw: ps.cw,
|
||||||
...(ps.hashtag ? { hashtag: ps.hashtag } : {}),
|
hashtag: ps.hashtag,
|
||||||
localOnly: ps.localOnly,
|
localOnly: ps.localOnly,
|
||||||
reactionAcceptance: ps.reactionAcceptance,
|
reactionAcceptance: ps.reactionAcceptance,
|
||||||
visibility: ps.visibility,
|
visibility: ps.visibility,
|
||||||
|
|
Loading…
Reference in New Issue