Skip to content

Commit c13f8f4

Browse files
committed
feat: add user removal logic in UsersService
1 parent 0747f94 commit c13f8f4

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/modules/users/users.service.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ export class UsersService {
121121
this.eventBus.publish(new AddUserToNodeEvent(user.response.user));
122122
}
123123

124+
if (user.response.isNeedToBeRemovedFromNode) {
125+
this.eventBus.publish(new RemoveUserFromNodeEvent(user.response.user));
126+
}
127+
124128
this.eventEmitter.emit(
125129
EVENTS.USER.MODIFIED,
126130
new UserEvent(user.response.user, EVENTS.USER.MODIFIED),
@@ -141,6 +145,7 @@ export class UsersService {
141145
public async updateUserTransactional(dto: UpdateUserRequestDto): Promise<
142146
ICommandResponse<{
143147
isNeedToBeAddedToNode: boolean;
148+
isNeedToBeRemovedFromNode: boolean;
144149
user: UserWithActiveInboundsEntity;
145150
}>
146151
> {
@@ -171,6 +176,8 @@ export class UsersService {
171176
let isNeedToBeAddedToNode =
172177
user.status !== USERS_STATUS.ACTIVE && status === USERS_STATUS.ACTIVE;
173178

179+
const isNeedToBeRemovedFromNode = status !== USERS_STATUS.DISABLED;
180+
174181
if (trafficLimitBytes !== undefined) {
175182
if (user.status === USERS_STATUS.LIMITED && trafficLimitBytes >= 0) {
176183
if (
@@ -261,6 +268,7 @@ export class UsersService {
261268
response: {
262269
user: userWithInbounds,
263270
isNeedToBeAddedToNode,
271+
isNeedToBeRemovedFromNode,
264272
},
265273
};
266274
} catch (error) {

0 commit comments

Comments
 (0)