mirror of
https://codeberg.org/yeentown/barkey.git
synced 2025-07-07 12:36:57 +00:00
reduce log spam from import/export processes
This commit is contained in:
parent
12acad0654
commit
8e30744bb9
17 changed files with 114 additions and 78 deletions
|
@ -86,21 +86,23 @@ export class ExportAccountDataProcessorService {
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public async process(job: Bull.Job): Promise<void> {
|
public async process(job: Bull.Job): Promise<void> {
|
||||||
this.logger.info('Exporting Account Data...');
|
|
||||||
|
|
||||||
const user = await this.usersRepository.findOneBy({ id: job.data.user.id });
|
const user = await this.usersRepository.findOneBy({ id: job.data.user.id });
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
|
this.logger.debug(`Skip: user ${job.data.user.id} does not exist`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const profile = await this.userProfilesRepository.findOneBy({ userId: job.data.user.id });
|
const profile = await this.userProfilesRepository.findOneBy({ userId: job.data.user.id });
|
||||||
if (profile == null) {
|
if (profile == null) {
|
||||||
|
this.logger.debug(`Skip: user ${job.data.user.id} has no profile`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.logger.info(`Exporting account data for ${job.data.user.id} ...`);
|
||||||
|
|
||||||
const [path, cleanup] = await createTempDir();
|
const [path, cleanup] = await createTempDir();
|
||||||
|
|
||||||
this.logger.info(`Temp dir is ${path}`);
|
this.logger.debug(`Temp dir is ${path}`);
|
||||||
|
|
||||||
// User Export
|
// User Export
|
||||||
|
|
||||||
|
@ -745,12 +747,12 @@ export class ExportAccountDataProcessorService {
|
||||||
zlib: { level: 0 },
|
zlib: { level: 0 },
|
||||||
});
|
});
|
||||||
archiveStream.on('close', async () => {
|
archiveStream.on('close', async () => {
|
||||||
this.logger.succ(`Exported to: ${archivePath}`);
|
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(new Date(), 'yyyy-MM-dd-HH-mm-ss') + '.zip';
|
||||||
const driveFile = await this.driveService.addFile({ user, path: archivePath, name: fileName, force: true });
|
const driveFile = await this.driveService.addFile({ user, path: archivePath, name: fileName, force: true });
|
||||||
|
|
||||||
this.logger.succ(`Exported to: ${driveFile.id}`);
|
this.logger.debug(`Exported to drive: ${driveFile.id}`);
|
||||||
cleanup();
|
cleanup();
|
||||||
archiveCleanup();
|
archiveCleanup();
|
||||||
if (profile.email) {
|
if (profile.email) {
|
||||||
|
|
|
@ -45,8 +45,12 @@ export class ExportAntennasProcessorService {
|
||||||
public async process(job: Bull.Job<DBExportAntennasData>): Promise<void> {
|
public async process(job: Bull.Job<DBExportAntennasData>): Promise<void> {
|
||||||
const user = await this.usersRepository.findOneBy({ id: job.data.user.id });
|
const user = await this.usersRepository.findOneBy({ id: job.data.user.id });
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
|
this.logger.debug(`Skip: user ${job.data.user.id} does not exist`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.logger.info(`Exporting antennas of ${job.data.user.id} ...`);
|
||||||
|
|
||||||
const [path, cleanup] = await createTemp();
|
const [path, cleanup] = await createTemp();
|
||||||
const stream = fs.createWriteStream(path, { flags: 'a' });
|
const stream = fs.createWriteStream(path, { flags: 'a' });
|
||||||
const write = (input: string): Promise<void> => {
|
const write = (input: string): Promise<void> => {
|
||||||
|
@ -96,7 +100,7 @@ export class ExportAntennasProcessorService {
|
||||||
|
|
||||||
const fileName = 'antennas-' + DateFormat(new Date(), 'yyyy-MM-dd-HH-mm-ss') + '.json';
|
const fileName = 'antennas-' + DateFormat(new Date(), 'yyyy-MM-dd-HH-mm-ss') + '.json';
|
||||||
const driveFile = await this.driveService.addFile({ user, path, name: fileName, force: true, ext: 'json' });
|
const driveFile = await this.driveService.addFile({ user, path, name: fileName, force: true, ext: 'json' });
|
||||||
this.logger.succ('Exported to: ' + driveFile.id);
|
this.logger.debug('Exported to: ' + driveFile.id);
|
||||||
|
|
||||||
this.notificationService.createNotification(user.id, 'exportCompleted', {
|
this.notificationService.createNotification(user.id, 'exportCompleted', {
|
||||||
exportedEntity: 'antenna',
|
exportedEntity: 'antenna',
|
||||||
|
|
|
@ -40,17 +40,18 @@ export class ExportBlockingProcessorService {
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public async process(job: Bull.Job<DbJobDataWithUser>): Promise<void> {
|
public async process(job: Bull.Job<DbJobDataWithUser>): Promise<void> {
|
||||||
this.logger.info(`Exporting blocking of ${job.data.user.id} ...`);
|
|
||||||
|
|
||||||
const user = await this.usersRepository.findOneBy({ id: job.data.user.id });
|
const user = await this.usersRepository.findOneBy({ id: job.data.user.id });
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
|
this.logger.debug(`Skip: user ${job.data.user.id} does not exist`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.logger.info(`Exporting blocking of ${job.data.user.id} ...`);
|
||||||
|
|
||||||
// Create temp file
|
// Create temp file
|
||||||
const [path, cleanup] = await createTemp();
|
const [path, cleanup] = await createTemp();
|
||||||
|
|
||||||
this.logger.info(`Temp file is ${path}`);
|
this.logger.debug(`Temp file is ${path}`);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const stream = fs.createWriteStream(path, { flags: 'a' });
|
const stream = fs.createWriteStream(path, { flags: 'a' });
|
||||||
|
@ -105,12 +106,12 @@ export class ExportBlockingProcessorService {
|
||||||
}
|
}
|
||||||
|
|
||||||
stream.end();
|
stream.end();
|
||||||
this.logger.succ(`Exported to: ${path}`);
|
this.logger.debug(`Exported to: ${path}`);
|
||||||
|
|
||||||
const fileName = 'blocking-' + dateFormat(new Date(), 'yyyy-MM-dd-HH-mm-ss') + '.csv';
|
const fileName = 'blocking-' + dateFormat(new Date(), 'yyyy-MM-dd-HH-mm-ss') + '.csv';
|
||||||
const driveFile = await this.driveService.addFile({ user, path, name: fileName, force: true, ext: 'csv' });
|
const driveFile = await this.driveService.addFile({ user, path, name: fileName, force: true, ext: 'csv' });
|
||||||
|
|
||||||
this.logger.succ(`Exported to: ${driveFile.id}`);
|
this.logger.debug(`Exported to: ${driveFile.id}`);
|
||||||
|
|
||||||
this.notificationService.createNotification(user.id, 'exportCompleted', {
|
this.notificationService.createNotification(user.id, 'exportCompleted', {
|
||||||
exportedEntity: 'blocking',
|
exportedEntity: 'blocking',
|
||||||
|
|
|
@ -51,17 +51,18 @@ export class ExportClipsProcessorService {
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public async process(job: Bull.Job<DbJobDataWithUser>): Promise<void> {
|
public async process(job: Bull.Job<DbJobDataWithUser>): Promise<void> {
|
||||||
this.logger.info(`Exporting clips of ${job.data.user.id} ...`);
|
|
||||||
|
|
||||||
const user = await this.usersRepository.findOneBy({ id: job.data.user.id });
|
const user = await this.usersRepository.findOneBy({ id: job.data.user.id });
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
|
this.logger.debug(`Skip: user ${job.data.user.id} does not exist`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.logger.info(`Exporting clips of ${job.data.user.id} ...`);
|
||||||
|
|
||||||
// Create temp file
|
// Create temp file
|
||||||
const [path, cleanup] = await createTemp();
|
const [path, cleanup] = await createTemp();
|
||||||
|
|
||||||
this.logger.info(`Temp file is ${path}`);
|
this.logger.debug(`Temp file is ${path}`);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const stream = Writable.toWeb(fs.createWriteStream(path, { flags: 'a' }));
|
const stream = Writable.toWeb(fs.createWriteStream(path, { flags: 'a' }));
|
||||||
|
@ -75,12 +76,12 @@ export class ExportClipsProcessorService {
|
||||||
await writer.write(']');
|
await writer.write(']');
|
||||||
await writer.close();
|
await writer.close();
|
||||||
|
|
||||||
this.logger.succ(`Exported to: ${path}`);
|
this.logger.debug(`Exported to: ${path}`);
|
||||||
|
|
||||||
const fileName = 'clips-' + dateFormat(new Date(), 'yyyy-MM-dd-HH-mm-ss') + '.json';
|
const fileName = 'clips-' + dateFormat(new Date(), 'yyyy-MM-dd-HH-mm-ss') + '.json';
|
||||||
const driveFile = await this.driveService.addFile({ user, path, name: fileName, force: true, ext: 'json' });
|
const driveFile = await this.driveService.addFile({ user, path, name: fileName, force: true, ext: 'json' });
|
||||||
|
|
||||||
this.logger.succ(`Exported to: ${driveFile.id}`);
|
this.logger.debug(`Exported to: ${driveFile.id}`);
|
||||||
|
|
||||||
this.notificationService.createNotification(user.id, 'exportCompleted', {
|
this.notificationService.createNotification(user.id, 'exportCompleted', {
|
||||||
exportedEntity: 'clip',
|
exportedEntity: 'clip',
|
||||||
|
|
|
@ -45,16 +45,17 @@ export class ExportCustomEmojisProcessorService {
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public async process(job: Bull.Job): Promise<void> {
|
public async process(job: Bull.Job): Promise<void> {
|
||||||
this.logger.info('Exporting custom emojis ...');
|
|
||||||
|
|
||||||
const user = await this.usersRepository.findOneBy({ id: job.data.user.id });
|
const user = await this.usersRepository.findOneBy({ id: job.data.user.id });
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
|
this.logger.debug(`Skip: user ${job.data.user.id} does not exist`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.logger.info(`Exporting custom emojis of ${job.data.user.id} ...`);
|
||||||
|
|
||||||
const [path, cleanup] = await createTempDir();
|
const [path, cleanup] = await createTempDir();
|
||||||
|
|
||||||
this.logger.info(`Temp dir is ${path}`);
|
this.logger.debug(`Temp dir is ${path}`);
|
||||||
|
|
||||||
const metaPath = path + '/meta.json';
|
const metaPath = path + '/meta.json';
|
||||||
|
|
||||||
|
@ -130,12 +131,12 @@ export class ExportCustomEmojisProcessorService {
|
||||||
zlib: { level: 0 },
|
zlib: { level: 0 },
|
||||||
});
|
});
|
||||||
archiveStream.on('close', async () => {
|
archiveStream.on('close', async () => {
|
||||||
this.logger.succ(`Exported to: ${archivePath}`);
|
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(new Date(), 'yyyy-MM-dd-HH-mm-ss') + '.zip';
|
||||||
const driveFile = await this.driveService.addFile({ user, path: archivePath, name: fileName, force: true });
|
const driveFile = await this.driveService.addFile({ user, path: archivePath, name: fileName, force: true });
|
||||||
|
|
||||||
this.logger.succ(`Exported to: ${driveFile.id}`);
|
this.logger.debug(`Exported to: ${driveFile.id}`);
|
||||||
|
|
||||||
this.notificationService.createNotification(user.id, 'exportCompleted', {
|
this.notificationService.createNotification(user.id, 'exportCompleted', {
|
||||||
exportedEntity: 'customEmoji',
|
exportedEntity: 'customEmoji',
|
||||||
|
|
|
@ -45,17 +45,18 @@ export class ExportFavoritesProcessorService {
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public async process(job: Bull.Job<DbJobDataWithUser>): Promise<void> {
|
public async process(job: Bull.Job<DbJobDataWithUser>): Promise<void> {
|
||||||
this.logger.info(`Exporting favorites of ${job.data.user.id} ...`);
|
|
||||||
|
|
||||||
const user = await this.usersRepository.findOneBy({ id: job.data.user.id });
|
const user = await this.usersRepository.findOneBy({ id: job.data.user.id });
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
|
this.logger.debug(`Skip: user ${job.data.user.id} does not exist`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.logger.info(`Exporting favorites of ${job.data.user.id} ...`);
|
||||||
|
|
||||||
// Create temp file
|
// Create temp file
|
||||||
const [path, cleanup] = await createTemp();
|
const [path, cleanup] = await createTemp();
|
||||||
|
|
||||||
this.logger.info(`Temp file is ${path}`);
|
this.logger.debug(`Temp file is ${path}`);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const stream = fs.createWriteStream(path, { flags: 'a' });
|
const stream = fs.createWriteStream(path, { flags: 'a' });
|
||||||
|
@ -119,12 +120,12 @@ export class ExportFavoritesProcessorService {
|
||||||
await write(']');
|
await write(']');
|
||||||
|
|
||||||
stream.end();
|
stream.end();
|
||||||
this.logger.succ(`Exported to: ${path}`);
|
this.logger.debug(`Exported to: ${path}`);
|
||||||
|
|
||||||
const fileName = 'favorites-' + dateFormat(new Date(), 'yyyy-MM-dd-HH-mm-ss') + '.json';
|
const fileName = 'favorites-' + dateFormat(new Date(), 'yyyy-MM-dd-HH-mm-ss') + '.json';
|
||||||
const driveFile = await this.driveService.addFile({ user, path, name: fileName, force: true, ext: 'json' });
|
const driveFile = await this.driveService.addFile({ user, path, name: fileName, force: true, ext: 'json' });
|
||||||
|
|
||||||
this.logger.succ(`Exported to: ${driveFile.id}`);
|
this.logger.debug(`Exported to: ${driveFile.id}`);
|
||||||
|
|
||||||
this.notificationService.createNotification(user.id, 'exportCompleted', {
|
this.notificationService.createNotification(user.id, 'exportCompleted', {
|
||||||
exportedEntity: 'favorite',
|
exportedEntity: 'favorite',
|
||||||
|
|
|
@ -44,17 +44,18 @@ export class ExportFollowingProcessorService {
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public async process(job: Bull.Job<DbExportFollowingData>): Promise<void> {
|
public async process(job: Bull.Job<DbExportFollowingData>): Promise<void> {
|
||||||
this.logger.info(`Exporting following of ${job.data.user.id} ...`);
|
|
||||||
|
|
||||||
const user = await this.usersRepository.findOneBy({ id: job.data.user.id });
|
const user = await this.usersRepository.findOneBy({ id: job.data.user.id });
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
|
this.logger.debug(`Skip: user ${job.data.user.id} does not exist`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.logger.info(`Exporting following of ${job.data.user.id} ...`);
|
||||||
|
|
||||||
// Create temp file
|
// Create temp file
|
||||||
const [path, cleanup] = await createTemp();
|
const [path, cleanup] = await createTemp();
|
||||||
|
|
||||||
this.logger.info(`Temp file is ${path}`);
|
this.logger.debug(`Temp file is ${path}`);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const stream = fs.createWriteStream(path, { flags: 'a' });
|
const stream = fs.createWriteStream(path, { flags: 'a' });
|
||||||
|
@ -109,12 +110,12 @@ export class ExportFollowingProcessorService {
|
||||||
}
|
}
|
||||||
|
|
||||||
stream.end();
|
stream.end();
|
||||||
this.logger.succ(`Exported to: ${path}`);
|
this.logger.debug(`Exported to: ${path}`);
|
||||||
|
|
||||||
const fileName = 'following-' + dateFormat(new Date(), 'yyyy-MM-dd-HH-mm-ss') + '.csv';
|
const fileName = 'following-' + dateFormat(new Date(), 'yyyy-MM-dd-HH-mm-ss') + '.csv';
|
||||||
const driveFile = await this.driveService.addFile({ user, path, name: fileName, force: true, ext: 'csv' });
|
const driveFile = await this.driveService.addFile({ user, path, name: fileName, force: true, ext: 'csv' });
|
||||||
|
|
||||||
this.logger.succ(`Exported to: ${driveFile.id}`);
|
this.logger.debug(`Exported to: ${driveFile.id}`);
|
||||||
|
|
||||||
this.notificationService.createNotification(user.id, 'exportCompleted', {
|
this.notificationService.createNotification(user.id, 'exportCompleted', {
|
||||||
exportedEntity: 'following',
|
exportedEntity: 'following',
|
||||||
|
|
|
@ -40,17 +40,18 @@ export class ExportMutingProcessorService {
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public async process(job: Bull.Job<DbJobDataWithUser>): Promise<void> {
|
public async process(job: Bull.Job<DbJobDataWithUser>): Promise<void> {
|
||||||
this.logger.info(`Exporting muting of ${job.data.user.id} ...`);
|
|
||||||
|
|
||||||
const user = await this.usersRepository.findOneBy({ id: job.data.user.id });
|
const user = await this.usersRepository.findOneBy({ id: job.data.user.id });
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
|
this.logger.debug(`Skip: user ${job.data.user.id} does not exist`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.logger.debug(`Exporting muting of ${job.data.user.id} ...`);
|
||||||
|
|
||||||
// Create temp file
|
// Create temp file
|
||||||
const [path, cleanup] = await createTemp();
|
const [path, cleanup] = await createTemp();
|
||||||
|
|
||||||
this.logger.info(`Temp file is ${path}`);
|
this.logger.debug(`Temp file is ${path}`);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const stream = fs.createWriteStream(path, { flags: 'a' });
|
const stream = fs.createWriteStream(path, { flags: 'a' });
|
||||||
|
@ -106,12 +107,12 @@ export class ExportMutingProcessorService {
|
||||||
}
|
}
|
||||||
|
|
||||||
stream.end();
|
stream.end();
|
||||||
this.logger.succ(`Exported to: ${path}`);
|
this.logger.debug(`Exported to: ${path}`);
|
||||||
|
|
||||||
const fileName = 'mute-' + dateFormat(new Date(), 'yyyy-MM-dd-HH-mm-ss') + '.csv';
|
const fileName = 'mute-' + dateFormat(new Date(), 'yyyy-MM-dd-HH-mm-ss') + '.csv';
|
||||||
const driveFile = await this.driveService.addFile({ user, path, name: fileName, force: true, ext: 'csv' });
|
const driveFile = await this.driveService.addFile({ user, path, name: fileName, force: true, ext: 'csv' });
|
||||||
|
|
||||||
this.logger.succ(`Exported to: ${driveFile.id}`);
|
this.logger.debug(`Exported to: ${driveFile.id}`);
|
||||||
|
|
||||||
this.notificationService.createNotification(user.id, 'exportCompleted', {
|
this.notificationService.createNotification(user.id, 'exportCompleted', {
|
||||||
exportedEntity: 'muting',
|
exportedEntity: 'muting',
|
||||||
|
|
|
@ -120,17 +120,18 @@ export class ExportNotesProcessorService {
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public async process(job: Bull.Job<DbJobDataWithUser>): Promise<void> {
|
public async process(job: Bull.Job<DbJobDataWithUser>): Promise<void> {
|
||||||
this.logger.info(`Exporting notes of ${job.data.user.id} ...`);
|
|
||||||
|
|
||||||
const user = await this.usersRepository.findOneBy({ id: job.data.user.id });
|
const user = await this.usersRepository.findOneBy({ id: job.data.user.id });
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
|
this.logger.debug(`Skip: user ${job.data.user.id} does not exist`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.logger.info(`Exporting notes of ${job.data.user.id} ...`);
|
||||||
|
|
||||||
// Create temp file
|
// Create temp file
|
||||||
const [path, cleanup] = await createTemp();
|
const [path, cleanup] = await createTemp();
|
||||||
|
|
||||||
this.logger.info(`Temp file is ${path}`);
|
this.logger.debug(`Temp file is ${path}`);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// メモリが足りなくならないようにストリームで処理する
|
// メモリが足りなくならないようにストリームで処理する
|
||||||
|
@ -146,12 +147,12 @@ export class ExportNotesProcessorService {
|
||||||
.pipeThrough(new TextEncoderStream())
|
.pipeThrough(new TextEncoderStream())
|
||||||
.pipeTo(new FileWriterStream(path));
|
.pipeTo(new FileWriterStream(path));
|
||||||
|
|
||||||
this.logger.succ(`Exported to: ${path}`);
|
this.logger.debug(`Exported to: ${path}`);
|
||||||
|
|
||||||
const fileName = 'notes-' + dateFormat(new Date(), 'yyyy-MM-dd-HH-mm-ss') + '.json';
|
const fileName = 'notes-' + dateFormat(new Date(), 'yyyy-MM-dd-HH-mm-ss') + '.json';
|
||||||
const driveFile = await this.driveService.addFile({ user, path, name: fileName, force: true, ext: 'json' });
|
const driveFile = await this.driveService.addFile({ user, path, name: fileName, force: true, ext: 'json' });
|
||||||
|
|
||||||
this.logger.succ(`Exported to: ${driveFile.id}`);
|
this.logger.debug(`Exported to: ${driveFile.id}`);
|
||||||
|
|
||||||
this.notificationService.createNotification(user.id, 'exportCompleted', {
|
this.notificationService.createNotification(user.id, 'exportCompleted', {
|
||||||
exportedEntity: 'note',
|
exportedEntity: 'note',
|
||||||
|
|
|
@ -43,13 +43,14 @@ export class ExportUserListsProcessorService {
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public async process(job: Bull.Job<DbJobDataWithUser>): Promise<void> {
|
public async process(job: Bull.Job<DbJobDataWithUser>): Promise<void> {
|
||||||
this.logger.info(`Exporting user lists of ${job.data.user.id} ...`);
|
|
||||||
|
|
||||||
const user = await this.usersRepository.findOneBy({ id: job.data.user.id });
|
const user = await this.usersRepository.findOneBy({ id: job.data.user.id });
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
|
this.logger.debug(`Skip: user ${job.data.user.id} does not exist`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.logger.info(`Exporting user lists of ${job.data.user.id} ...`);
|
||||||
|
|
||||||
const lists = await this.userListsRepository.findBy({
|
const lists = await this.userListsRepository.findBy({
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
});
|
});
|
||||||
|
@ -57,7 +58,7 @@ export class ExportUserListsProcessorService {
|
||||||
// Create temp file
|
// Create temp file
|
||||||
const [path, cleanup] = await createTemp();
|
const [path, cleanup] = await createTemp();
|
||||||
|
|
||||||
this.logger.info(`Temp file is ${path}`);
|
this.logger.debug(`Temp file is ${path}`);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const stream = fs.createWriteStream(path, { flags: 'a' });
|
const stream = fs.createWriteStream(path, { flags: 'a' });
|
||||||
|
@ -85,12 +86,12 @@ export class ExportUserListsProcessorService {
|
||||||
}
|
}
|
||||||
|
|
||||||
stream.end();
|
stream.end();
|
||||||
this.logger.succ(`Exported to: ${path}`);
|
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(new Date(), 'yyyy-MM-dd-HH-mm-ss') + '.csv';
|
||||||
const driveFile = await this.driveService.addFile({ user, path, name: fileName, force: true, ext: 'csv' });
|
const driveFile = await this.driveService.addFile({ user, path, name: fileName, force: true, ext: 'csv' });
|
||||||
|
|
||||||
this.logger.succ(`Exported to: ${driveFile.id}`);
|
this.logger.debug(`Exported to: ${driveFile.id}`);
|
||||||
|
|
||||||
this.notificationService.createNotification(user.id, 'exportCompleted', {
|
this.notificationService.createNotification(user.id, 'exportCompleted', {
|
||||||
exportedEntity: 'userList',
|
exportedEntity: 'userList',
|
||||||
|
|
|
@ -8,7 +8,7 @@ import _Ajv from 'ajv';
|
||||||
import { IdService } from '@/core/IdService.js';
|
import { IdService } from '@/core/IdService.js';
|
||||||
import { GlobalEventService } from '@/core/GlobalEventService.js';
|
import { GlobalEventService } from '@/core/GlobalEventService.js';
|
||||||
import Logger from '@/logger.js';
|
import Logger from '@/logger.js';
|
||||||
import type { AntennasRepository } from '@/models/_.js';
|
import type { AntennasRepository, UsersRepository } from '@/models/_.js';
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
import { QueueLoggerService } from '../QueueLoggerService.js';
|
import { QueueLoggerService } from '../QueueLoggerService.js';
|
||||||
|
@ -59,6 +59,9 @@ export class ImportAntennasProcessorService {
|
||||||
@Inject(DI.antennasRepository)
|
@Inject(DI.antennasRepository)
|
||||||
private antennasRepository: AntennasRepository,
|
private antennasRepository: AntennasRepository,
|
||||||
|
|
||||||
|
@Inject(DI.usersRepository)
|
||||||
|
private usersRepository: UsersRepository,
|
||||||
|
|
||||||
private queueLoggerService: QueueLoggerService,
|
private queueLoggerService: QueueLoggerService,
|
||||||
private idService: IdService,
|
private idService: IdService,
|
||||||
private globalEventService: GlobalEventService,
|
private globalEventService: GlobalEventService,
|
||||||
|
@ -68,6 +71,14 @@ export class ImportAntennasProcessorService {
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public async process(job: Bull.Job<DBAntennaImportJobData>): Promise<void> {
|
public async process(job: Bull.Job<DBAntennaImportJobData>): Promise<void> {
|
||||||
|
const user = await this.usersRepository.findOneBy({ id: job.data.user.id });
|
||||||
|
if (user == null) {
|
||||||
|
this.logger.debug(`Skip: user ${job.data.user.id} does not exist`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.logger.debug(`Importing blocking of ${job.data.user.id} ...`);
|
||||||
|
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
try {
|
try {
|
||||||
for (const antenna of job.data.antenna) {
|
for (const antenna of job.data.antenna) {
|
||||||
|
@ -92,7 +103,7 @@ export class ImportAntennasProcessorService {
|
||||||
withReplies: antenna.withReplies,
|
withReplies: antenna.withReplies,
|
||||||
withFile: antenna.withFile,
|
withFile: antenna.withFile,
|
||||||
});
|
});
|
||||||
this.logger.succ('Antenna created: ' + result.id);
|
this.logger.debug('Antenna created: ' + result.id);
|
||||||
this.globalEventService.publishInternalEvent('antennaCreated', result);
|
this.globalEventService.publishInternalEvent('antennaCreated', result);
|
||||||
}
|
}
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
|
|
|
@ -40,10 +40,9 @@ export class ImportBlockingProcessorService {
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public async process(job: Bull.Job<DbUserImportJobData>): Promise<void> {
|
public async process(job: Bull.Job<DbUserImportJobData>): Promise<void> {
|
||||||
this.logger.info(`Importing blocking of ${job.data.user.id} ...`);
|
|
||||||
|
|
||||||
const user = await this.usersRepository.findOneBy({ id: job.data.user.id });
|
const user = await this.usersRepository.findOneBy({ id: job.data.user.id });
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
|
this.logger.debug(`Skip: user ${job.data.user.id} does not exist`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,14 +50,17 @@ export class ImportBlockingProcessorService {
|
||||||
id: job.data.fileId,
|
id: job.data.fileId,
|
||||||
});
|
});
|
||||||
if (file == null) {
|
if (file == null) {
|
||||||
|
this.logger.debug(`Skip: file ${job.data.fileId} does not exist`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.logger.debug(`Importing blocking of ${job.data.user.id} ...`);
|
||||||
|
|
||||||
const csv = await this.downloadService.downloadTextFile(file.url);
|
const csv = await this.downloadService.downloadTextFile(file.url);
|
||||||
const targets = csv.trim().split('\n');
|
const targets = csv.trim().split('\n');
|
||||||
this.queueService.createImportBlockingToDbJob({ id: user.id }, targets);
|
this.queueService.createImportBlockingToDbJob({ id: user.id }, targets);
|
||||||
|
|
||||||
this.logger.succ('Import jobs created');
|
this.logger.debug('Import jobs created');
|
||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
|
@ -93,7 +95,7 @@ export class ImportBlockingProcessorService {
|
||||||
// skip myself
|
// skip myself
|
||||||
if (target.id === job.data.user.id) return;
|
if (target.id === job.data.user.id) return;
|
||||||
|
|
||||||
this.logger.info(`Block ${target.id} ...`);
|
this.logger.debug(`Block ${target.id} ...`);
|
||||||
|
|
||||||
this.queueService.createBlockJob([{ from: { id: user.id }, to: { id: target.id }, silent: true }]);
|
this.queueService.createBlockJob([{ from: { id: user.id }, to: { id: target.id }, silent: true }]);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
@ -46,18 +46,19 @@ export class ImportCustomEmojisProcessorService {
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public async process(job: Bull.Job<DbUserImportJobData>): Promise<void> {
|
public async process(job: Bull.Job<DbUserImportJobData>): Promise<void> {
|
||||||
this.logger.info('Importing custom emojis ...');
|
|
||||||
|
|
||||||
const file = await this.driveFilesRepository.findOneBy({
|
const file = await this.driveFilesRepository.findOneBy({
|
||||||
id: job.data.fileId,
|
id: job.data.fileId,
|
||||||
});
|
});
|
||||||
if (file == null) {
|
if (file == null) {
|
||||||
|
this.logger.debug(`Skip: file ${job.data.fileId} does not exist`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.logger.info(`Importing custom emojis from ${file.id} (${file.name}) ...`);
|
||||||
|
|
||||||
const [path, cleanup] = await createTempDir();
|
const [path, cleanup] = await createTempDir();
|
||||||
|
|
||||||
this.logger.info(`Temp dir is ${path}`);
|
this.logger.debug(`Temp dir is ${path}`);
|
||||||
|
|
||||||
const destPath = path + '/emojis.zip';
|
const destPath = path + '/emojis.zip';
|
||||||
|
|
||||||
|
@ -73,7 +74,7 @@ export class ImportCustomEmojisProcessorService {
|
||||||
|
|
||||||
const outputPath = path + '/emojis';
|
const outputPath = path + '/emojis';
|
||||||
try {
|
try {
|
||||||
this.logger.succ(`Unzipping to ${outputPath}`);
|
this.logger.debug(`Unzipping to ${outputPath}`);
|
||||||
ZipReader.withDestinationPath(outputPath).viaBuffer(await fs.promises.readFile(destPath));
|
ZipReader.withDestinationPath(outputPath).viaBuffer(await fs.promises.readFile(destPath));
|
||||||
const metaRaw = fs.readFileSync(outputPath + '/meta.json', 'utf-8');
|
const metaRaw = fs.readFileSync(outputPath + '/meta.json', 'utf-8');
|
||||||
const meta = JSON.parse(metaRaw);
|
const meta = JSON.parse(metaRaw);
|
||||||
|
@ -126,7 +127,7 @@ export class ImportCustomEmojisProcessorService {
|
||||||
|
|
||||||
cleanup();
|
cleanup();
|
||||||
|
|
||||||
this.logger.succ('Imported');
|
this.logger.debug('Imported');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.logger.error('Error importing custom emojis:', e as Error);
|
this.logger.error('Error importing custom emojis:', e as Error);
|
||||||
cleanup();
|
cleanup();
|
||||||
|
|
|
@ -40,10 +40,9 @@ export class ImportFollowingProcessorService {
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public async process(job: Bull.Job<DbUserImportJobData>): Promise<void> {
|
public async process(job: Bull.Job<DbUserImportJobData>): Promise<void> {
|
||||||
this.logger.info(`Importing following of ${job.data.user.id} ...`);
|
|
||||||
|
|
||||||
const user = await this.usersRepository.findOneBy({ id: job.data.user.id });
|
const user = await this.usersRepository.findOneBy({ id: job.data.user.id });
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
|
this.logger.debug(`Skip: user ${job.data.user.id} does not exist`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,14 +50,17 @@ export class ImportFollowingProcessorService {
|
||||||
id: job.data.fileId,
|
id: job.data.fileId,
|
||||||
});
|
});
|
||||||
if (file == null) {
|
if (file == null) {
|
||||||
|
this.logger.debug(`Skip: file ${job.data.fileId} does not exist`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.logger.info(`Importing following of ${job.data.user.id} ...`);
|
||||||
|
|
||||||
const csv = await this.downloadService.downloadTextFile(file.url);
|
const csv = await this.downloadService.downloadTextFile(file.url);
|
||||||
const targets = csv.trim().split('\n');
|
const targets = csv.trim().split('\n');
|
||||||
this.queueService.createImportFollowingToDbJob({ id: user.id }, targets, job.data.withReplies);
|
this.queueService.createImportFollowingToDbJob({ id: user.id }, targets, job.data.withReplies);
|
||||||
|
|
||||||
this.logger.succ('Import jobs created');
|
this.logger.debug('Import jobs created');
|
||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
|
@ -93,7 +95,7 @@ export class ImportFollowingProcessorService {
|
||||||
// skip myself
|
// skip myself
|
||||||
if (target.id === job.data.user.id) return;
|
if (target.id === job.data.user.id) return;
|
||||||
|
|
||||||
this.logger.info(`Follow ${target.id} ${job.data.withReplies ? 'with replies' : 'without replies'} ...`);
|
this.logger.debug(`Follow ${target.id} ${job.data.withReplies ? 'with replies' : 'without replies'} ...`);
|
||||||
|
|
||||||
this.queueService.createFollowJob([{ from: user, to: { id: target.id }, silent: true, withReplies: job.data.withReplies }]);
|
this.queueService.createFollowJob([{ from: user, to: { id: target.id }, silent: true, withReplies: job.data.withReplies }]);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
@ -41,10 +41,9 @@ export class ImportMutingProcessorService {
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public async process(job: Bull.Job<DbUserImportJobData>): Promise<void> {
|
public async process(job: Bull.Job<DbUserImportJobData>): Promise<void> {
|
||||||
this.logger.info(`Importing muting of ${job.data.user.id} ...`);
|
|
||||||
|
|
||||||
const user = await this.usersRepository.findOneBy({ id: job.data.user.id });
|
const user = await this.usersRepository.findOneBy({ id: job.data.user.id });
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
|
this.logger.debug(`Skip: user ${job.data.user.id} does not exist`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,9 +51,12 @@ export class ImportMutingProcessorService {
|
||||||
id: job.data.fileId,
|
id: job.data.fileId,
|
||||||
});
|
});
|
||||||
if (file == null) {
|
if (file == null) {
|
||||||
|
this.logger.debug(`Skip: file ${job.data.fileId} does not exist`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.logger.info(`Importing muting of ${job.data.user.id} ...`);
|
||||||
|
|
||||||
const csv = await this.downloadService.downloadTextFile(file.url);
|
const csv = await this.downloadService.downloadTextFile(file.url);
|
||||||
|
|
||||||
let linenum = 0;
|
let linenum = 0;
|
||||||
|
@ -89,7 +91,7 @@ export class ImportMutingProcessorService {
|
||||||
// skip myself
|
// skip myself
|
||||||
if (target.id === job.data.user.id) continue;
|
if (target.id === job.data.user.id) continue;
|
||||||
|
|
||||||
this.logger.info(`Mute[${linenum}] ${target.id} ...`);
|
this.logger.debug(`Mute[${linenum}] ${target.id} ...`);
|
||||||
|
|
||||||
await this.userMutingService.mute(user, target);
|
await this.userMutingService.mute(user, target);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -97,6 +99,6 @@ export class ImportMutingProcessorService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.logger.succ('Imported');
|
this.logger.debug('Imported');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,10 +159,9 @@ export class ImportNotesProcessorService {
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public async process(job: Bull.Job<DbNoteImportJobData>): Promise<void> {
|
public async process(job: Bull.Job<DbNoteImportJobData>): Promise<void> {
|
||||||
this.logger.info(`Starting note import of ${job.data.user.id} ...`);
|
|
||||||
|
|
||||||
const user = await this.usersRepository.findOneBy({ id: job.data.user.id });
|
const user = await this.usersRepository.findOneBy({ id: job.data.user.id });
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
|
this.logger.debug(`Skip: user ${job.data.user.id} does not exist`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,9 +169,12 @@ export class ImportNotesProcessorService {
|
||||||
id: job.data.fileId,
|
id: job.data.fileId,
|
||||||
});
|
});
|
||||||
if (file == null) {
|
if (file == null) {
|
||||||
|
this.logger.debug(`Skip: file ${job.data.fileId} does not exist`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.logger.info(`Starting note import of ${job.data.user.id} ...`);
|
||||||
|
|
||||||
let folder = await this.driveFoldersRepository.findOneBy({ name: 'Imports', userId: job.data.user.id });
|
let folder = await this.driveFoldersRepository.findOneBy({ name: 'Imports', userId: job.data.user.id });
|
||||||
if (folder == null) {
|
if (folder == null) {
|
||||||
await this.driveFoldersRepository.insert({ id: this.idService.gen(), name: 'Imports', userId: job.data.user.id });
|
await this.driveFoldersRepository.insert({ id: this.idService.gen(), name: 'Imports', userId: job.data.user.id });
|
||||||
|
@ -184,7 +186,7 @@ export class ImportNotesProcessorService {
|
||||||
if (type === 'Twitter' || file.name.startsWith('twitter') && file.name.endsWith('.zip')) {
|
if (type === 'Twitter' || file.name.startsWith('twitter') && file.name.endsWith('.zip')) {
|
||||||
const [path, cleanup] = await createTempDir();
|
const [path, cleanup] = await createTempDir();
|
||||||
|
|
||||||
this.logger.info(`Temp dir is ${path}`);
|
this.logger.debug(`Temp dir is ${path}`);
|
||||||
|
|
||||||
const destPath = path + '/twitter.zip';
|
const destPath = path + '/twitter.zip';
|
||||||
|
|
||||||
|
@ -198,7 +200,7 @@ export class ImportNotesProcessorService {
|
||||||
|
|
||||||
const outputPath = path + '/twitter';
|
const outputPath = path + '/twitter';
|
||||||
try {
|
try {
|
||||||
this.logger.succ(`Unzipping to ${outputPath}`);
|
this.logger.debug(`Unzipping to ${outputPath}`);
|
||||||
ZipReader.withDestinationPath(outputPath).viaBuffer(await fsp.readFile(destPath));
|
ZipReader.withDestinationPath(outputPath).viaBuffer(await fsp.readFile(destPath));
|
||||||
|
|
||||||
const unprocessedTweets = this.parseTwitterFile(await fsp.readFile(outputPath + '/data/tweets.js', 'utf-8'));
|
const unprocessedTweets = this.parseTwitterFile(await fsp.readFile(outputPath + '/data/tweets.js', 'utf-8'));
|
||||||
|
@ -212,7 +214,7 @@ export class ImportNotesProcessorService {
|
||||||
} else if (type === 'Facebook' || file.name.startsWith('facebook-') && file.name.endsWith('.zip')) {
|
} else if (type === 'Facebook' || file.name.startsWith('facebook-') && file.name.endsWith('.zip')) {
|
||||||
const [path, cleanup] = await createTempDir();
|
const [path, cleanup] = await createTempDir();
|
||||||
|
|
||||||
this.logger.info(`Temp dir is ${path}`);
|
this.logger.debug(`Temp dir is ${path}`);
|
||||||
|
|
||||||
const destPath = path + '/facebook.zip';
|
const destPath = path + '/facebook.zip';
|
||||||
|
|
||||||
|
@ -226,7 +228,7 @@ export class ImportNotesProcessorService {
|
||||||
|
|
||||||
const outputPath = path + '/facebook';
|
const outputPath = path + '/facebook';
|
||||||
try {
|
try {
|
||||||
this.logger.succ(`Unzipping to ${outputPath}`);
|
this.logger.debug(`Unzipping to ${outputPath}`);
|
||||||
ZipReader.withDestinationPath(outputPath).viaBuffer(await fsp.readFile(destPath));
|
ZipReader.withDestinationPath(outputPath).viaBuffer(await fsp.readFile(destPath));
|
||||||
const postsJson = await fsp.readFile(outputPath + '/your_activity_across_facebook/posts/your_posts__check_ins__photos_and_videos_1.json', 'utf-8');
|
const postsJson = await fsp.readFile(outputPath + '/your_activity_across_facebook/posts/your_posts__check_ins__photos_and_videos_1.json', 'utf-8');
|
||||||
const posts = JSON.parse(postsJson);
|
const posts = JSON.parse(postsJson);
|
||||||
|
@ -243,7 +245,7 @@ export class ImportNotesProcessorService {
|
||||||
} else if (file.name.endsWith('.zip')) {
|
} else if (file.name.endsWith('.zip')) {
|
||||||
const [path, cleanup] = await createTempDir();
|
const [path, cleanup] = await createTempDir();
|
||||||
|
|
||||||
this.logger.info(`Temp dir is ${path}`);
|
this.logger.debug(`Temp dir is ${path}`);
|
||||||
|
|
||||||
const destPath = path + '/unknown.zip';
|
const destPath = path + '/unknown.zip';
|
||||||
|
|
||||||
|
@ -257,7 +259,7 @@ export class ImportNotesProcessorService {
|
||||||
|
|
||||||
const outputPath = path + '/unknown';
|
const outputPath = path + '/unknown';
|
||||||
try {
|
try {
|
||||||
this.logger.succ(`Unzipping to ${outputPath}`);
|
this.logger.debug(`Unzipping to ${outputPath}`);
|
||||||
ZipReader.withDestinationPath(outputPath).viaBuffer(await fsp.readFile(destPath));
|
ZipReader.withDestinationPath(outputPath).viaBuffer(await fsp.readFile(destPath));
|
||||||
const isInstagram = type === 'Instagram' || fs.existsSync(outputPath + '/instagram_live') || fs.existsSync(outputPath + '/instagram_ads_and_businesses');
|
const isInstagram = type === 'Instagram' || fs.existsSync(outputPath + '/instagram_live') || fs.existsSync(outputPath + '/instagram_ads_and_businesses');
|
||||||
const isOutbox = type === 'Mastodon' || fs.existsSync(outputPath + '/outbox.json');
|
const isOutbox = type === 'Mastodon' || fs.existsSync(outputPath + '/outbox.json');
|
||||||
|
@ -301,7 +303,7 @@ export class ImportNotesProcessorService {
|
||||||
} else if (job.data.type === 'Misskey' || file.name.startsWith('notes-') && file.name.endsWith('.json')) {
|
} else if (job.data.type === 'Misskey' || file.name.startsWith('notes-') && file.name.endsWith('.json')) {
|
||||||
const [path, cleanup] = await createTemp();
|
const [path, cleanup] = await createTemp();
|
||||||
|
|
||||||
this.logger.info(`Temp dir is ${path}`);
|
this.logger.debug(`Temp dir is ${path}`);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await fsp.writeFile(path, '', 'utf-8');
|
await fsp.writeFile(path, '', 'utf-8');
|
||||||
|
@ -318,7 +320,7 @@ export class ImportNotesProcessorService {
|
||||||
cleanup();
|
cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.logger.succ('Import jobs created');
|
this.logger.debug('Import jobs created');
|
||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
|
|
|
@ -49,10 +49,9 @@ export class ImportUserListsProcessorService {
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public async process(job: Bull.Job<DbUserImportJobData>): Promise<void> {
|
public async process(job: Bull.Job<DbUserImportJobData>): Promise<void> {
|
||||||
this.logger.info(`Importing user lists of ${job.data.user.id} ...`);
|
|
||||||
|
|
||||||
const user = await this.usersRepository.findOneBy({ id: job.data.user.id });
|
const user = await this.usersRepository.findOneBy({ id: job.data.user.id });
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
|
this.logger.debug(`Skip: user ${job.data.user.id} does not exist`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,9 +59,12 @@ export class ImportUserListsProcessorService {
|
||||||
id: job.data.fileId,
|
id: job.data.fileId,
|
||||||
});
|
});
|
||||||
if (file == null) {
|
if (file == null) {
|
||||||
|
this.logger.debug(`Skip: file ${job.data.fileId} does not exist`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.logger.info(`Importing user lists of ${job.data.user.id} ...`);
|
||||||
|
|
||||||
const csv = await this.downloadService.downloadTextFile(file.url);
|
const csv = await this.downloadService.downloadTextFile(file.url);
|
||||||
|
|
||||||
let linenum = 0;
|
let linenum = 0;
|
||||||
|
@ -107,6 +109,6 @@ export class ImportUserListsProcessorService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.logger.succ('Imported');
|
this.logger.debug('Imported');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue