fix: schedule unscheduled emails with tasker in cron job (#20748)
Co-authored-by: CarinaWolli <[email protected]>
This commit is contained in:
1 parent
dc361f7879
commit
ffb36509ff
7 files changed
+173
-109
No files matched your search
@@ -1,4 +1,5 @@
|
||||
import { Task } from "./repository";
|
||||
import type { TaskTypes } from "./tasker";
|
||||
import { type TaskerCreate, type Tasker } from "./tasker";
|
||||
import tasksMap, { tasksConfig } from "./tasks";
|
||||
|
||||
@@ -52,4 +53,9 @@ export class InternalTasker implements Tasker {
|
||||
const task = await Task.cancel(id);
|
||||
return task.id;
|
||||
}
|
||||
|
||||
async cancelWithReference(referenceUid: string, type: TaskTypes): Promise<string | null> {
|
||||
const task = await Task.cancelWithReference(referenceUid, type);
|
||||
return task?.id ?? null;
|
||||
}
|
||||
}
|
||||
@@ -154,6 +154,26 @@ export class Task {
|
||||
});
|
||||
}
|
||||
|
||||
static async cancelWithReference(referenceUid: string, type: TaskTypes) {
|
||||
const task = await db.task.findFirst({
|
||||
where: {
|
||||
referenceUid,
|
||||
type,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (!task) return null;
|
||||
|
||||
return await db.task.delete({
|
||||
where: {
|
||||
id: task.id,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
static async cleanup() {
|
||||
// TODO: Uncomment this later
|
||||
// return db.task.deleteMany({
|
||||
|
||||
@@ -34,4 +34,5 @@ export interface Tasker {
|
||||
processQueue(): Promise<void>;
|
||||
cleanup(): Promise<void>;
|
||||
cancel(id: string): Promise<string>;
|
||||
cancelWithReference(referenceUid: string, type: TaskTypes): Promise<string | null>;
|
||||
}
|
||||
Reference in new issue
Block a user