mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-27 08:25:07 +00:00

* feat: Bind Notification Pipe (#2229) * chore: account page add bind notification modal * feat: timerlock schema and type * feat(fe): bind notification method modal * chore: fe adjust * feat: clean useless code * fix: cron lock * chore: adjust the code * chore: rename api * chore: remove unused code * chore: fe adjust * perf: bind inform ux * fix: time ts * chore: notification (#2251) * perf: send message code * perf: sub schema index * fix: timezone plugin * fix: format --------- Co-authored-by: Finley Ge <32237950+FinleyGe@users.noreply.github.com>
25 lines
539 B
TypeScript
25 lines
539 B
TypeScript
import { MongoTimerLock } from './schema';
|
|
import { addMinutes } from 'date-fns';
|
|
|
|
/*
|
|
利用唯一健,使得同一时间只有一个任务在执行,后创建的锁,会因唯一健创建失败,从而无法继续执行任务
|
|
*/
|
|
export const checkTimerLock = async ({
|
|
timerId,
|
|
lockMinuted
|
|
}: {
|
|
timerId: string;
|
|
lockMinuted: number;
|
|
}) => {
|
|
try {
|
|
await MongoTimerLock.create({
|
|
timerId,
|
|
expiredTime: addMinutes(new Date(), lockMinuted)
|
|
});
|
|
|
|
return true;
|
|
} catch (error) {
|
|
return false;
|
|
}
|
|
};
|