enhance(role): ロールの割り当て時メモを残せるように (MisskeyIO#842)
This commit is contained in:
parent
346c848134
commit
6542ad4a12
14 changed files with 72 additions and 7 deletions
|
@ -488,7 +488,7 @@ export class RoleService implements OnApplicationShutdown, OnModuleInit {
|
|||
}
|
||||
|
||||
@bindThis
|
||||
public async assign(userId: MiUser['id'], roleId: MiRole['id'], expiresAt: Date | null = null, moderator?: MiUser): Promise<void> {
|
||||
public async assign(userId: MiUser['id'], roleId: MiRole['id'], memo: string | null = null, expiresAt: Date | null = null, moderator?: MiUser): Promise<void> {
|
||||
const now = Date.now();
|
||||
|
||||
const role = await this.rolesRepository.findOneByOrFail({ id: roleId });
|
||||
|
@ -512,6 +512,7 @@ export class RoleService implements OnApplicationShutdown, OnModuleInit {
|
|||
expiresAt: expiresAt,
|
||||
roleId: roleId,
|
||||
userId: userId,
|
||||
memo: memo,
|
||||
}).then(x => this.roleAssignmentsRepository.findOneByOrFail(x.identifiers[0]));
|
||||
|
||||
this.globalEventService.publishInternalEvent('userRoleAssigned', created);
|
||||
|
@ -521,9 +522,10 @@ export class RoleService implements OnApplicationShutdown, OnModuleInit {
|
|||
roleId: roleId,
|
||||
});
|
||||
}
|
||||
} else if (existing.expiresAt !== expiresAt) {
|
||||
} else if (existing.expiresAt !== expiresAt || existing.memo !== memo) {
|
||||
await this.roleAssignmentsRepository.update(existing.id, {
|
||||
expiresAt: expiresAt,
|
||||
memo: memo,
|
||||
});
|
||||
} else {
|
||||
throw new IdentifiableError('67d8689c-25c6-435f-8ced-631e4b81fce1', 'User is already assigned to this role.');
|
||||
|
@ -542,6 +544,7 @@ export class RoleService implements OnApplicationShutdown, OnModuleInit {
|
|||
userUsername: user.username,
|
||||
userHost: user.host,
|
||||
expiresAt: expiresAt ? expiresAt.toISOString() : null,
|
||||
memo: memo,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -582,6 +585,7 @@ export class RoleService implements OnApplicationShutdown, OnModuleInit {
|
|||
userId: userId,
|
||||
userUsername: user.username,
|
||||
userHost: user.host,
|
||||
memo: existing.memo,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue