fix(core): Flush instance stopped event immediately (#10238)
This commit is contained in:
@@ -179,7 +179,7 @@ export class AuthController {
|
||||
throw new BadRequestError('Invalid request');
|
||||
}
|
||||
|
||||
void this.internalHooks.onUserInviteEmailClick({ inviter, invitee });
|
||||
this.internalHooks.onUserInviteEmailClick({ inviter, invitee });
|
||||
this.eventService.emit('user-invite-email-click', { inviter, invitee });
|
||||
|
||||
const { firstName, lastName } = inviter;
|
||||
|
||||
@@ -9,7 +9,6 @@ import { Delete, Get, Middleware, Patch, Post, RestController, GlobalScope } fro
|
||||
import { NodeRequest } from '@/requests';
|
||||
import type { InstalledPackages } from '@db/entities/InstalledPackages';
|
||||
import type { CommunityPackages } from '@/Interfaces';
|
||||
import { InternalHooks } from '@/InternalHooks';
|
||||
import { Push } from '@/push';
|
||||
import { CommunityPackagesService } from '@/services/communityPackages.service';
|
||||
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
|
||||
@@ -37,7 +36,6 @@ export function isNpmError(error: unknown): error is { code: number; stdout: str
|
||||
export class CommunityPackagesController {
|
||||
constructor(
|
||||
private readonly push: Push,
|
||||
private readonly internalHooks: InternalHooks,
|
||||
private readonly communityPackagesService: CommunityPackagesService,
|
||||
private readonly eventService: EventService,
|
||||
) {}
|
||||
|
||||
@@ -168,7 +168,7 @@ export class InvitationController {
|
||||
|
||||
this.authService.issueCookie(res, updatedUser, req.browserId);
|
||||
|
||||
void this.internalHooks.onUserSignup(updatedUser, {
|
||||
this.internalHooks.onUserSignup(updatedUser, {
|
||||
user_type: 'email',
|
||||
was_disabled_ldap_user: false,
|
||||
});
|
||||
|
||||
@@ -101,7 +101,7 @@ export class MeController {
|
||||
this.authService.issueCookie(res, user, req.browserId);
|
||||
|
||||
const fieldsChanged = Object.keys(payload);
|
||||
void this.internalHooks.onUserUpdate({ user, fields_changed: fieldsChanged });
|
||||
this.internalHooks.onUserUpdate({ user, fields_changed: fieldsChanged });
|
||||
this.eventService.emit('user-updated', { user, fieldsChanged });
|
||||
|
||||
const publicUser = await this.userService.toPublic(user);
|
||||
@@ -151,7 +151,7 @@ export class MeController {
|
||||
|
||||
this.authService.issueCookie(res, updatedUser, req.browserId);
|
||||
|
||||
void this.internalHooks.onUserUpdate({ user: updatedUser, fields_changed: ['password'] });
|
||||
this.internalHooks.onUserUpdate({ user: updatedUser, fields_changed: ['password'] });
|
||||
this.eventService.emit('user-updated', { user: updatedUser, fieldsChanged: ['password'] });
|
||||
|
||||
await this.externalHooks.run('user.password.update', [updatedUser.email, updatedUser.password]);
|
||||
@@ -186,7 +186,7 @@ export class MeController {
|
||||
|
||||
this.logger.info('User survey updated successfully', { userId: req.user.id });
|
||||
|
||||
void this.internalHooks.onPersonalizationSurveySubmitted(req.user.id, personalizationAnswers);
|
||||
this.internalHooks.onPersonalizationSurveySubmitted(req.user.id, personalizationAnswers);
|
||||
|
||||
return { success: true };
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ export class OwnerController {
|
||||
|
||||
this.authService.issueCookie(res, owner, req.browserId);
|
||||
|
||||
void this.internalHooks.onInstanceOwnerSetup({ user_id: owner.id });
|
||||
this.internalHooks.onInstanceOwnerSetup({ user_id: owner.id });
|
||||
|
||||
return await this.userService.toPublic(owner, { posthog: this.postHog, withScopes: true });
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ export class PasswordResetController {
|
||||
domain: this.urlService.getInstanceBaseUrl(),
|
||||
});
|
||||
} catch (error) {
|
||||
void this.internalHooks.onEmailFailed({
|
||||
this.internalHooks.onEmailFailed({
|
||||
user,
|
||||
message_type: 'Reset password',
|
||||
public_api: false,
|
||||
@@ -132,13 +132,13 @@ export class PasswordResetController {
|
||||
}
|
||||
|
||||
this.logger.info('Sent password reset email successfully', { userId: user.id, email });
|
||||
void this.internalHooks.onUserTransactionalEmail({
|
||||
this.internalHooks.onUserTransactionalEmail({
|
||||
user_id: id,
|
||||
message_type: 'Reset password',
|
||||
public_api: false,
|
||||
});
|
||||
|
||||
void this.internalHooks.onUserPasswordResetRequestClick({ user });
|
||||
this.internalHooks.onUserPasswordResetRequestClick({ user });
|
||||
this.eventService.emit('user-password-reset-request-click', { user });
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ export class PasswordResetController {
|
||||
}
|
||||
|
||||
this.logger.info('Reset-password token resolved successfully', { userId: user.id });
|
||||
void this.internalHooks.onUserPasswordResetEmailClick({ user });
|
||||
this.internalHooks.onUserPasswordResetEmailClick({ user });
|
||||
this.eventService.emit('user-password-reset-email-click', { user });
|
||||
}
|
||||
|
||||
@@ -215,13 +215,13 @@ export class PasswordResetController {
|
||||
|
||||
this.authService.issueCookie(res, user, req.browserId);
|
||||
|
||||
void this.internalHooks.onUserUpdate({ user, fields_changed: ['password'] });
|
||||
this.internalHooks.onUserUpdate({ user, fields_changed: ['password'] });
|
||||
this.eventService.emit('user-updated', { user, fieldsChanged: ['password'] });
|
||||
|
||||
// if this user used to be an LDAP users
|
||||
const ldapIdentity = user?.authIdentities?.find((i) => i.providerType === 'ldap');
|
||||
if (ldapIdentity) {
|
||||
void this.internalHooks.onUserSignup(user, {
|
||||
this.internalHooks.onUserSignup(user, {
|
||||
user_type: 'email',
|
||||
was_disabled_ldap_user: true,
|
||||
});
|
||||
|
||||
@@ -253,7 +253,7 @@ export class UsersController {
|
||||
await trx.delete(User, { id: userToDelete.id });
|
||||
});
|
||||
|
||||
void this.internalHooks.onUserDeletion({
|
||||
this.internalHooks.onUserDeletion({
|
||||
user: req.user,
|
||||
telemetryData,
|
||||
publicApi: false,
|
||||
@@ -294,7 +294,7 @@ export class UsersController {
|
||||
|
||||
await this.userService.update(targetUser.id, { role: payload.newRoleName });
|
||||
|
||||
void this.internalHooks.onUserRoleChange({
|
||||
this.internalHooks.onUserRoleChange({
|
||||
user: req.user,
|
||||
target_user_id: targetUser.id,
|
||||
target_user_new_role: ['global', payload.newRoleName].join(' '),
|
||||
|
||||
Reference in New Issue
Block a user