refactor(core): Rename EventRelay to EventService (no-changelog) (#10110)

This commit is contained in:
Iván Ovejero
2024-07-19 12:55:38 +02:00
committed by GitHub
parent 222a0862bd
commit aba1c64500
36 changed files with 203 additions and 195 deletions

View File

@@ -23,7 +23,7 @@ import { InternalHooks } from '@/InternalHooks';
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
import { UserRepository } from '@/databases/repositories/user.repository';
import { isApiEnabled } from '@/PublicApi';
import { EventRelay } from '@/eventbus/event-relay.service';
import { EventService } from '@/eventbus/event.service';
export const isApiEnabledMiddleware: RequestHandler = (_, res, next) => {
if (isApiEnabled()) {
@@ -43,7 +43,7 @@ export class MeController {
private readonly userService: UserService,
private readonly passwordUtility: PasswordUtility,
private readonly userRepository: UserRepository,
private readonly eventRelay: EventRelay,
private readonly eventService: EventService,
) {}
/**
@@ -100,7 +100,7 @@ export class MeController {
const fieldsChanged = Object.keys(payload);
void this.internalHooks.onUserUpdate({ user, fields_changed: fieldsChanged });
this.eventRelay.emit('user-updated', { user, fieldsChanged });
this.eventService.emit('user-updated', { user, fieldsChanged });
const publicUser = await this.userService.toPublic(user);
@@ -150,7 +150,7 @@ export class MeController {
this.authService.issueCookie(res, updatedUser, req.browserId);
void this.internalHooks.onUserUpdate({ user: updatedUser, fields_changed: ['password'] });
this.eventRelay.emit('user-updated', { user: updatedUser, fieldsChanged: ['password'] });
this.eventService.emit('user-updated', { user: updatedUser, fieldsChanged: ['password'] });
await this.externalHooks.run('user.password.update', [updatedUser.email, updatedUser.password]);
@@ -199,7 +199,7 @@ export class MeController {
await this.userService.update(req.user.id, { apiKey });
void this.internalHooks.onApiKeyCreated({ user: req.user, public_api: false });
this.eventRelay.emit('api-key-created', { user: req.user });
this.eventService.emit('api-key-created', { user: req.user });
return { apiKey };
}
@@ -220,7 +220,7 @@ export class MeController {
await this.userService.update(req.user.id, { apiKey: null });
void this.internalHooks.onApiKeyDeleted({ user: req.user, public_api: false });
this.eventRelay.emit('api-key-deleted', { user: req.user });
this.eventService.emit('api-key-deleted', { user: req.user });
return { success: true };
}