add isFromInstance role condition
This commit is contained in:
parent
b8558fd8db
commit
56a8ff4f50
5 changed files with 54 additions and 1 deletions
|
|
@ -248,6 +248,19 @@ export class RoleService implements OnApplicationShutdown, OnModuleInit {
|
|||
case 'isRemote': {
|
||||
return this.userEntityService.isRemoteUser(user);
|
||||
}
|
||||
// User is from a specific instance
|
||||
case 'isFromInstance': {
|
||||
if (user.host == null) {
|
||||
return false;
|
||||
}
|
||||
if (value.subdomains) {
|
||||
const userHost = '.' + user.host.toLowerCase();
|
||||
const targetHost = '.' + value.host.toLowerCase();
|
||||
return userHost.endsWith(targetHost);
|
||||
} else {
|
||||
return user.host.toLowerCase() === value.host.toLowerCase();
|
||||
}
|
||||
}
|
||||
// サスペンド済みユーザである
|
||||
case 'isSuspended': {
|
||||
return user.isSuspended;
|
||||
|
|
|
|||
|
|
@ -47,6 +47,15 @@ type CondFormulaValueIsRemote = {
|
|||
type: 'isRemote';
|
||||
};
|
||||
|
||||
/**
|
||||
* User is from a specific instance
|
||||
*/
|
||||
type CondFormulaValueIsFromInstance = {
|
||||
type: 'isFromInstance';
|
||||
host: string;
|
||||
subdomains: boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
* 既に指定のマニュアルロールにアサインされている場合のみ成立とする
|
||||
*/
|
||||
|
|
@ -160,6 +169,7 @@ export type RoleCondFormulaValue = { id: string } & (
|
|||
CondFormulaValueNot |
|
||||
CondFormulaValueIsLocal |
|
||||
CondFormulaValueIsRemote |
|
||||
CondFormulaValueIsFromInstance |
|
||||
CondFormulaValueIsSuspended |
|
||||
CondFormulaValueIsLocked |
|
||||
CondFormulaValueIsBot |
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue