use TimeService everywhere in the backend
This commit is contained in:
parent
ed750fd990
commit
6cceca90f9
123 changed files with 550 additions and 285 deletions
|
|
@ -11,6 +11,7 @@ import { bindThis } from '@/decorators.js';
|
|||
import type { RetentionAggregationsRepository, UsersRepository } from '@/models/_.js';
|
||||
import { deepClone } from '@/misc/clone.js';
|
||||
import { IdService } from '@/core/IdService.js';
|
||||
import { TimeService } from '@/core/TimeService.js';
|
||||
import { isDuplicateKeyValueError } from '@/misc/is-duplicate-key-value-error.js';
|
||||
import { QueueLoggerService } from '../QueueLoggerService.js';
|
||||
import type * as Bull from 'bullmq';
|
||||
|
|
@ -28,6 +29,7 @@ export class AggregateRetentionProcessorService {
|
|||
|
||||
private idService: IdService,
|
||||
private queueLoggerService: QueueLoggerService,
|
||||
private readonly timeService: TimeService,
|
||||
) {
|
||||
this.logger = this.queueLoggerService.logger.createSubLogger('aggregate-retention');
|
||||
}
|
||||
|
|
@ -36,18 +38,18 @@ export class AggregateRetentionProcessorService {
|
|||
public async process(): Promise<void> {
|
||||
this.logger.info('Aggregating retention...');
|
||||
|
||||
const now = new Date();
|
||||
const now = this.timeService.date;
|
||||
const dateKey = `${now.getFullYear()}-${now.getMonth() + 1}-${now.getDate()}`;
|
||||
|
||||
// 過去(だいたい)30日分のレコードを取得
|
||||
const pastRecords = await this.retentionAggregationsRepository.findBy({
|
||||
createdAt: MoreThan(new Date(Date.now() - (1000 * 60 * 60 * 24 * 31))),
|
||||
createdAt: MoreThan(new Date(this.timeService.now - (1000 * 60 * 60 * 24 * 31))),
|
||||
});
|
||||
|
||||
// 今日登録したユーザーを全て取得
|
||||
const targetUsers = await this.usersRepository.findBy({
|
||||
host: IsNull(),
|
||||
id: MoreThan(this.idService.gen(Date.now() - (1000 * 60 * 60 * 24))),
|
||||
id: MoreThan(this.idService.gen(this.timeService.now - (1000 * 60 * 60 * 24))),
|
||||
});
|
||||
const targetUserIds = targetUsers.map(u => u.id);
|
||||
|
||||
|
|
@ -71,7 +73,7 @@ export class AggregateRetentionProcessorService {
|
|||
// 今日活動したユーザーを全て取得
|
||||
const activeUsers = await this.usersRepository.findBy({
|
||||
host: IsNull(),
|
||||
lastActiveDate: MoreThan(new Date(Date.now() - (1000 * 60 * 60 * 24))),
|
||||
lastActiveDate: MoreThan(new Date(this.timeService.now - (1000 * 60 * 60 * 24))),
|
||||
});
|
||||
const activeUsersIds = activeUsers.map(u => u.id);
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import type { MutingsRepository } from '@/models/_.js';
|
|||
import type Logger from '@/logger.js';
|
||||
import { bindThis } from '@/decorators.js';
|
||||
import { UserMutingService } from '@/core/UserMutingService.js';
|
||||
import { TimeService } from '@/core/TimeService.js';
|
||||
import { QueueLoggerService } from '../QueueLoggerService.js';
|
||||
import type * as Bull from 'bullmq';
|
||||
|
||||
|
|
@ -23,6 +24,7 @@ export class CheckExpiredMutingsProcessorService {
|
|||
|
||||
private userMutingService: UserMutingService,
|
||||
private queueLoggerService: QueueLoggerService,
|
||||
private readonly timeService: TimeService,
|
||||
) {
|
||||
this.logger = this.queueLoggerService.logger.createSubLogger('check-expired-mutings');
|
||||
}
|
||||
|
|
@ -33,7 +35,7 @@ export class CheckExpiredMutingsProcessorService {
|
|||
|
||||
const expired = await this.mutingsRepository.createQueryBuilder('muting')
|
||||
.where('muting.expiresAt IS NOT NULL')
|
||||
.andWhere('muting.expiresAt < :now', { now: new Date() })
|
||||
.andWhere('muting.expiresAt < :now', { now: this.timeService.date })
|
||||
.innerJoinAndSelect('muting.mutee', 'mutee')
|
||||
.getMany();
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import { bindThis } from '@/decorators.js';
|
|||
import { IdService } from '@/core/IdService.js';
|
||||
import type { Config } from '@/config.js';
|
||||
import { ReversiService } from '@/core/ReversiService.js';
|
||||
import { TimeService } from '@/core/TimeService.js';
|
||||
import { QueueLoggerService } from '../QueueLoggerService.js';
|
||||
import type * as Bull from 'bullmq';
|
||||
|
||||
|
|
@ -35,6 +36,7 @@ export class CleanProcessorService {
|
|||
private queueLoggerService: QueueLoggerService,
|
||||
private reversiService: ReversiService,
|
||||
private idService: IdService,
|
||||
private readonly timeService: TimeService,
|
||||
) {
|
||||
this.logger = this.queueLoggerService.logger.createSubLogger('clean');
|
||||
}
|
||||
|
|
@ -44,13 +46,13 @@ export class CleanProcessorService {
|
|||
this.logger.info('Cleaning...');
|
||||
|
||||
this.userIpsRepository.delete({
|
||||
createdAt: LessThan(new Date(Date.now() - (1000 * 60 * 60 * 24 * 90))),
|
||||
createdAt: LessThan(new Date(this.timeService.now - (1000 * 60 * 60 * 24 * 90))),
|
||||
});
|
||||
|
||||
// 使われてないアンテナを停止
|
||||
if (this.config.deactivateAntennaThreshold > 0) {
|
||||
this.antennasRepository.update({
|
||||
lastUsedAt: LessThan(new Date(Date.now() - this.config.deactivateAntennaThreshold)),
|
||||
lastUsedAt: LessThan(new Date(this.timeService.now - this.config.deactivateAntennaThreshold)),
|
||||
}, {
|
||||
isActive: false,
|
||||
});
|
||||
|
|
@ -58,7 +60,7 @@ export class CleanProcessorService {
|
|||
|
||||
const expiredRoleAssignments = await this.roleAssignmentsRepository.createQueryBuilder('assign')
|
||||
.where('assign.expiresAt IS NOT NULL')
|
||||
.andWhere('assign.expiresAt < :now', { now: new Date() })
|
||||
.andWhere('assign.expiresAt < :now', { now: this.timeService.date })
|
||||
.getMany();
|
||||
|
||||
if (expiredRoleAssignments.length > 0) {
|
||||
|
|
|
|||
|
|
@ -10,11 +10,12 @@ import type { MiDriveFile, DriveFilesRepository } from '@/models/_.js';
|
|||
import { MiUser } from '@/models/_.js';
|
||||
import type Logger from '@/logger.js';
|
||||
import { DriveService } from '@/core/DriveService.js';
|
||||
import { IdService } from '@/core/IdService.js';
|
||||
import { TimeService } from '@/core/TimeService.js';
|
||||
import { bindThis } from '@/decorators.js';
|
||||
import { QueueLoggerService } from '../QueueLoggerService.js';
|
||||
import type * as Bull from 'bullmq';
|
||||
import type { CleanRemoteFilesJobData } from '../types.js';
|
||||
import { IdService } from '@/core/IdService.js';
|
||||
|
||||
@Injectable()
|
||||
export class CleanRemoteFilesProcessorService {
|
||||
|
|
@ -27,6 +28,7 @@ export class CleanRemoteFilesProcessorService {
|
|||
private driveService: DriveService,
|
||||
private queueLoggerService: QueueLoggerService,
|
||||
private idService: IdService,
|
||||
private readonly timeService: TimeService,
|
||||
) {
|
||||
this.logger = this.queueLoggerService.logger.createSubLogger('clean-remote-files');
|
||||
}
|
||||
|
|
@ -35,7 +37,7 @@ export class CleanRemoteFilesProcessorService {
|
|||
public async process(job: Bull.Job<CleanRemoteFilesJobData>): Promise<void> {
|
||||
this.logger.info('Deleting cached remote files...');
|
||||
|
||||
const olderThanTimestamp = Date.now() - (job.data.olderThanSeconds ?? 0) * 1000;
|
||||
const olderThanTimestamp = this.timeService.now - (job.data.olderThanSeconds ?? 0) * 1000;
|
||||
const olderThanDate = new Date(olderThanTimestamp);
|
||||
const keepFilesInUse = job.data.keepFilesInUse ?? false;
|
||||
let deletedCount = 0;
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import ApRequestChart from '@/core/chart/charts/ap-request.js';
|
|||
import FederationChart from '@/core/chart/charts/federation.js';
|
||||
import { StatusError } from '@/misc/status-error.js';
|
||||
import { UtilityService } from '@/core/UtilityService.js';
|
||||
import { TimeService } from '@/core/TimeService.js';
|
||||
import { bindThis } from '@/decorators.js';
|
||||
import { QueueLoggerService } from '../QueueLoggerService.js';
|
||||
import type { DeliverJobData } from '../types.js';
|
||||
|
|
@ -42,6 +43,7 @@ export class DeliverProcessorService {
|
|||
private apRequestChart: ApRequestChart,
|
||||
private federationChart: FederationChart,
|
||||
private queueLoggerService: QueueLoggerService,
|
||||
private readonly timeService: TimeService,
|
||||
) {
|
||||
this.logger = this.queueLoggerService.logger.createSubLogger('deliver');
|
||||
}
|
||||
|
|
@ -99,11 +101,11 @@ export class DeliverProcessorService {
|
|||
if (!i.isNotResponding) {
|
||||
this.federatedInstanceService.update(i.id, {
|
||||
isNotResponding: true,
|
||||
notRespondingSince: new Date(),
|
||||
notRespondingSince: this.timeService.date,
|
||||
});
|
||||
} else if (i.notRespondingSince) {
|
||||
// 1週間以上不通ならサスペンド
|
||||
if (i.suspensionState === 'none' && i.notRespondingSince.getTime() <= Date.now() - 1000 * 60 * 60 * 24 * 7) {
|
||||
if (i.suspensionState === 'none' && i.notRespondingSince.getTime() <= this.timeService.now - 1000 * 60 * 60 * 24 * 7) {
|
||||
this.federatedInstanceService.update(i.id, {
|
||||
suspensionState: 'autoSuspendedForNotResponding',
|
||||
});
|
||||
|
|
@ -112,7 +114,7 @@ export class DeliverProcessorService {
|
|||
// isNotRespondingがtrueでnotRespondingSinceがnullの場合はnotRespondingSinceをセット
|
||||
// notRespondingSinceは新たな機能なので、それ以前のデータにはnotRespondingSinceがない場合がある
|
||||
this.federatedInstanceService.update(i.id, {
|
||||
notRespondingSince: new Date(),
|
||||
notRespondingSince: this.timeService.date,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import { Packed } from '@/misc/json-schema.js';
|
|||
import { UtilityService } from '@/core/UtilityService.js';
|
||||
import { DownloadService } from '@/core/DownloadService.js';
|
||||
import { EmailService } from '@/core/EmailService.js';
|
||||
import { TimeService } from '@/core/TimeService.js';
|
||||
import { renderInlineError } from '@/misc/render-inline-error.js';
|
||||
import { QueueLoggerService } from '../QueueLoggerService.js';
|
||||
import type * as Bull from 'bullmq';
|
||||
|
|
@ -80,6 +81,7 @@ export class ExportAccountDataProcessorService {
|
|||
private downloadService: DownloadService,
|
||||
private emailService: EmailService,
|
||||
private queueLoggerService: QueueLoggerService,
|
||||
private readonly timeService: TimeService,
|
||||
) {
|
||||
this.logger = this.queueLoggerService.logger.createSubLogger('export-account-data');
|
||||
}
|
||||
|
|
@ -125,7 +127,7 @@ export class ExportAccountDataProcessorService {
|
|||
});
|
||||
};
|
||||
|
||||
await writeUser(`{"metaVersion":1,"host":"${this.config.host}","exportedAt":"${new Date().toString()}","user":[`);
|
||||
await writeUser(`{"metaVersion":1,"host":"${this.config.host}","exportedAt":"${this.timeService.date.toString()}","user":[`);
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { host, uri, sharedInbox, followersUri, lastFetchedAt, inbox, ...userTrimmed } = user;
|
||||
|
|
@ -160,7 +162,7 @@ export class ExportAccountDataProcessorService {
|
|||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { emailVerifyCode, twoFactorBackupSecret, twoFactorSecret, password, twoFactorTempSecret, userHost, ...profileTrimmed } = profile;
|
||||
|
||||
await writeProfile(`{"metaVersion":1,"host":"${this.config.host}","exportedAt":"${new Date().toString()}","profile":[`);
|
||||
await writeProfile(`{"metaVersion":1,"host":"${this.config.host}","exportedAt":"${this.timeService.date.toString()}","profile":[`);
|
||||
|
||||
await writeProfile(JSON.stringify(profileTrimmed));
|
||||
|
||||
|
|
@ -191,7 +193,7 @@ export class ExportAccountDataProcessorService {
|
|||
});
|
||||
};
|
||||
|
||||
await writeIPs(`{"metaVersion":1,"host":"${this.config.host}","exportedAt":"${new Date().toString()}","ips":[`);
|
||||
await writeIPs(`{"metaVersion":1,"host":"${this.config.host}","exportedAt":"${this.timeService.date.toString()}","ips":[`);
|
||||
|
||||
for (const signin of signins) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
|
|
@ -226,7 +228,7 @@ export class ExportAccountDataProcessorService {
|
|||
});
|
||||
};
|
||||
|
||||
await writeNotes(`{"metaVersion":1,"host":"${this.config.host}","exportedAt":"${new Date().toString()}","notes":[`);
|
||||
await writeNotes(`{"metaVersion":1,"host":"${this.config.host}","exportedAt":"${this.timeService.date.toString()}","notes":[`);
|
||||
|
||||
let noteCursor: MiNote['id'] | null = null;
|
||||
let exportedNotesCount = 0;
|
||||
|
|
@ -287,7 +289,7 @@ export class ExportAccountDataProcessorService {
|
|||
});
|
||||
};
|
||||
|
||||
await writeFollowing(`{"metaVersion":1,"host":"${this.config.host}","exportedAt":"${new Date().toString()}","followings":[`);
|
||||
await writeFollowing(`{"metaVersion":1,"host":"${this.config.host}","exportedAt":"${this.timeService.date.toString()}","followings":[`);
|
||||
|
||||
let followingsCursor: MiFollowing['id'] | null = null;
|
||||
let exportedFollowingsCount = 0;
|
||||
|
|
@ -321,7 +323,7 @@ export class ExportAccountDataProcessorService {
|
|||
continue;
|
||||
}
|
||||
|
||||
if (u.updatedAt && (Date.now() - u.updatedAt.getTime() > 1000 * 60 * 60 * 24 * 90)) {
|
||||
if (u.updatedAt && (this.timeService.now - u.updatedAt.getTime() > 1000 * 60 * 60 * 24 * 90)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -357,7 +359,7 @@ export class ExportAccountDataProcessorService {
|
|||
});
|
||||
};
|
||||
|
||||
await writeFollowers(`{"metaVersion":1,"host":"${this.config.host}","exportedAt":"${new Date().toString()}","followers":[`);
|
||||
await writeFollowers(`{"metaVersion":1,"host":"${this.config.host}","exportedAt":"${this.timeService.date.toString()}","followers":[`);
|
||||
|
||||
let followersCursor: MiFollowing['id'] | null = null;
|
||||
let exportedFollowersCount = 0;
|
||||
|
|
@ -420,7 +422,7 @@ export class ExportAccountDataProcessorService {
|
|||
|
||||
fs.mkdirSync(`${path}/files`);
|
||||
|
||||
await writeDrive(`{"metaVersion":1,"host":"${this.config.host}","exportedAt":"${new Date().toString()}","drive":[`);
|
||||
await writeDrive(`{"metaVersion":1,"host":"${this.config.host}","exportedAt":"${this.timeService.date.toString()}","drive":[`);
|
||||
|
||||
const driveFiles = await this.driveFilesRepository.find({ where: { userId: user.id } });
|
||||
|
||||
|
|
@ -476,7 +478,7 @@ export class ExportAccountDataProcessorService {
|
|||
});
|
||||
};
|
||||
|
||||
await writeMuting(`{"metaVersion":1,"host":"${this.config.host}","exportedAt":"${new Date().toString()}","mutings":[`);
|
||||
await writeMuting(`{"metaVersion":1,"host":"${this.config.host}","exportedAt":"${this.timeService.date.toString()}","mutings":[`);
|
||||
|
||||
let exportedMutingCount = 0;
|
||||
let mutingCursor: MiMuting['id'] | null = null;
|
||||
|
|
@ -539,7 +541,7 @@ export class ExportAccountDataProcessorService {
|
|||
});
|
||||
};
|
||||
|
||||
await writeBlocking(`{"metaVersion":1,"host":"${this.config.host}","exportedAt":"${new Date().toString()}","blockings":[`);
|
||||
await writeBlocking(`{"metaVersion":1,"host":"${this.config.host}","exportedAt":"${this.timeService.date.toString()}","blockings":[`);
|
||||
|
||||
let exportedBlockingCount = 0;
|
||||
let blockingCursor: MiBlocking['id'] | null = null;
|
||||
|
|
@ -601,7 +603,7 @@ export class ExportAccountDataProcessorService {
|
|||
});
|
||||
};
|
||||
|
||||
await writeFavorite(`{"metaVersion":1,"host":"${this.config.host}","exportedAt":"${new Date().toString()}","favorites":[`);
|
||||
await writeFavorite(`{"metaVersion":1,"host":"${this.config.host}","exportedAt":"${this.timeService.date.toString()}","favorites":[`);
|
||||
|
||||
let exportedFavoritesCount = 0;
|
||||
let favoriteCursor: MiNoteFavorite['id'] | null = null;
|
||||
|
|
@ -662,7 +664,7 @@ export class ExportAccountDataProcessorService {
|
|||
});
|
||||
};
|
||||
|
||||
await writeAntenna(`{"metaVersion":1,"host":"${this.config.host}","exportedAt":"${new Date().toString()}","antennas":[`);
|
||||
await writeAntenna(`{"metaVersion":1,"host":"${this.config.host}","exportedAt":"${this.timeService.date.toString()}","antennas":[`);
|
||||
|
||||
const antennas = await this.antennasRepository.findBy({ userId: user.id });
|
||||
|
||||
|
|
@ -749,7 +751,7 @@ export class ExportAccountDataProcessorService {
|
|||
archiveStream.on('close', async () => {
|
||||
this.logger.debug(`Exported to path: ${archivePath}`);
|
||||
|
||||
const fileName = 'data-request-' + dateFormat(new Date(), 'yyyy-MM-dd-HH-mm-ss') + '.zip';
|
||||
const fileName = 'data-request-' + dateFormat(this.timeService.date, 'yyyy-MM-dd-HH-mm-ss') + '.zip';
|
||||
const driveFile = await this.driveService.addFile({ user, path: archivePath, name: fileName, force: true });
|
||||
|
||||
this.logger.debug(`Exported to drive: ${driveFile.id}`);
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import { bindThis } from '@/decorators.js';
|
|||
import { createTemp } from '@/misc/create-temp.js';
|
||||
import { UtilityService } from '@/core/UtilityService.js';
|
||||
import { NotificationService } from '@/core/NotificationService.js';
|
||||
import { TimeService } from '@/core/TimeService.js';
|
||||
import { QueueLoggerService } from '../QueueLoggerService.js';
|
||||
import type { DBExportAntennasData } from '../types.js';
|
||||
import type * as Bull from 'bullmq';
|
||||
|
|
@ -37,6 +38,7 @@ export class ExportAntennasProcessorService {
|
|||
private utilityService: UtilityService,
|
||||
private queueLoggerService: QueueLoggerService,
|
||||
private notificationService: NotificationService,
|
||||
private readonly timeService: TimeService,
|
||||
) {
|
||||
this.logger = this.queueLoggerService.logger.createSubLogger('export-antennas');
|
||||
}
|
||||
|
|
@ -98,7 +100,7 @@ export class ExportAntennasProcessorService {
|
|||
write(']');
|
||||
stream.end();
|
||||
|
||||
const fileName = 'antennas-' + DateFormat(new Date(), 'yyyy-MM-dd-HH-mm-ss') + '.json';
|
||||
const fileName = 'antennas-' + DateFormat(this.timeService.date, 'yyyy-MM-dd-HH-mm-ss') + '.json';
|
||||
const driveFile = await this.driveService.addFile({ user, path, name: fileName, force: true, ext: 'json' });
|
||||
this.logger.debug('Exported to: ' + driveFile.id);
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import { DriveService } from '@/core/DriveService.js';
|
|||
import { createTemp } from '@/misc/create-temp.js';
|
||||
import { UtilityService } from '@/core/UtilityService.js';
|
||||
import { NotificationService } from '@/core/NotificationService.js';
|
||||
import { TimeService } from '@/core/TimeService.js';
|
||||
import { bindThis } from '@/decorators.js';
|
||||
import { QueueLoggerService } from '../QueueLoggerService.js';
|
||||
import type * as Bull from 'bullmq';
|
||||
|
|
@ -34,6 +35,7 @@ export class ExportBlockingProcessorService {
|
|||
private notificationService: NotificationService,
|
||||
private driveService: DriveService,
|
||||
private queueLoggerService: QueueLoggerService,
|
||||
private readonly timeService: TimeService,
|
||||
) {
|
||||
this.logger = this.queueLoggerService.logger.createSubLogger('export-blocking');
|
||||
}
|
||||
|
|
@ -108,7 +110,7 @@ export class ExportBlockingProcessorService {
|
|||
stream.end();
|
||||
this.logger.debug(`Exported to: ${path}`);
|
||||
|
||||
const fileName = 'blocking-' + dateFormat(new Date(), 'yyyy-MM-dd-HH-mm-ss') + '.csv';
|
||||
const fileName = 'blocking-' + dateFormat(this.timeService.date, 'yyyy-MM-dd-HH-mm-ss') + '.csv';
|
||||
const driveFile = await this.driveService.addFile({ user, path, name: fileName, force: true, ext: 'csv' });
|
||||
|
||||
this.logger.debug(`Exported to: ${driveFile.id}`);
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import { DriveFileEntityService } from '@/core/entities/DriveFileEntityService.j
|
|||
import { Packed } from '@/misc/json-schema.js';
|
||||
import { IdService } from '@/core/IdService.js';
|
||||
import { NotificationService } from '@/core/NotificationService.js';
|
||||
import { TimeService } from '@/core/TimeService.js';
|
||||
import { QueueLoggerService } from '../QueueLoggerService.js';
|
||||
import type * as Bull from 'bullmq';
|
||||
import type { DbJobDataWithUser } from '../types.js';
|
||||
|
|
@ -45,6 +46,7 @@ export class ExportClipsProcessorService {
|
|||
private queueLoggerService: QueueLoggerService,
|
||||
private idService: IdService,
|
||||
private notificationService: NotificationService,
|
||||
private readonly timeService: TimeService,
|
||||
) {
|
||||
this.logger = this.queueLoggerService.logger.createSubLogger('export-clips');
|
||||
}
|
||||
|
|
@ -78,7 +80,7 @@ export class ExportClipsProcessorService {
|
|||
|
||||
this.logger.debug(`Exported to: ${path}`);
|
||||
|
||||
const fileName = 'clips-' + dateFormat(new Date(), 'yyyy-MM-dd-HH-mm-ss') + '.json';
|
||||
const fileName = 'clips-' + dateFormat(this.timeService.date, 'yyyy-MM-dd-HH-mm-ss') + '.json';
|
||||
const driveFile = await this.driveService.addFile({ user, path, name: fileName, force: true, ext: 'json' });
|
||||
|
||||
this.logger.debug(`Exported to: ${driveFile.id}`);
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import { DriveService } from '@/core/DriveService.js';
|
|||
import { createTemp, createTempDir } from '@/misc/create-temp.js';
|
||||
import { DownloadService } from '@/core/DownloadService.js';
|
||||
import { NotificationService } from '@/core/NotificationService.js';
|
||||
import { TimeService } from '@/core/TimeService.js';
|
||||
import { bindThis } from '@/decorators.js';
|
||||
import { QueueLoggerService } from '../QueueLoggerService.js';
|
||||
import type * as Bull from 'bullmq';
|
||||
|
|
@ -39,6 +40,7 @@ export class ExportCustomEmojisProcessorService {
|
|||
private downloadService: DownloadService,
|
||||
private queueLoggerService: QueueLoggerService,
|
||||
private notificationService: NotificationService,
|
||||
private readonly timeService: TimeService,
|
||||
) {
|
||||
this.logger = this.queueLoggerService.logger.createSubLogger('export-custom-emojis');
|
||||
}
|
||||
|
|
@ -133,7 +135,7 @@ export class ExportCustomEmojisProcessorService {
|
|||
archiveStream.on('close', async () => {
|
||||
this.logger.debug(`Exported to: ${archivePath}`);
|
||||
|
||||
const fileName = 'custom-emojis-' + dateFormat(new Date(), 'yyyy-MM-dd-HH-mm-ss') + '.zip';
|
||||
const fileName = 'custom-emojis-' + dateFormat(this.timeService.date, 'yyyy-MM-dd-HH-mm-ss') + '.zip';
|
||||
const driveFile = await this.driveService.addFile({ user, path: archivePath, name: fileName, force: true });
|
||||
|
||||
this.logger.debug(`Exported to: ${driveFile.id}`);
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import type { MiNote } from '@/models/Note.js';
|
|||
import { bindThis } from '@/decorators.js';
|
||||
import { IdService } from '@/core/IdService.js';
|
||||
import { NotificationService } from '@/core/NotificationService.js';
|
||||
import { TimeService } from '@/core/TimeService.js';
|
||||
import { QueueLoggerService } from '../QueueLoggerService.js';
|
||||
import type * as Bull from 'bullmq';
|
||||
import type { DbJobDataWithUser } from '../types.js';
|
||||
|
|
@ -39,6 +40,7 @@ export class ExportFavoritesProcessorService {
|
|||
private queueLoggerService: QueueLoggerService,
|
||||
private idService: IdService,
|
||||
private notificationService: NotificationService,
|
||||
private readonly timeService: TimeService,
|
||||
) {
|
||||
this.logger = this.queueLoggerService.logger.createSubLogger('export-favorites');
|
||||
}
|
||||
|
|
@ -122,7 +124,7 @@ export class ExportFavoritesProcessorService {
|
|||
stream.end();
|
||||
this.logger.debug(`Exported to: ${path}`);
|
||||
|
||||
const fileName = 'favorites-' + dateFormat(new Date(), 'yyyy-MM-dd-HH-mm-ss') + '.json';
|
||||
const fileName = 'favorites-' + dateFormat(this.timeService.date, 'yyyy-MM-dd-HH-mm-ss') + '.json';
|
||||
const driveFile = await this.driveService.addFile({ user, path, name: fileName, force: true, ext: 'json' });
|
||||
|
||||
this.logger.debug(`Exported to: ${driveFile.id}`);
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import { createTemp } from '@/misc/create-temp.js';
|
|||
import type { MiFollowing } from '@/models/Following.js';
|
||||
import { UtilityService } from '@/core/UtilityService.js';
|
||||
import { NotificationService } from '@/core/NotificationService.js';
|
||||
import { TimeService } from '@/core/TimeService.js';
|
||||
import { bindThis } from '@/decorators.js';
|
||||
import { QueueLoggerService } from '../QueueLoggerService.js';
|
||||
import type * as Bull from 'bullmq';
|
||||
|
|
@ -38,6 +39,7 @@ export class ExportFollowingProcessorService {
|
|||
private driveService: DriveService,
|
||||
private queueLoggerService: QueueLoggerService,
|
||||
private notificationService: NotificationService,
|
||||
private readonly timeService: TimeService,
|
||||
) {
|
||||
this.logger = this.queueLoggerService.logger.createSubLogger('export-following');
|
||||
}
|
||||
|
|
@ -91,7 +93,7 @@ export class ExportFollowingProcessorService {
|
|||
continue;
|
||||
}
|
||||
|
||||
if (job.data.excludeInactive && u.updatedAt && (Date.now() - u.updatedAt.getTime() > 1000 * 60 * 60 * 24 * 90)) {
|
||||
if (job.data.excludeInactive && u.updatedAt && (this.timeService.now - u.updatedAt.getTime() > 1000 * 60 * 60 * 24 * 90)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -112,7 +114,7 @@ export class ExportFollowingProcessorService {
|
|||
stream.end();
|
||||
this.logger.debug(`Exported to: ${path}`);
|
||||
|
||||
const fileName = 'following-' + dateFormat(new Date(), 'yyyy-MM-dd-HH-mm-ss') + '.csv';
|
||||
const fileName = 'following-' + dateFormat(this.timeService.date, 'yyyy-MM-dd-HH-mm-ss') + '.csv';
|
||||
const driveFile = await this.driveService.addFile({ user, path, name: fileName, force: true, ext: 'csv' });
|
||||
|
||||
this.logger.debug(`Exported to: ${driveFile.id}`);
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import { createTemp } from '@/misc/create-temp.js';
|
|||
import { UtilityService } from '@/core/UtilityService.js';
|
||||
import { NotificationService } from '@/core/NotificationService.js';
|
||||
import { bindThis } from '@/decorators.js';
|
||||
import { TimeService } from '@/core/TimeService.js';
|
||||
import { QueueLoggerService } from '../QueueLoggerService.js';
|
||||
import type * as Bull from 'bullmq';
|
||||
import type { DbJobDataWithUser } from '../types.js';
|
||||
|
|
@ -34,6 +35,7 @@ export class ExportMutingProcessorService {
|
|||
private driveService: DriveService,
|
||||
private queueLoggerService: QueueLoggerService,
|
||||
private notificationService: NotificationService,
|
||||
private readonly timeService: TimeService,
|
||||
) {
|
||||
this.logger = this.queueLoggerService.logger.createSubLogger('export-muting');
|
||||
}
|
||||
|
|
@ -109,7 +111,7 @@ export class ExportMutingProcessorService {
|
|||
stream.end();
|
||||
this.logger.debug(`Exported to: ${path}`);
|
||||
|
||||
const fileName = 'mute-' + dateFormat(new Date(), 'yyyy-MM-dd-HH-mm-ss') + '.csv';
|
||||
const fileName = 'mute-' + dateFormat(this.timeService.date, 'yyyy-MM-dd-HH-mm-ss') + '.csv';
|
||||
const driveFile = await this.driveService.addFile({ user, path, name: fileName, force: true, ext: 'csv' });
|
||||
|
||||
this.logger.debug(`Exported to: ${driveFile.id}`);
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import { IdService } from '@/core/IdService.js';
|
|||
import { NotificationService } from '@/core/NotificationService.js';
|
||||
import { JsonArrayStream } from '@/misc/JsonArrayStream.js';
|
||||
import { FileWriterStream } from '@/misc/FileWriterStream.js';
|
||||
import { TimeService } from '@/core/TimeService.js';
|
||||
import { QueueLoggerService } from '../QueueLoggerService.js';
|
||||
import type * as Bull from 'bullmq';
|
||||
import type { DbJobDataWithUser } from '../types.js';
|
||||
|
|
@ -114,6 +115,7 @@ export class ExportNotesProcessorService {
|
|||
private driveFileEntityService: DriveFileEntityService,
|
||||
private idService: IdService,
|
||||
private notificationService: NotificationService,
|
||||
private readonly timeService: TimeService,
|
||||
) {
|
||||
this.logger = this.queueLoggerService.logger.createSubLogger('export-notes');
|
||||
}
|
||||
|
|
@ -149,7 +151,7 @@ export class ExportNotesProcessorService {
|
|||
|
||||
this.logger.debug(`Exported to: ${path}`);
|
||||
|
||||
const fileName = 'notes-' + dateFormat(new Date(), 'yyyy-MM-dd-HH-mm-ss') + '.json';
|
||||
const fileName = 'notes-' + dateFormat(this.timeService.date, 'yyyy-MM-dd-HH-mm-ss') + '.json';
|
||||
const driveFile = await this.driveService.addFile({ user, path, name: fileName, force: true, ext: 'json' });
|
||||
|
||||
this.logger.debug(`Exported to: ${driveFile.id}`);
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import { DriveService } from '@/core/DriveService.js';
|
|||
import { createTemp } from '@/misc/create-temp.js';
|
||||
import { UtilityService } from '@/core/UtilityService.js';
|
||||
import { NotificationService } from '@/core/NotificationService.js';
|
||||
import { TimeService } from '@/core/TimeService.js';
|
||||
import { bindThis } from '@/decorators.js';
|
||||
import { QueueLoggerService } from '../QueueLoggerService.js';
|
||||
import type * as Bull from 'bullmq';
|
||||
|
|
@ -37,6 +38,7 @@ export class ExportUserListsProcessorService {
|
|||
private driveService: DriveService,
|
||||
private queueLoggerService: QueueLoggerService,
|
||||
private notificationService: NotificationService,
|
||||
private readonly timeService: TimeService,
|
||||
) {
|
||||
this.logger = this.queueLoggerService.logger.createSubLogger('export-user-lists');
|
||||
}
|
||||
|
|
@ -88,7 +90,7 @@ export class ExportUserListsProcessorService {
|
|||
stream.end();
|
||||
this.logger.debug(`Exported to: ${path}`);
|
||||
|
||||
const fileName = 'user-lists-' + dateFormat(new Date(), 'yyyy-MM-dd-HH-mm-ss') + '.csv';
|
||||
const fileName = 'user-lists-' + dateFormat(this.timeService.date, 'yyyy-MM-dd-HH-mm-ss') + '.csv';
|
||||
const driveFile = await this.driveService.addFile({ user, path, name: fileName, force: true, ext: 'csv' });
|
||||
|
||||
this.logger.debug(`Exported to: ${driveFile.id}`);
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import type { AntennasRepository, UsersRepository } from '@/models/_.js';
|
|||
import { DI } from '@/di-symbols.js';
|
||||
import { bindThis } from '@/decorators.js';
|
||||
import { NotificationService } from '@/core/NotificationService.js';
|
||||
import { TimeService } from '@/core/TimeService.js';
|
||||
import { QueueLoggerService } from '../QueueLoggerService.js';
|
||||
import { DBAntennaImportJobData } from '../types.js';
|
||||
import type * as Bull from 'bullmq';
|
||||
|
|
@ -67,6 +68,7 @@ export class ImportAntennasProcessorService {
|
|||
private idService: IdService,
|
||||
private globalEventService: GlobalEventService,
|
||||
private notificationService: NotificationService,
|
||||
private readonly timeService: TimeService,
|
||||
) {
|
||||
this.logger = this.queueLoggerService.logger.createSubLogger('import-antennas');
|
||||
}
|
||||
|
|
@ -81,7 +83,7 @@ export class ImportAntennasProcessorService {
|
|||
|
||||
this.logger.debug(`Importing antennas of ${job.data.user.id} ...`);
|
||||
|
||||
const now = new Date();
|
||||
const now = this.timeService.date;
|
||||
try {
|
||||
for (const antenna of job.data.antenna) {
|
||||
if (antenna.keywords.length === 0 || antenna.keywords[0].every(x => x === '')) continue;
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ import { SkApInboxLog } from '@/models/_.js';
|
|||
import type { Config } from '@/config.js';
|
||||
import { ApLogService, calculateDurationSince } from '@/core/ApLogService.js';
|
||||
import { UpdateInstanceQueue } from '@/core/UpdateInstanceQueue.js';
|
||||
import { TimeService } from '@/core/TimeService.js';
|
||||
import { isRetryableError } from '@/misc/is-retryable-error.js';
|
||||
import { renderInlineError } from '@/misc/render-inline-error.js';
|
||||
import { QueueLoggerService } from '../QueueLoggerService.js';
|
||||
|
|
@ -66,6 +67,7 @@ export class InboxProcessorService implements OnApplicationShutdown {
|
|||
private queueLoggerService: QueueLoggerService,
|
||||
private readonly apLogService: ApLogService,
|
||||
private readonly updateInstanceQueue: UpdateInstanceQueue,
|
||||
private readonly timeService: TimeService,
|
||||
) {
|
||||
this.logger = this.queueLoggerService.logger.createSubLogger('inbox');
|
||||
}
|
||||
|
|
@ -263,7 +265,7 @@ export class InboxProcessorService implements OnApplicationShutdown {
|
|||
if (i == null) return;
|
||||
|
||||
this.updateInstanceQueue.enqueue(i.id, {
|
||||
latestRequestReceivedAt: new Date(),
|
||||
latestRequestReceivedAt: this.timeService.date,
|
||||
shouldUnsuspend: i.suspensionState === 'autoSuspendedForNotResponding',
|
||||
});
|
||||
|
||||
|
|
@ -322,7 +324,7 @@ export class InboxProcessorService implements OnApplicationShutdown {
|
|||
@bindThis
|
||||
public async performUpdateInstance(id: string, job: UpdateInstanceJob) {
|
||||
await this.federatedInstanceService.update(id, {
|
||||
latestRequestReceivedAt: new Date(),
|
||||
latestRequestReceivedAt: this.timeService.date,
|
||||
isNotResponding: false,
|
||||
// もしサーバーが死んでるために配信が止まっていた場合には自動的に復活させてあげる
|
||||
suspensionState: job.shouldUnsuspend ? 'none' : undefined,
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import { NotificationService } from '@/core/NotificationService.js';
|
|||
import { IdentifiableError } from '@/misc/identifiable-error.js';
|
||||
import type { MiScheduleNoteType } from '@/models/NoteSchedule.js';
|
||||
import { renderInlineError } from '@/misc/render-inline-error.js';
|
||||
import { TimeService } from '@/core/TimeService.js';
|
||||
import { QueueLoggerService } from '../QueueLoggerService.js';
|
||||
import type * as Bull from 'bullmq';
|
||||
import type { ScheduleNotePostJobData } from '../types.js';
|
||||
|
|
@ -37,6 +38,7 @@ export class ScheduleNotePostProcessorService {
|
|||
private noteCreateService: NoteCreateService,
|
||||
private queueLoggerService: QueueLoggerService,
|
||||
private notificationService: NotificationService,
|
||||
private readonly timeService: TimeService,
|
||||
) {
|
||||
this.logger = this.queueLoggerService.logger.createSubLogger('schedule-note-post');
|
||||
}
|
||||
|
|
@ -118,7 +120,7 @@ export class ScheduleNotePostProcessorService {
|
|||
|
||||
const createdNote = await this.noteCreateService.create(me, {
|
||||
...note,
|
||||
createdAt: new Date(),
|
||||
createdAt: this.timeService.date,
|
||||
files,
|
||||
poll: note.poll ? {
|
||||
choices: note.poll.choices,
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import type { Config } from '@/config.js';
|
|||
import type Logger from '@/logger.js';
|
||||
import { HttpRequestService } from '@/core/HttpRequestService.js';
|
||||
import { StatusError } from '@/misc/status-error.js';
|
||||
import { TimeService } from '@/core/TimeService.js';
|
||||
import { bindThis } from '@/decorators.js';
|
||||
import { renderInlineError } from '@/misc/render-inline-error.js';
|
||||
import { QueueLoggerService } from '../QueueLoggerService.js';
|
||||
|
|
@ -29,6 +30,7 @@ export class SystemWebhookDeliverProcessorService {
|
|||
|
||||
private httpRequestService: HttpRequestService,
|
||||
private queueLoggerService: QueueLoggerService,
|
||||
private readonly timeService: TimeService,
|
||||
) {
|
||||
this.logger = this.queueLoggerService.logger.createSubLogger('webhook');
|
||||
}
|
||||
|
|
@ -58,7 +60,7 @@ export class SystemWebhookDeliverProcessorService {
|
|||
});
|
||||
|
||||
this.systemWebhooksRepository.update({ id: job.data.webhookId }, {
|
||||
latestSentAt: new Date(),
|
||||
latestSentAt: this.timeService.date,
|
||||
latestStatus: res.status,
|
||||
});
|
||||
|
||||
|
|
@ -67,7 +69,7 @@ export class SystemWebhookDeliverProcessorService {
|
|||
this.logger.error(`Failed to send webhook: ${renderInlineError(res)}`);
|
||||
|
||||
this.systemWebhooksRepository.update({ id: job.data.webhookId }, {
|
||||
latestSentAt: new Date(),
|
||||
latestSentAt: this.timeService.date,
|
||||
latestStatus: res instanceof StatusError ? res.statusCode : 1,
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import type { Config } from '@/config.js';
|
|||
import type Logger from '@/logger.js';
|
||||
import { HttpRequestService } from '@/core/HttpRequestService.js';
|
||||
import { StatusError } from '@/misc/status-error.js';
|
||||
import { TimeService } from '@/core/TimeService.js';
|
||||
import { bindThis } from '@/decorators.js';
|
||||
import { QueueLoggerService } from '../QueueLoggerService.js';
|
||||
import { UserWebhookDeliverJobData } from '../types.js';
|
||||
|
|
@ -28,6 +29,7 @@ export class UserWebhookDeliverProcessorService {
|
|||
|
||||
private httpRequestService: HttpRequestService,
|
||||
private queueLoggerService: QueueLoggerService,
|
||||
private readonly timeService: TimeService,
|
||||
) {
|
||||
this.logger = this.queueLoggerService.logger.createSubLogger('webhook');
|
||||
}
|
||||
|
|
@ -58,14 +60,14 @@ export class UserWebhookDeliverProcessorService {
|
|||
});
|
||||
|
||||
this.webhooksRepository.update({ id: job.data.webhookId }, {
|
||||
latestSentAt: new Date(),
|
||||
latestSentAt: this.timeService.date,
|
||||
latestStatus: res.status,
|
||||
});
|
||||
|
||||
return 'Success';
|
||||
} catch (res) {
|
||||
this.webhooksRepository.update({ id: job.data.webhookId }, {
|
||||
latestSentAt: new Date(),
|
||||
latestSentAt: this.timeService.date,
|
||||
latestStatus: res instanceof StatusError ? res.statusCode : 1,
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue