add isFromInstance role condition

This commit is contained in:
Hazelnoot 2025-05-09 21:03:05 -04:00
parent b8558fd8db
commit 56a8ff4f50
5 changed files with 54 additions and 1 deletions

View file

@ -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;