[web] Enforce collaborator limit (#19619)
* Enables collaborator limit enforcement * Add pendingEditor_refs for editors downgraded during limit enforcement * Add isPendingEditor to useEditorContext --------- Co-authored-by: Thomas Mees <thomas.mees@overleaf.com> GitOrigin-RevId: b622213f6282ccd8ee85a23ceb29b8c6f8ff6a96
This commit is contained in:
committed by
Copybot
co-authored by
Thomas Mees
parent
18ee2bc87a
commit
5e2662adc4
@@ -415,6 +415,7 @@ const _ProjectController = {
|
||||
tokens: 1,
|
||||
tokenAccessReadAndWrite_refs: 1, // used for link sharing analytics
|
||||
collaberator_refs: 1, // used for link sharing analytics
|
||||
pendingEditor_refs: 1, // used for link sharing analytics
|
||||
}),
|
||||
userIsMemberOfGroupSubscription: sessionUser
|
||||
? (async () =>
|
||||
@@ -488,12 +489,24 @@ const _ProjectController = {
|
||||
anonRequestToken
|
||||
)
|
||||
|
||||
const linkSharingChanges =
|
||||
await SplitTestHandler.promises.getAssignmentForUser(
|
||||
const [linkSharingChanges, linkSharingEnforcement] = await Promise.all([
|
||||
SplitTestHandler.promises.getAssignmentForUser(
|
||||
project.owner_ref,
|
||||
'link-sharing-warning'
|
||||
)
|
||||
),
|
||||
SplitTestHandler.promises.getAssignmentForUser(
|
||||
project.owner_ref,
|
||||
'link-sharing-enforcement'
|
||||
),
|
||||
])
|
||||
|
||||
if (linkSharingChanges?.variant === 'active') {
|
||||
if (linkSharingEnforcement?.variant === 'active') {
|
||||
await Modules.promises.hooks.fire(
|
||||
'enforceCollaboratorLimit',
|
||||
projectId
|
||||
)
|
||||
}
|
||||
if (isTokenMember) {
|
||||
// Check explicitly that the user is in read write token refs, while this could be inferred
|
||||
// from the privilege level, the privilege level of token members might later be restricted
|
||||
@@ -570,12 +583,14 @@ const _ProjectController = {
|
||||
)
|
||||
const planLimit = ownerFeatures?.collaborators || 0
|
||||
const namedEditors = project.collaberator_refs?.length || 0
|
||||
const pendingEditors = project.pendingEditor_refs?.length || 0
|
||||
const exceedAtLimit = planLimit > -1 && namedEditors >= planLimit
|
||||
const projectOpenedSegmentation = {
|
||||
projectId: project._id,
|
||||
// temporary link sharing segmentation:
|
||||
linkSharingWarning: linkSharingChanges?.variant,
|
||||
namedEditors,
|
||||
pendingEditors,
|
||||
tokenEditors: project.tokenAccessReadAndWrite_refs?.length || 0,
|
||||
planLimit,
|
||||
exceedAtLimit,
|
||||
@@ -1034,7 +1049,6 @@ const ProjectController = {
|
||||
),
|
||||
updateProjectSettings: expressify(_ProjectController.updateProjectSettings),
|
||||
userProjectsJson: expressify(_ProjectController.userProjectsJson),
|
||||
|
||||
_buildProjectList: _ProjectController._buildProjectList,
|
||||
_buildProjectViewModel: _ProjectController._buildProjectViewModel,
|
||||
_injectProjectUsers: _ProjectController._injectProjectUsers,
|
||||
|
||||
Reference in New Issue
Block a user