mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-11 13:12:23 +09:00
36 lines
1.5 KiB
TypeScript
36 lines
1.5 KiB
TypeScript
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
import type {UserID} from '@app/api/BrandedTypes';
|
|
import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate';
|
|
import type {IGatewayService} from '@app/api/infrastructure/IGatewayService';
|
|
import type {UserCacheService} from '@app/api/infrastructure/UserCacheService';
|
|
import type {User} from '@app/api/models/User';
|
|
import type {IUserRepository} from '@app/api/user/IUserRepository';
|
|
import {BaseUserUpdatePropagator} from '@app/api/user/services/BaseUserUpdatePropagator';
|
|
import {propagatePartialUserChange} from '@app/api/user/services/PartialUserChangePropagation';
|
|
import {hasPartialUserFieldsChanged} from '@app/api/user/UserMappers';
|
|
|
|
interface AdminUserUpdatePropagatorDeps {
|
|
userCacheService: UserCacheService;
|
|
userRepository: IUserRepository;
|
|
guildRepository: IGuildRepositoryAggregate;
|
|
gatewayService: IGatewayService;
|
|
}
|
|
|
|
export class AdminUserUpdatePropagator extends BaseUserUpdatePropagator {
|
|
constructor(private readonly deps: AdminUserUpdatePropagatorDeps) {
|
|
super({
|
|
userCacheService: deps.userCacheService,
|
|
gatewayService: deps.gatewayService,
|
|
});
|
|
}
|
|
|
|
async propagateUserUpdate(params: {userId: UserID; oldUser: User; updatedUser: User}): Promise<void> {
|
|
const {oldUser, updatedUser} = params;
|
|
await this.dispatchUserUpdate(updatedUser);
|
|
if (hasPartialUserFieldsChanged(oldUser, updatedUser)) {
|
|
await propagatePartialUserChange(this.deps, updatedUser);
|
|
}
|
|
}
|
|
}
|