mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 04:48:53 +00:00
fix(server): seat not allocated when new user invited to licensed workspace (#12322)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Bug Fixes** - Improved the accuracy of workspace member overcapacity calculation. - Corrected seat allocation handling for one-time license variants, ensuring proper event emission and bypassing unnecessary updates. - **Refactor** - Streamlined internal logic by removing an obsolete method related to seat count checks. - **Tests** - Removed a workspace member list pagination test to streamline end-to-end testing. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -144,8 +144,7 @@ export class QuotaService {
|
||||
: await this.getWorkspaceStorageUsage(workspaceId);
|
||||
const memberCount =
|
||||
await this.models.workspaceUser.chargedCount(workspaceId);
|
||||
const overcapacityMemberCount =
|
||||
await this.models.workspaceUser.insufficientSeatMemberCount(workspaceId);
|
||||
const overcapacityMemberCount = memberCount - quota.memberLimit;
|
||||
|
||||
return {
|
||||
...quota,
|
||||
|
||||
@@ -289,15 +289,6 @@ export class WorkspaceUserModel extends BaseModel {
|
||||
});
|
||||
}
|
||||
|
||||
async insufficientSeatMemberCount(workspaceId: string) {
|
||||
return this.db.workspaceUserRole.count({
|
||||
where: {
|
||||
workspaceId,
|
||||
status: WorkspaceMemberStatus.NeedMoreSeat,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async getUserActiveRoles(
|
||||
userId: string,
|
||||
filter: { role?: WorkspaceRole } = {}
|
||||
|
||||
@@ -288,6 +288,15 @@ export class LicenseService {
|
||||
return;
|
||||
}
|
||||
|
||||
if (license.variant === SubscriptionVariant.Onetime) {
|
||||
this.event.emit('workspace.members.allocateSeats', {
|
||||
workspaceId,
|
||||
quantity: license.quantity,
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const count = await this.models.workspaceUser.chargedCount(workspaceId);
|
||||
await this.fetchAffinePro(`/api/team/licenses/${license.key}/seats`, {
|
||||
method: 'POST',
|
||||
|
||||
Reference in New Issue
Block a user