Merge upstream
This commit is contained in:
commit
5f931855be
147 changed files with 1778 additions and 1044 deletions
|
@ -155,10 +155,8 @@ export class RoleService implements OnApplicationShutdown, OnModuleInit {
|
|||
private moderationLogService: ModerationLogService,
|
||||
private fanoutTimelineService: FanoutTimelineService,
|
||||
) {
|
||||
//this.onMessage = this.onMessage.bind(this);
|
||||
|
||||
this.rolesCache = new MemorySingleCache<MiRole[]>(1000 * 60 * 60 * 1);
|
||||
this.roleAssignmentByUserIdCache = new MemoryKVCache<MiRoleAssignment[]>(1000 * 60 * 60 * 1);
|
||||
this.rolesCache = new MemorySingleCache<MiRole[]>(1000 * 60 * 60); // 1h
|
||||
this.roleAssignmentByUserIdCache = new MemoryKVCache<MiRoleAssignment[]>(1000 * 60 * 5); // 5m
|
||||
|
||||
this.redisForSub.on('message', this.onMessage);
|
||||
}
|
||||
|
@ -503,7 +501,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 });
|
||||
|
@ -527,6 +525,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);
|
||||
|
@ -536,9 +535,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.');
|
||||
|
@ -557,6 +557,7 @@ export class RoleService implements OnApplicationShutdown, OnModuleInit {
|
|||
userUsername: user.username,
|
||||
userHost: user.host,
|
||||
expiresAt: expiresAt ? expiresAt.toISOString() : null,
|
||||
memo: memo,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -597,6 +598,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