refactor(core): Decouple lifecycle events from internal hooks (no-changelog) (#10305)

This commit is contained in:
Iván Ovejero
2024-08-07 16:09:42 +02:00
committed by GitHub
parent b232831f18
commit 9b977e80f6
11 changed files with 129 additions and 119 deletions

View File

@@ -13,13 +13,13 @@ import { PostHogClient } from '@/posthog';
import { UserService } from '@/services/user.service';
import { Logger } from '@/Logger';
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
import { InternalHooks } from '@/InternalHooks';
import { EventService } from '@/events/event.service';
@RestController('/owner')
export class OwnerController {
constructor(
private readonly logger: Logger,
private readonly internalHooks: InternalHooks,
private readonly eventService: EventService,
private readonly settingsRepository: SettingsRepository,
private readonly authService: AuthService,
private readonly userService: UserService,
@@ -85,7 +85,7 @@ export class OwnerController {
this.authService.issueCookie(res, owner, req.browserId);
this.internalHooks.onInstanceOwnerSetup({ user_id: owner.id });
this.eventService.emit('instance-owner-setup', { userId: owner.id });
return await this.userService.toPublic(owner, { posthog: this.postHog, withScopes: true });
}