Add importCompleted notification. Send importCompleted when antenna/customEmoji/muting/userList is imported
The only userImportableEntities that don't notify are blocking and following because they fork off a batch of single Closes #891
This commit is contained in:
parent
69f3c8a58e
commit
a00a3c6841
14 changed files with 104 additions and 7 deletions
|
|
@ -187,6 +187,10 @@ export class NotificationEntityService implements OnModuleInit {
|
|||
exportedEntity: notification.exportedEntity,
|
||||
fileId: notification.fileId,
|
||||
} : {}),
|
||||
...(notification.type === 'importCompleted' ? {
|
||||
importedEntity: notification.importedEntity,
|
||||
fileId: notification.fileId,
|
||||
} : {}),
|
||||
...(notification.type === 'scheduledNoteFailed' ? {
|
||||
reason: notification.reason,
|
||||
} : {}),
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { userExportableEntities } from '@/types.js';
|
||||
import { userExportableEntities, userImportableEntities } from '@/types.js';
|
||||
import { MiUser } from './User.js';
|
||||
import { MiNote } from './Note.js';
|
||||
import { MiAccessToken } from './AccessToken.js';
|
||||
|
|
@ -92,6 +92,12 @@ export type MiNotification = {
|
|||
createdAt: string;
|
||||
exportedEntity: typeof userExportableEntities[number];
|
||||
fileId: MiDriveFile['id'];
|
||||
} | {
|
||||
type: 'importCompleted';
|
||||
id: string;
|
||||
createdAt: string;
|
||||
importedEntity: typeof userImportableEntities[number];
|
||||
fileId?: MiDriveFile['id'];
|
||||
} | {
|
||||
type: 'login';
|
||||
id: string;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { notificationTypes, userExportableEntities } from '@/types.js';
|
||||
import { notificationTypes, userExportableEntities, userImportableEntities } from '@/types.js';
|
||||
|
||||
const baseSchema = {
|
||||
type: 'object',
|
||||
|
|
@ -334,6 +334,26 @@ export const packedNotificationSchema = {
|
|||
format: 'id',
|
||||
},
|
||||
},
|
||||
}, {
|
||||
type: 'object',
|
||||
properties: {
|
||||
...baseSchema.properties,
|
||||
type: {
|
||||
type: 'string',
|
||||
optional: false, nullable: false,
|
||||
enum: ['importCompleted'],
|
||||
},
|
||||
importedEntity: {
|
||||
type: 'string',
|
||||
optional: false, nullable: false,
|
||||
enum: userImportableEntities,
|
||||
},
|
||||
fileId: {
|
||||
type: 'string',
|
||||
optional: false, nullable: false,
|
||||
format: 'id',
|
||||
},
|
||||
},
|
||||
}, {
|
||||
type: 'object',
|
||||
properties: {
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import type { AntennasRepository, UsersRepository } from '@/models/_.js';
|
|||
import { DI } from '@/di-symbols.js';
|
||||
import { bindThis } from '@/decorators.js';
|
||||
import { QueueLoggerService } from '../QueueLoggerService.js';
|
||||
import { NotificationService } from '@/core/NotificationService.js';
|
||||
import { DBAntennaImportJobData } from '../types.js';
|
||||
import type * as Bull from 'bullmq';
|
||||
|
||||
|
|
@ -65,6 +66,7 @@ export class ImportAntennasProcessorService {
|
|||
private queueLoggerService: QueueLoggerService,
|
||||
private idService: IdService,
|
||||
private globalEventService: GlobalEventService,
|
||||
private notificationService: NotificationService,
|
||||
) {
|
||||
this.logger = this.queueLoggerService.logger.createSubLogger('import-antennas');
|
||||
}
|
||||
|
|
@ -106,6 +108,10 @@ export class ImportAntennasProcessorService {
|
|||
this.logger.debug('Antenna created: ' + result.id);
|
||||
this.globalEventService.publishInternalEvent('antennaCreated', result);
|
||||
}
|
||||
|
||||
this.notificationService.createNotification(job.data.user.id, 'importCompleted', {
|
||||
importedEntity: 'antenna',
|
||||
});
|
||||
} catch (err: any) {
|
||||
this.logger.error('Error importing antennas:', err);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import { bindThis } from '@/decorators.js';
|
|||
import type { Config } from '@/config.js';
|
||||
import { renderInlineError } from '@/misc/render-inline-error.js';
|
||||
import { QueueLoggerService } from '../QueueLoggerService.js';
|
||||
import { NotificationService } from '@/core/NotificationService.js';
|
||||
import type * as Bull from 'bullmq';
|
||||
import type { DbUserImportJobData } from '../types.js';
|
||||
|
||||
|
|
@ -40,6 +41,7 @@ export class ImportCustomEmojisProcessorService {
|
|||
private driveService: DriveService,
|
||||
private downloadService: DownloadService,
|
||||
private queueLoggerService: QueueLoggerService,
|
||||
private notificationService: NotificationService,
|
||||
) {
|
||||
this.logger = this.queueLoggerService.logger.createSubLogger('import-custom-emojis');
|
||||
}
|
||||
|
|
@ -127,7 +129,12 @@ export class ImportCustomEmojisProcessorService {
|
|||
|
||||
cleanup();
|
||||
|
||||
this.logger.debug('Imported');
|
||||
this.notificationService.createNotification(job.data.user.id, 'importCompleted', {
|
||||
importedEntity: 'customEmoji',
|
||||
fileId: file.id,
|
||||
});
|
||||
|
||||
this.logger.debug('Imported', file.name);
|
||||
} catch (e) {
|
||||
this.logger.error('Error importing custom emojis:', e as Error);
|
||||
cleanup();
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import { UtilityService } from '@/core/UtilityService.js';
|
|||
import { bindThis } from '@/decorators.js';
|
||||
import { renderInlineError } from '@/misc/render-inline-error.js';
|
||||
import { QueueLoggerService } from '../QueueLoggerService.js';
|
||||
import { NotificationService } from '@/core/NotificationService.js';
|
||||
import type * as Bull from 'bullmq';
|
||||
import type { DbUserImportJobData } from '../types.js';
|
||||
|
||||
|
|
@ -35,6 +36,7 @@ export class ImportMutingProcessorService {
|
|||
private remoteUserResolveService: RemoteUserResolveService,
|
||||
private downloadService: DownloadService,
|
||||
private queueLoggerService: QueueLoggerService,
|
||||
private notificationService: NotificationService,
|
||||
) {
|
||||
this.logger = this.queueLoggerService.logger.createSubLogger('import-muting');
|
||||
}
|
||||
|
|
@ -99,6 +101,11 @@ export class ImportMutingProcessorService {
|
|||
}
|
||||
}
|
||||
|
||||
this.notificationService.createNotification(job.data.user.id, 'importCompleted', {
|
||||
importedEntity: 'muting',
|
||||
fileId: file.id,
|
||||
});
|
||||
|
||||
this.logger.debug('Imported');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import { UtilityService } from '@/core/UtilityService.js';
|
|||
import { bindThis } from '@/decorators.js';
|
||||
import { renderInlineError } from '@/misc/render-inline-error.js';
|
||||
import { QueueLoggerService } from '../QueueLoggerService.js';
|
||||
import { NotificationService } from '@/core/NotificationService.js';
|
||||
import type * as Bull from 'bullmq';
|
||||
import type { DbUserImportJobData } from '../types.js';
|
||||
|
||||
|
|
@ -43,6 +44,7 @@ export class ImportUserListsProcessorService {
|
|||
private remoteUserResolveService: RemoteUserResolveService,
|
||||
private downloadService: DownloadService,
|
||||
private queueLoggerService: QueueLoggerService,
|
||||
private notificationService: NotificationService,
|
||||
) {
|
||||
this.logger = this.queueLoggerService.logger.createSubLogger('import-user-lists');
|
||||
}
|
||||
|
|
@ -109,6 +111,11 @@ export class ImportUserListsProcessorService {
|
|||
}
|
||||
}
|
||||
|
||||
this.notificationService.createNotification(job.data.user.id, 'importCompleted', {
|
||||
importedEntity: 'userList',
|
||||
fileId: file.id,
|
||||
});
|
||||
|
||||
this.logger.debug('Imported');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ export const notificationTypes = [
|
|||
'chatRoomInvitationReceived',
|
||||
'achievementEarned',
|
||||
'exportCompleted',
|
||||
'importCompleted',
|
||||
'login',
|
||||
'createToken',
|
||||
'scheduledNoteFailed',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue