convert all remaining backend code to TimeService
This commit is contained in:
parent
9c96dca5a6
commit
3a92471b68
11 changed files with 74 additions and 46 deletions
|
|
@ -11,6 +11,7 @@ import { IdService } from '@/core/IdService.js';
|
|||
import { DI } from '@/di-symbols.js';
|
||||
import { generateInviteCode } from '@/misc/generate-invite-code.js';
|
||||
import { ModerationLogService } from '@/core/ModerationLogService.js';
|
||||
import type { TimeService } from '@/core/TimeService.js';
|
||||
import { ApiError } from '../../../error.js';
|
||||
|
||||
export const meta = {
|
||||
|
|
@ -57,6 +58,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
private inviteCodeEntityService: InviteCodeEntityService,
|
||||
private idService: IdService,
|
||||
private moderationLogService: ModerationLogService,
|
||||
private readonly timeService: TimeService,
|
||||
) {
|
||||
super(meta, paramDef, async (ps, me) => {
|
||||
if (ps.expiresAt && isNaN(Date.parse(ps.expiresAt))) {
|
||||
|
|
@ -71,7 +73,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
createdBy: me,
|
||||
createdById: me.id,
|
||||
expiresAt: ps.expiresAt ? new Date(ps.expiresAt) : null,
|
||||
code: generateInviteCode(),
|
||||
code: generateInviteCode(this.timeService.now),
|
||||
}));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
createdBy: me,
|
||||
createdById: me.id,
|
||||
expiresAt: policies.inviteExpirationTime ? new Date(this.timeService.now + (policies.inviteExpirationTime * 1000 * 60)) : null,
|
||||
code: generateInviteCode(),
|
||||
code: generateInviteCode(this.timeService.now),
|
||||
});
|
||||
|
||||
return await this.inviteCodeEntityService.pack(ticket, me);
|
||||
|
|
|
|||
|
|
@ -66,6 +66,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
|
||||
logger.info('---- Database reset complete.');
|
||||
|
||||
// Ignore rule - this is just testing code.
|
||||
// eslint-disable-next-line no-restricted-globals
|
||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue