mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-18 10:31:50 +08:00
feat(server): filter docs by access role (#12311)
close CLOUD-208 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Enhanced document access control with batch permission checks, enabling efficient filtering of documents based on user roles and permissions. - Added detailed document-level role and permission management for workspace users. - **Bug Fixes** - Improved accuracy in filtering search results to only display documents users have permission to read. - **Tests** - Added comprehensive tests for document-level permission filtering and search result accuracy. - Introduced new mock utilities to support permission-related test scenarios. - **Refactor** - Simplified and optimized permission logic for determining user roles and document access. - **Documentation** - Updated type definitions for improved clarity in permission handling. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -174,6 +174,18 @@ export class DocUserModel extends BaseModel {
|
||||
});
|
||||
}
|
||||
|
||||
async findMany(workspaceId: string, docIds: string[], userId: string) {
|
||||
return await this.db.workspaceDocUserRole.findMany({
|
||||
where: {
|
||||
workspaceId,
|
||||
docId: {
|
||||
in: docIds,
|
||||
},
|
||||
userId,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
count(workspaceId: string, docId: string) {
|
||||
return this.db.workspaceDocUserRole.count({
|
||||
where: {
|
||||
|
||||
Reference in New Issue
Block a user