ProjectController.mjs 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330
  1. import _ from 'lodash'
  2. import OError from '@overleaf/o-error'
  3. import crypto from 'node:crypto'
  4. import { setTimeout } from 'node:timers/promises'
  5. import pProps from 'p-props'
  6. import logger from '@overleaf/logger'
  7. import { expressify } from '@overleaf/promise-utils'
  8. import mongodb from 'mongodb-legacy'
  9. import ProjectDeleter from './ProjectDeleter.mjs'
  10. import ProjectDuplicator from './ProjectDuplicator.mjs'
  11. import ProjectCreationHandler from './ProjectCreationHandler.mjs'
  12. import EditorController from '../Editor/EditorController.mjs'
  13. import ProjectHelper from './ProjectHelper.mjs'
  14. import metrics from '@overleaf/metrics'
  15. import { User } from '../../models/User.js'
  16. import SubscriptionLocator from '../Subscription/SubscriptionLocator.mjs'
  17. import { isPaidSubscription } from '../Subscription/SubscriptionHelper.js'
  18. import LimitationsManager from '../Subscription/LimitationsManager.mjs'
  19. import Settings from '@overleaf/settings'
  20. import AuthorizationManager from '../Authorization/AuthorizationManager.mjs'
  21. import InactiveProjectManager from '../InactiveData/InactiveProjectManager.mjs'
  22. import ProjectUpdateHandler from './ProjectUpdateHandler.mjs'
  23. import ProjectGetter from './ProjectGetter.mjs'
  24. import PrivilegeLevels from '../Authorization/PrivilegeLevels.js'
  25. import SessionManager from '../Authentication/SessionManager.mjs'
  26. import Sources from '../Authorization/Sources.mjs'
  27. import TokenAccessHandler from '../TokenAccess/TokenAccessHandler.mjs'
  28. import CollaboratorsGetter from '../Collaborators/CollaboratorsGetter.mjs'
  29. import ProjectEntityHandler from './ProjectEntityHandler.mjs'
  30. import TpdsProjectFlusher from '../ThirdPartyDataStore/TpdsProjectFlusher.mjs'
  31. import Features from '../../infrastructure/Features.js'
  32. import BrandVariationsHandler from '../BrandVariations/BrandVariationsHandler.mjs'
  33. import UserController from '../User/UserController.mjs'
  34. import AnalyticsManager from '../Analytics/AnalyticsManager.mjs'
  35. import SplitTestHandler from '../SplitTests/SplitTestHandler.mjs'
  36. import SplitTestSessionHandler from '../SplitTests/SplitTestSessionHandler.mjs'
  37. import FeaturesUpdater from '../Subscription/FeaturesUpdater.mjs'
  38. import SpellingHandler from '../Spelling/SpellingHandler.mjs'
  39. import AdminAuthorizationHelper from '../Helpers/AdminAuthorizationHelper.mjs'
  40. import InstitutionsFeatures from '../Institutions/InstitutionsFeatures.mjs'
  41. import InstitutionsGetter from '../Institutions/InstitutionsGetter.mjs'
  42. import ProjectAuditLogHandler from './ProjectAuditLogHandler.mjs'
  43. import PublicAccessLevels from '../Authorization/PublicAccessLevels.mjs'
  44. import TagsHandler from '../Tags/TagsHandler.mjs'
  45. import TutorialHandler from '../Tutorial/TutorialHandler.mjs'
  46. import UserUpdater from '../User/UserUpdater.mjs'
  47. import Modules from '../../infrastructure/Modules.js'
  48. import { z, zz, validateReq } from '../../infrastructure/Validation.js'
  49. import UserGetter from '../User/UserGetter.mjs'
  50. import { isStandaloneAiAddOnPlanCode } from '../Subscription/AiHelper.js'
  51. import SubscriptionController from '../Subscription/SubscriptionController.mjs'
  52. import { formatCurrency } from '../../util/currency.js'
  53. import UserSettingsHelper from './UserSettingsHelper.mjs'
  54. const { hasAdminAccess } = AdminAuthorizationHelper
  55. const { ObjectId } = mongodb
  56. /**
  57. * @import { GetProjectsRequest, GetProjectsResponse, Project } from "./types"
  58. */
  59. const updateProjectAdminSettingsSchema = z.object({
  60. params: z.object({
  61. Project_id: zz.coercedObjectId(ObjectId),
  62. }),
  63. body: z.object({
  64. publicAccessLevel: z
  65. .enum(
  66. [PublicAccessLevels.PRIVATE, PublicAccessLevels.TOKEN_BASED],
  67. 'unexpected access level'
  68. )
  69. .optional(),
  70. }),
  71. })
  72. const updateProjectSettingsSchema = z.object({
  73. params: z.object({
  74. Project_id: zz.coercedObjectId(),
  75. }),
  76. body: z.object({
  77. compiler: z.string().optional(),
  78. imageName: z.string().optional(),
  79. mainBibliographyDocId: zz.objectId().optional(),
  80. name: z.string().optional(),
  81. rootDocId: zz.objectId().optional(),
  82. spellCheckLanguage: z.string().optional(),
  83. }),
  84. })
  85. const _ProjectController = {
  86. _isInPercentageRollout(rolloutName, objectId, percentage) {
  87. if (Settings.bypassPercentageRollouts === true) {
  88. return true
  89. }
  90. const data = `${rolloutName}:${objectId.toString()}`
  91. const md5hash = crypto.createHash('md5').update(data).digest('hex')
  92. const counter = parseInt(md5hash.slice(26, 32), 16)
  93. return counter % 100 < percentage
  94. },
  95. async updateProjectSettings(req, res) {
  96. const { params, body } = validateReq(req, updateProjectSettingsSchema)
  97. const projectId = params.Project_id
  98. if (body.compiler != null) {
  99. await EditorController.promises.setCompiler(projectId, body.compiler)
  100. }
  101. if (body.imageName != null) {
  102. await EditorController.promises.setImageName(projectId, body.imageName)
  103. }
  104. if (body.name != null) {
  105. await EditorController.promises.renameProject(projectId, body.name)
  106. }
  107. if (body.spellCheckLanguage != null) {
  108. await EditorController.promises.setSpellCheckLanguage(
  109. projectId,
  110. body.spellCheckLanguage
  111. )
  112. }
  113. if (body.rootDocId != null) {
  114. await EditorController.promises.setRootDoc(projectId, body.rootDocId)
  115. }
  116. if (body.mainBibliographyDocId != null) {
  117. await EditorController.promises.setMainBibliographyDoc(
  118. projectId,
  119. body.mainBibliographyDocId
  120. )
  121. }
  122. res.sendStatus(204)
  123. },
  124. async updateProjectAdminSettings(req, res) {
  125. const { params, body } = validateReq(req, updateProjectAdminSettingsSchema)
  126. const projectId = params.Project_id
  127. const user = SessionManager.getSessionUser(req.session)
  128. if (!Features.hasFeature('link-sharing')) {
  129. return res.sendStatus(403) // return Forbidden if link sharing is not enabled
  130. }
  131. if (body.publicAccessLevel != null) {
  132. await EditorController.promises.setPublicAccessLevel(
  133. projectId,
  134. body.publicAccessLevel
  135. )
  136. await ProjectAuditLogHandler.promises.addEntry(
  137. projectId,
  138. 'toggle-access-level',
  139. user._id,
  140. req.ip,
  141. { publicAccessLevel: body.publicAccessLevel, status: 'OK' }
  142. )
  143. res.sendStatus(204)
  144. } else {
  145. res.sendStatus(500)
  146. }
  147. },
  148. async deleteProject(req, res) {
  149. const projectId = req.params.Project_id
  150. const user = SessionManager.getSessionUser(req.session)
  151. await ProjectDeleter.promises.deleteProject(projectId, {
  152. deleterUser: user,
  153. ipAddress: req.ip,
  154. })
  155. res.sendStatus(200)
  156. },
  157. async archiveProject(req, res) {
  158. const projectId = req.params.Project_id
  159. const userId = SessionManager.getLoggedInUserId(req.session)
  160. await ProjectDeleter.promises.archiveProject(projectId, userId)
  161. res.sendStatus(200)
  162. },
  163. async unarchiveProject(req, res) {
  164. const projectId = req.params.Project_id
  165. const userId = SessionManager.getLoggedInUserId(req.session)
  166. await ProjectDeleter.promises.unarchiveProject(projectId, userId)
  167. res.sendStatus(200)
  168. },
  169. async trashProject(req, res) {
  170. const projectId = req.params.project_id
  171. const userId = SessionManager.getLoggedInUserId(req.session)
  172. await ProjectDeleter.promises.trashProject(projectId, userId)
  173. res.sendStatus(200)
  174. },
  175. async untrashProject(req, res) {
  176. const projectId = req.params.project_id
  177. const userId = SessionManager.getLoggedInUserId(req.session)
  178. await ProjectDeleter.promises.untrashProject(projectId, userId)
  179. res.sendStatus(200)
  180. },
  181. async expireDeletedProjectsAfterDuration(_req, res) {
  182. await ProjectDeleter.promises.expireDeletedProjectsAfterDuration()
  183. res.sendStatus(200)
  184. },
  185. async expireDeletedProject(req, res) {
  186. const { projectId } = req.params
  187. await ProjectDeleter.promises.expireDeletedProject(projectId)
  188. res.sendStatus(200)
  189. },
  190. async restoreProject(req, res) {
  191. const projectId = req.params.Project_id
  192. await ProjectDeleter.promises.restoreProject(projectId)
  193. res.sendStatus(200)
  194. },
  195. async cloneProject(req, res, next) {
  196. res.setTimeout(5 * 60 * 1000) // allow extra time for the copy to complete
  197. metrics.inc('cloned-project')
  198. const projectId = req.params.Project_id
  199. const { projectName, tags } = req.body
  200. logger.debug({ projectId, projectName }, 'cloning project')
  201. if (!SessionManager.isUserLoggedIn(req.session)) {
  202. return res.json({ redir: '/register' })
  203. }
  204. const currentUser = SessionManager.getSessionUser(req.session)
  205. const { first_name: firstName, last_name: lastName, email } = currentUser
  206. try {
  207. const project = await ProjectDuplicator.promises.duplicate(
  208. currentUser,
  209. projectId,
  210. projectName,
  211. tags
  212. )
  213. res.json({
  214. name: project.name,
  215. lastUpdated: project.lastUpdated,
  216. project_id: project._id,
  217. owner_ref: project.owner_ref,
  218. owner: {
  219. first_name: firstName,
  220. last_name: lastName,
  221. email,
  222. _id: currentUser._id,
  223. },
  224. })
  225. } catch (err) {
  226. OError.tag(err, 'error cloning project', {
  227. projectId,
  228. userId: currentUser._id,
  229. })
  230. return next(err)
  231. }
  232. },
  233. async newProject(req, res) {
  234. const currentUser = SessionManager.getSessionUser(req.session)
  235. const {
  236. first_name: firstName,
  237. last_name: lastName,
  238. email,
  239. _id: userId,
  240. } = currentUser
  241. const projectName =
  242. req.body.projectName != null ? req.body.projectName.trim() : undefined
  243. const { template } = req.body
  244. const project = await (template === 'example'
  245. ? ProjectCreationHandler.promises.createExampleProject(
  246. userId,
  247. projectName
  248. )
  249. : ProjectCreationHandler.promises.createBasicProject(userId, projectName))
  250. ProjectAuditLogHandler.addEntryIfManagedInBackground(
  251. project._id,
  252. 'project-created',
  253. project.owner_ref,
  254. req.ip
  255. )
  256. res.json({
  257. project_id: project._id,
  258. owner_ref: project.owner_ref,
  259. owner: {
  260. first_name: firstName,
  261. last_name: lastName,
  262. email,
  263. _id: userId,
  264. },
  265. })
  266. },
  267. async renameProject(req, res) {
  268. const projectId = req.params.Project_id
  269. const newName = req.body.newProjectName
  270. await EditorController.promises.renameProject(projectId, newName)
  271. res.sendStatus(200)
  272. },
  273. async userProjectsJson(req, res) {
  274. const userId = SessionManager.getLoggedInUserId(req.session)
  275. let projects = await ProjectGetter.promises.findAllUsersProjects(
  276. userId,
  277. 'name lastUpdated publicAccesLevel archived trashed owner_ref'
  278. )
  279. // _buildProjectList already converts archived/trashed to booleans so isArchivedOrTrashed should not be used here
  280. projects = ProjectController._buildProjectList(projects, userId)
  281. .filter(p => !(p.archived || p.trashed))
  282. .map(p => ({ _id: p.id, name: p.name, accessLevel: p.accessLevel }))
  283. res.json({ projects })
  284. },
  285. async projectEntitiesJson(req, res) {
  286. const projectId = req.params.Project_id
  287. const project = await ProjectGetter.promises.getProject(projectId)
  288. const { docs, files } =
  289. ProjectEntityHandler.getAllEntitiesFromProject(project)
  290. const entities = docs
  291. .concat(files)
  292. // Sort by path ascending
  293. .sort((a, b) => (a.path > b.path ? 1 : a.path < b.path ? -1 : 0))
  294. .map(e => ({
  295. path: e.path,
  296. type: e.doc != null ? 'doc' : 'file',
  297. }))
  298. res.json({ project_id: projectId, entities })
  299. },
  300. async loadEditor(req, res, next) {
  301. const timer = new metrics.Timer('load-editor')
  302. if (!Settings.editorIsOpen) {
  303. return res.render('general/closed', { title: 'updating_site' })
  304. }
  305. let anonymous, userId, sessionUser
  306. if (SessionManager.isUserLoggedIn(req.session)) {
  307. sessionUser = SessionManager.getSessionUser(req.session)
  308. userId = SessionManager.getLoggedInUserId(req.session)
  309. anonymous = false
  310. } else {
  311. sessionUser = null
  312. anonymous = true
  313. userId = null
  314. }
  315. if (Features.hasFeature('saas') && userId) {
  316. const { variant: domainCaptureRedirect } =
  317. await SplitTestHandler.promises.getAssignment(
  318. req,
  319. res,
  320. 'domain-capture-redirect'
  321. )
  322. if (domainCaptureRedirect === 'enabled') {
  323. const subscription = (
  324. await Modules.promises.hooks.fire(
  325. 'findDomainCaptureGroupUserCouldBePartOf',
  326. userId
  327. )
  328. )?.[0]
  329. if (subscription) {
  330. if (subscription.managedUsersEnabled) {
  331. return res.redirect('/domain-capture')
  332. } else {
  333. // TODO show notification or anything else
  334. }
  335. }
  336. }
  337. }
  338. const projectId = req.params.Project_id
  339. // should not be used in place of split tests query param overrides (?my-split-test-name=my-variant)
  340. function shouldDisplayFeature(name, variantFlag) {
  341. if (req.query && req.query[name]) {
  342. return req.query[name] === 'true'
  343. } else {
  344. return variantFlag === true
  345. }
  346. }
  347. const splitTests = [
  348. 'compile-log-events',
  349. 'visual-preview',
  350. 'external-socket-heartbeat',
  351. 'null-test-share-modal',
  352. 'pdf-caching-cached-url-lookup',
  353. 'pdf-caching-mode',
  354. 'pdf-caching-prefetch-large',
  355. 'pdf-caching-prefetching',
  356. 'revert-file',
  357. 'revert-project',
  358. !anonymous && 'ro-mirror-on-client',
  359. 'track-pdf-download',
  360. !anonymous && 'writefull-oauth-promotion',
  361. 'hotjar',
  362. 'editor-redesign',
  363. 'overleaf-assist-bundle',
  364. 'word-count-client',
  365. 'editor-popup-ux-survey',
  366. 'editor-redesign-new-users',
  367. 'writefull-frontend-migration',
  368. 'chat-edit-delete',
  369. 'compile-timeout-remove-info',
  370. 'ai-workbench',
  371. 'compile-timeout-target-plans',
  372. ].filter(Boolean)
  373. const getUserValues = async userId =>
  374. pProps(
  375. _.mapValues({
  376. user: (async () => {
  377. const user = await User.findById(
  378. userId,
  379. 'email first_name last_name referal_id signUpDate featureSwitches features featuresEpoch refProviders alphaProgram betaProgram isAdmin ace labsProgram labsExperiments completedTutorials writefull aiErrorAssistant'
  380. ).exec()
  381. // Handle case of deleted user
  382. if (!user) {
  383. UserController.logout(req, res, next)
  384. return
  385. }
  386. logger.debug({ projectId, userId }, 'got user')
  387. return FeaturesUpdater.featuresEpochIsCurrent(user)
  388. ? user
  389. : await ProjectController._refreshFeatures(req, user)
  390. })(),
  391. learnedWords: SpellingHandler.promises.getUserDictionary(userId),
  392. projectTags: TagsHandler.promises.getTagsForProject(
  393. userId,
  394. projectId
  395. ),
  396. userHasInstitutionLicence: InstitutionsFeatures.promises
  397. .hasLicence(userId)
  398. .catch(err => {
  399. logger.error({ err, userId }, 'failed to get institution licence')
  400. return false
  401. }),
  402. affiliations: InstitutionsGetter.promises
  403. .getCurrentAffiliations(userId)
  404. .catch(err => {
  405. logger.error({ err, userId }, 'failed to get institution licence')
  406. return false
  407. }),
  408. subscription:
  409. SubscriptionLocator.promises.getUsersSubscription(userId),
  410. isTokenMember: CollaboratorsGetter.promises.userIsTokenMember(
  411. userId,
  412. projectId
  413. ),
  414. isInvitedMember:
  415. CollaboratorsGetter.promises.isUserInvitedMemberOfProject(
  416. userId,
  417. projectId
  418. ),
  419. })
  420. )
  421. try {
  422. const responses = await pProps({
  423. userValues: userId ? getUserValues(userId) : defaultUserValues(),
  424. project: ProjectGetter.promises.getProject(projectId, {
  425. name: 1,
  426. lastUpdated: 1,
  427. track_changes: 1,
  428. owner_ref: 1,
  429. brandVariationId: 1,
  430. overleaf: 1,
  431. tokens: 1,
  432. tokenAccessReadAndWrite_refs: 1, // used for link sharing analytics
  433. collaberator_refs: 1, // used for link sharing analytics
  434. pendingEditor_refs: 1, // used for link sharing analytics
  435. reviewer_refs: 1,
  436. }),
  437. userIsMemberOfGroupSubscription: sessionUser
  438. ? (async () =>
  439. (
  440. await LimitationsManager.promises.userIsMemberOfGroupSubscription(
  441. sessionUser
  442. )
  443. ).isMember)()
  444. : false,
  445. _flushToTpds:
  446. TpdsProjectFlusher.promises.flushProjectToTpdsIfNeeded(projectId),
  447. _activate:
  448. InactiveProjectManager.promises.reactivateProjectIfRequired(
  449. projectId
  450. ),
  451. })
  452. const { project, userValues, userIsMemberOfGroupSubscription } = responses
  453. const {
  454. user,
  455. learnedWords,
  456. projectTags,
  457. userHasInstitutionLicence,
  458. subscription,
  459. isTokenMember,
  460. isInvitedMember,
  461. affiliations,
  462. } = userValues
  463. let inEnterpriseCommons = false
  464. for (const affiliation of affiliations || []) {
  465. inEnterpriseCommons =
  466. inEnterpriseCommons || affiliation.institution?.enterpriseCommons
  467. }
  468. const getSplitTestAssignment = async splitTest => {
  469. return await SplitTestHandler.promises.getAssignment(
  470. req,
  471. res,
  472. splitTest
  473. )
  474. }
  475. const splitTestAssignments = {}
  476. await Promise.all(
  477. splitTests.map(async splitTest => {
  478. splitTestAssignments[splitTest] =
  479. await getSplitTestAssignment(splitTest)
  480. })
  481. )
  482. const brandVariation = project?.brandVariationId
  483. ? await BrandVariationsHandler.promises.getBrandVariationById(
  484. project.brandVariationId
  485. )
  486. : undefined
  487. const anonRequestToken = TokenAccessHandler.getRequestToken(
  488. req,
  489. projectId
  490. )
  491. const imageNames = ProjectHelper.getAllowedImagesForUser(user)
  492. const privilegeLevel =
  493. await AuthorizationManager.promises.getPrivilegeLevelForProject(
  494. userId,
  495. projectId,
  496. anonRequestToken
  497. )
  498. await Modules.promises.hooks.fire('enforceCollaboratorLimit', projectId)
  499. if (isTokenMember) {
  500. // Check explicitly that the user is in read write token refs, while this could be inferred
  501. // from the privilege level, the privilege level of token members might later be restricted
  502. const isReadWriteTokenMember =
  503. await CollaboratorsGetter.promises.userIsReadWriteTokenMember(
  504. userId,
  505. projectId
  506. )
  507. if (isReadWriteTokenMember) {
  508. // Check for an edge case where a user is both in read write token access refs but also
  509. // an invited read write member. Ensure they are not redirected to the sharing updates page
  510. // We could also delete the token access ref if the user is already a member of the project
  511. const isInvitedReadWriteMember =
  512. await CollaboratorsGetter.promises.isUserInvitedReadWriteMemberOfProject(
  513. userId,
  514. projectId
  515. )
  516. if (!isInvitedReadWriteMember) {
  517. return res.redirect(`/project/${projectId}/sharing-updates`)
  518. }
  519. }
  520. }
  521. if (privilegeLevel == null || privilegeLevel === PrivilegeLevels.NONE) {
  522. return res.sendStatus(401)
  523. }
  524. const allowedFreeTrial =
  525. subscription == null ||
  526. isStandaloneAiAddOnPlanCode(subscription.planCode)
  527. let wsUrl = Settings.wsUrl
  528. let metricName = 'load-editor-ws'
  529. if (user.betaProgram && Settings.wsUrlBeta !== undefined) {
  530. wsUrl = Settings.wsUrlBeta
  531. metricName += '-beta'
  532. } else if (
  533. Settings.wsUrlV2 &&
  534. Settings.wsUrlV2Percentage > 0 &&
  535. (new ObjectId(projectId).getTimestamp() / 1000) % 100 <
  536. Settings.wsUrlV2Percentage
  537. ) {
  538. wsUrl = Settings.wsUrlV2
  539. metricName += '-v2'
  540. }
  541. if (req.query && req.query.ws === 'fallback') {
  542. // `?ws=fallback` will connect to the bare origin, and ignore
  543. // the custom wsUrl. Hence it must load the client side
  544. // javascript from there too.
  545. // Not resetting it here would possibly load a socket.io v2
  546. // client and connect to a v0 endpoint.
  547. wsUrl = undefined
  548. metricName += '-fallback'
  549. }
  550. metrics.inc(metricName)
  551. // don't need to wait for these to complete
  552. ProjectUpdateHandler.promises
  553. .markAsOpened(projectId)
  554. .catch(err =>
  555. logger.error({ err, projectId }, 'failed to mark project as opened')
  556. )
  557. SplitTestSessionHandler.promises
  558. .sessionMaintenance(req, userId ? user : null)
  559. .catch(err =>
  560. logger.error({ err }, 'failed to update split test info in session')
  561. )
  562. const ownerFeatures = await UserGetter.promises.getUserFeatures(
  563. project.owner_ref
  564. )
  565. if (userId) {
  566. const planLimit = ownerFeatures?.collaborators || 0
  567. const namedEditors = project.collaberator_refs?.length || 0
  568. const pendingEditors = project.pendingEditor_refs?.length || 0
  569. const exceedAtLimit = planLimit > -1 && namedEditors >= planLimit
  570. let mode = 'edit'
  571. if (privilegeLevel === PrivilegeLevels.READ_ONLY) {
  572. mode = 'view'
  573. } else if (
  574. project.track_changes === true ||
  575. project.track_changes?.[userId] === true
  576. ) {
  577. mode = 'review'
  578. }
  579. const projectOpenedSegmentation = {
  580. role: privilegeLevel,
  581. mode,
  582. ownerId: project.owner_ref,
  583. projectId: project._id,
  584. namedEditors,
  585. pendingEditors,
  586. tokenEditors: project.tokenAccessReadAndWrite_refs?.length || 0,
  587. planLimit,
  588. exceedAtLimit,
  589. }
  590. AnalyticsManager.recordEventForUserInBackground(
  591. userId,
  592. 'project-opened',
  593. projectOpenedSegmentation
  594. )
  595. User.updateOne(
  596. { _id: new ObjectId(userId) },
  597. { $set: { lastActive: new Date() } }
  598. )
  599. .exec()
  600. .catch(err =>
  601. logger.error(
  602. { err, userId },
  603. 'failed to update lastActive for user'
  604. )
  605. )
  606. }
  607. const isAdminOrTemplateOwner =
  608. hasAdminAccess(user) || Settings.templates?.user_id === userId
  609. const showTemplatesServerPro =
  610. Features.hasFeature('templates-server-pro') && isAdminOrTemplateOwner
  611. const debugPdfDetach = shouldDisplayFeature('debug_pdf_detach')
  612. const detachRole = req.params.detachRole
  613. const showSymbolPalette =
  614. !Features.hasFeature('saas') ||
  615. (user.features && user.features.symbolPalette)
  616. const userInNonIndividualSub =
  617. userIsMemberOfGroupSubscription || userHasInstitutionLicence
  618. const userHasPremiumSub =
  619. subscription && !isStandaloneAiAddOnPlanCode(subscription.planCode)
  620. // Persistent upgrade prompts
  621. // in header & in share project modal
  622. const showUpgradePrompt =
  623. Features.hasFeature('saas') &&
  624. userId &&
  625. !userHasPremiumSub &&
  626. !userInNonIndividualSub
  627. let aiFeaturesAllowed = false
  628. if (userId && Features.hasFeature('saas')) {
  629. try {
  630. // exit early if the user couldnt use ai anyways, since permissions checks are expensive
  631. const canUserWriteOrReviewProjectContent =
  632. privilegeLevel === PrivilegeLevels.READ_AND_WRITE ||
  633. privilegeLevel === PrivilegeLevels.OWNER ||
  634. privilegeLevel === PrivilegeLevels.REVIEW
  635. if (canUserWriteOrReviewProjectContent) {
  636. // check permissions for user and project owner, to see if they allow AI on the project
  637. const permissionsResults = await Modules.promises.hooks.fire(
  638. 'projectAllowsCapability',
  639. project,
  640. userId,
  641. ['use-ai']
  642. )
  643. const aiAllowed = permissionsResults.every(
  644. result => result === true
  645. )
  646. aiFeaturesAllowed = aiAllowed
  647. }
  648. } catch (err) {
  649. // still allow users to access project if we cant get their permissions, but disable AI feature
  650. aiFeaturesAllowed = false
  651. }
  652. }
  653. let featureUsage = {}
  654. if (Features.hasFeature('saas')) {
  655. const usagesLeft = await Modules.promises.hooks.fire(
  656. 'remainingFeatureAllocation',
  657. userId
  658. )
  659. usagesLeft?.forEach(usage => {
  660. featureUsage = { ...featureUsage, ...usage }
  661. })
  662. }
  663. await ProjectController._setWritefullTrialState(
  664. user,
  665. userValues,
  666. userId,
  667. aiFeaturesAllowed,
  668. userIsMemberOfGroupSubscription
  669. )
  670. const template =
  671. detachRole === 'detached'
  672. ? 'project/ide-react-detached'
  673. : 'project/ide-react'
  674. const capabilities = [...req.capabilitySet]
  675. // make sure the capability is added to CE/SP when the feature is enabled
  676. if (!Features.hasFeature('saas') && Features.hasFeature('chat')) {
  677. capabilities.push('chat')
  678. }
  679. // Note: this is not part of the default capabilities in the backend.
  680. // See services/web/modules/group-settings/app/src/DefaultGroupPolicy.mjs.
  681. // We are only using it on the frontend at the moment.
  682. // Add !Features.hasFeature('saas') to the conditional, as for chat above
  683. // if you define the capability in the backend.
  684. if (Features.hasFeature('link-sharing')) {
  685. capabilities.push('link-sharing')
  686. }
  687. const isOverleafAssistBundleEnabled =
  688. splitTestAssignments['overleaf-assist-bundle']?.variant === 'enabled'
  689. let fullFeatureSet = user?.features
  690. if (!anonymous) {
  691. fullFeatureSet = await UserGetter.promises.getUserFeatures(userId)
  692. }
  693. const hasPaidSubscription = isPaidSubscription(subscription)
  694. const hasManuallyCollectedSubscription =
  695. subscription?.collectionMethod === 'manual'
  696. const assistantDisabled = user.aiErrorAssistant?.enabled === false // the assistant has been manually disabled by the user
  697. const canUseErrorAssistant =
  698. (!hasManuallyCollectedSubscription ||
  699. fullFeatureSet?.aiErrorAssistant) &&
  700. !assistantDisabled
  701. const customerIoEnabled =
  702. await SplitTestHandler.promises.hasUserBeenAssignedToVariant(
  703. req,
  704. userId,
  705. 'customer-io-trial-conversion',
  706. 'enabled',
  707. true
  708. )
  709. const addonPrices =
  710. isOverleafAssistBundleEnabled &&
  711. (await ProjectController._getAddonPrices(req, res))
  712. let standardPlanPricing
  713. let recommendedCurrency
  714. if (Features.hasFeature('saas')) {
  715. standardPlanPricing = await ProjectController._getPlanPricing(
  716. req,
  717. res,
  718. 'collaborator'
  719. )
  720. const { currency } =
  721. await SubscriptionController.getRecommendedCurrency(req, res)
  722. recommendedCurrency = currency
  723. }
  724. let planCode = subscription?.planCode
  725. if (!planCode && !userInNonIndividualSub) {
  726. planCode = 'personal'
  727. }
  728. const planDetails = Settings.plans.find(p => p.planCode === planCode)
  729. const shouldLoadHotjar =
  730. splitTestAssignments['compile-timeout-target-plans']?.variant ===
  731. 'enabled' &&
  732. !userHasPremiumSub &&
  733. !userInNonIndividualSub
  734. res.render(template, {
  735. title: project.name,
  736. priority_title: true,
  737. bodyClasses: ['editor'],
  738. project_id: project._id,
  739. projectName: project.name,
  740. canUseClsiCache:
  741. Features.hasFeature('saas') &&
  742. ownerFeatures?.compileGroup === 'priority',
  743. user: {
  744. id: userId,
  745. email: user.email,
  746. first_name: user.first_name,
  747. last_name: user.last_name,
  748. referal_id: user.referal_id,
  749. signUpDate: user.signUpDate,
  750. allowedFreeTrial,
  751. hasPaidSubscription,
  752. featureSwitches: user.featureSwitches,
  753. features: fullFeatureSet,
  754. featureUsage,
  755. refProviders: _.mapValues(user.refProviders, Boolean),
  756. writefull: {
  757. enabled: Boolean(user.writefull?.enabled && aiFeaturesAllowed),
  758. autoCreatedAccount: Boolean(user.writefull?.autoCreatedAccount),
  759. firstAutoLoad: Boolean(user.writefull?.firstAutoLoad),
  760. },
  761. alphaProgram: user.alphaProgram,
  762. betaProgram: user.betaProgram,
  763. labsProgram: user.labsProgram,
  764. inactiveTutorials: TutorialHandler.getInactiveTutorials(user),
  765. isAdmin: hasAdminAccess(user),
  766. planCode,
  767. planName: planDetails?.name,
  768. isAnnualPlan: planCode && planDetails?.annual,
  769. isMemberOfGroupSubscription: userIsMemberOfGroupSubscription,
  770. hasInstitutionLicence: userHasInstitutionLicence,
  771. },
  772. userSettings: UserSettingsHelper.buildUserSettings(user),
  773. labsExperiments: user.labsExperiments ?? [],
  774. privilegeLevel,
  775. anonymous,
  776. isTokenMember,
  777. isRestrictedTokenMember: AuthorizationManager.isRestrictedUser(
  778. userId,
  779. privilegeLevel,
  780. isTokenMember,
  781. isInvitedMember
  782. ),
  783. capabilities,
  784. roMirrorOnClientNoLocalStorage:
  785. Settings.adminOnlyLogin || project.name.startsWith('Debug: '),
  786. languages: Settings.languages,
  787. learnedWords,
  788. editorThemes: THEME_LIST,
  789. legacyEditorThemes: LEGACY_THEME_LIST,
  790. maxDocLength: Settings.max_doc_length,
  791. maxReconnectGracefullyIntervalMs:
  792. Settings.maxReconnectGracefullyIntervalMs,
  793. brandVariation,
  794. imageNames,
  795. gitBridgePublicBaseUrl: Settings.gitBridgePublicBaseUrl,
  796. gitBridgeEnabled: Features.hasFeature('git-bridge'),
  797. wsUrl,
  798. showSupport: Features.hasFeature('support'),
  799. showTemplatesServerPro,
  800. debugPdfDetach,
  801. showSymbolPalette,
  802. symbolPaletteAvailable: Features.hasFeature('symbol-palette'),
  803. userRestrictions: Array.from(req.userRestrictions || []),
  804. showAiErrorAssistant: aiFeaturesAllowed && canUseErrorAssistant,
  805. detachRole,
  806. metadata: { viewport: false },
  807. showUpgradePrompt,
  808. fixedSizeDocument: true,
  809. hasTrackChangesFeature: Features.hasFeature('track-changes'),
  810. otMigrationStage: project.overleaf?.history?.otMigrationStage ?? 0,
  811. projectTags,
  812. isSaas: Features.hasFeature('saas'),
  813. shouldLoadHotjar,
  814. isOverleafAssistBundleEnabled,
  815. customerIoEnabled,
  816. addonPrices,
  817. compileSettings: {
  818. compileTimeout: ownerFeatures?.compileTimeout,
  819. },
  820. standardPlanPricing,
  821. recommendedCurrency,
  822. })
  823. timer.done()
  824. } catch (err) {
  825. OError.tag(err, 'error getting details for project page')
  826. return next(err)
  827. }
  828. },
  829. async _getPlanPricing(req, res, plan = 'collaborator') {
  830. const locale = req.i18n.language
  831. const { currency } = await SubscriptionController.getRecommendedCurrency(
  832. req,
  833. res
  834. )
  835. const pricingForCurrency = Settings.localizedPlanPricing[currency]
  836. if (!pricingForCurrency) {
  837. return null
  838. }
  839. const planPricing = pricingForCurrency[plan]
  840. if (!planPricing) {
  841. return null
  842. }
  843. return {
  844. monthly: formatCurrency(planPricing.monthly, currency, locale, true),
  845. annual: formatCurrency(planPricing.annual, currency, locale, true),
  846. monthlyTimesTwelve: formatCurrency(
  847. planPricing.monthlyTimesTwelve,
  848. currency,
  849. locale,
  850. true
  851. ),
  852. }
  853. },
  854. async _getAddonPrices(req, res, addonPlans = ['assistant']) {
  855. const plansData = {}
  856. const locale = req.i18n.language
  857. const { currency } = await SubscriptionController.getRecommendedCurrency(
  858. req,
  859. res
  860. )
  861. addonPlans.forEach(plan => {
  862. const annualPrice = Settings.localizedAddOnsPricing[currency][plan].annual
  863. const monthlyPrice =
  864. Settings.localizedAddOnsPricing[currency][plan].monthly
  865. const annualDividedByTwelve =
  866. Settings.localizedAddOnsPricing[currency][plan].annualDividedByTwelve
  867. plansData[plan] = {
  868. annual: formatCurrency(annualPrice, currency, locale, true),
  869. annualDividedByTwelve: formatCurrency(
  870. annualDividedByTwelve,
  871. currency,
  872. locale,
  873. true
  874. ),
  875. monthly: formatCurrency(monthlyPrice, currency, locale, true),
  876. }
  877. })
  878. return plansData
  879. },
  880. async _refreshFeatures(req, user) {
  881. // If the feature refresh has failed in this session, don't retry
  882. // it - require the user to log in again.
  883. if (req.session.feature_refresh_failed) {
  884. metrics.inc('features-refresh', 1, {
  885. path: 'load-editor',
  886. status: 'skipped',
  887. })
  888. return user
  889. }
  890. // If the refresh takes too long then return the current
  891. // features. Note that the user.features property may still be
  892. // updated in the background after the promise is resolved.
  893. const abortController = new AbortController()
  894. const refreshTimeoutHandler = async () => {
  895. await setTimeout(5000, { signal: abortController.signal })
  896. req.session.feature_refresh_failed = {
  897. reason: 'timeout',
  898. at: new Date(),
  899. }
  900. metrics.inc('features-refresh', 1, {
  901. path: 'load-editor',
  902. status: 'timeout',
  903. })
  904. return user
  905. }
  906. // try to refresh user features now
  907. const timer = new metrics.Timer('features-refresh-on-load-editor')
  908. return Promise.race([
  909. refreshTimeoutHandler(),
  910. (async () => {
  911. try {
  912. user.features = await FeaturesUpdater.promises.refreshFeatures(
  913. user._id,
  914. 'load-editor'
  915. )
  916. metrics.inc('features-refresh', 1, {
  917. path: 'load-editor',
  918. status: 'success',
  919. })
  920. } catch (err) {
  921. // keep a record to prevent unneceary retries and leave
  922. // the original features unmodified if the refresh failed
  923. req.session.feature_refresh_failed = {
  924. reason: 'error',
  925. at: new Date(),
  926. }
  927. metrics.inc('features-refresh', 1, {
  928. path: 'load-editor',
  929. status: 'error',
  930. })
  931. }
  932. abortController.abort()
  933. timer.done()
  934. return user
  935. })(),
  936. ])
  937. },
  938. _buildProjectList(allProjects, userId) {
  939. let project
  940. const {
  941. owned,
  942. review,
  943. readAndWrite,
  944. readOnly,
  945. tokenReadAndWrite,
  946. tokenReadOnly,
  947. } = allProjects
  948. const projects = []
  949. for (project of owned) {
  950. projects.push(
  951. ProjectController._buildProjectViewModel(
  952. project,
  953. 'owner',
  954. Sources.OWNER,
  955. userId
  956. )
  957. )
  958. }
  959. // Invite-access
  960. for (project of readAndWrite) {
  961. projects.push(
  962. ProjectController._buildProjectViewModel(
  963. project,
  964. 'readWrite',
  965. Sources.INVITE,
  966. userId
  967. )
  968. )
  969. }
  970. for (project of review) {
  971. projects.push(
  972. ProjectController._buildProjectViewModel(
  973. project,
  974. 'review',
  975. Sources.INVITE,
  976. userId
  977. )
  978. )
  979. }
  980. for (project of readOnly) {
  981. projects.push(
  982. ProjectController._buildProjectViewModel(
  983. project,
  984. 'readOnly',
  985. Sources.INVITE,
  986. userId
  987. )
  988. )
  989. }
  990. // Token-access
  991. // Only add these projects if they're not already present, this gives us cascading access
  992. // from 'owner' => 'token-read-only'
  993. for (project of tokenReadAndWrite) {
  994. if (
  995. projects.filter(p => p.id.toString() === project._id.toString())
  996. .length === 0
  997. ) {
  998. projects.push(
  999. ProjectController._buildProjectViewModel(
  1000. project,
  1001. 'readAndWrite',
  1002. Sources.TOKEN,
  1003. userId
  1004. )
  1005. )
  1006. }
  1007. }
  1008. for (project of tokenReadOnly) {
  1009. if (
  1010. projects.filter(p => p.id.toString() === project._id.toString())
  1011. .length === 0
  1012. ) {
  1013. projects.push(
  1014. ProjectController._buildProjectViewModel(
  1015. project,
  1016. 'readOnly',
  1017. Sources.TOKEN,
  1018. userId
  1019. )
  1020. )
  1021. }
  1022. }
  1023. return projects
  1024. },
  1025. _buildProjectViewModel(project, accessLevel, source, userId) {
  1026. const archived = ProjectHelper.isArchived(project, userId)
  1027. // If a project is simultaneously trashed and archived, we will consider it archived but not trashed.
  1028. const trashed = ProjectHelper.isTrashed(project, userId) && !archived
  1029. const model = {
  1030. id: project._id,
  1031. name: project.name,
  1032. lastUpdated: project.lastUpdated,
  1033. lastUpdatedBy: project.lastUpdatedBy,
  1034. publicAccessLevel: project.publicAccesLevel,
  1035. accessLevel,
  1036. source,
  1037. archived,
  1038. trashed,
  1039. owner_ref: project.owner_ref,
  1040. isV1Project: false,
  1041. }
  1042. if (accessLevel === PrivilegeLevels.READ_ONLY && source === Sources.TOKEN) {
  1043. model.owner_ref = null
  1044. model.lastUpdatedBy = null
  1045. }
  1046. return model
  1047. },
  1048. _buildPortalTemplatesList(affiliations) {
  1049. if (affiliations == null) {
  1050. affiliations = []
  1051. }
  1052. const portalTemplates = []
  1053. for (const aff of affiliations) {
  1054. if (
  1055. aff.portal &&
  1056. aff.portal.slug &&
  1057. aff.portal.templates_count &&
  1058. aff.portal.templates_count > 0
  1059. ) {
  1060. const portalPath = aff.institution.isUniversity ? '/edu/' : '/org/'
  1061. portalTemplates.push({
  1062. name: aff.institution.name,
  1063. url: Settings.siteUrl + portalPath + aff.portal.slug,
  1064. })
  1065. }
  1066. }
  1067. return portalTemplates
  1068. },
  1069. async _setWritefullTrialState(
  1070. user,
  1071. userValues,
  1072. userId,
  1073. aiFeaturesAllowed,
  1074. userIsMemberOfGroupSubscription
  1075. ) {
  1076. let inEnterpriseCommons = false
  1077. const affiliations = userValues.affiliations || []
  1078. for (const affiliation of affiliations) {
  1079. inEnterpriseCommons =
  1080. inEnterpriseCommons || affiliation.institution?.enterpriseCommons
  1081. }
  1082. // check if a user has never tried writefull before (writefull.enabled will be null)
  1083. // if they previously accepted writefull, or are have been already assigned to a trial, user.writefull will be true,
  1084. // if they explicitly disabled it, user.writefull will be false
  1085. const shouldPushWritefull =
  1086. aiFeaturesAllowed &&
  1087. user.writefull?.enabled === null &&
  1088. !userIsMemberOfGroupSubscription
  1089. // we dont have legal approval to push enterprise commons into WF auto-account-create, but we are able to auto-load it into the toolbar
  1090. const shouldAutoCreateAccount = shouldPushWritefull && !inEnterpriseCommons
  1091. const shouldAutoLoad = shouldPushWritefull && inEnterpriseCommons
  1092. if (shouldAutoCreateAccount) {
  1093. await UserUpdater.promises.updateUser(userId, {
  1094. $set: {
  1095. writefull: { enabled: true, autoCreatedAccount: true },
  1096. },
  1097. })
  1098. user.writefull.enabled = true
  1099. user.writefull.autoCreatedAccount = true
  1100. } else if (shouldAutoLoad) {
  1101. await UserUpdater.promises.updateUser(userId, {
  1102. $set: {
  1103. writefull: { enabled: true, autoCreatedAccount: false },
  1104. },
  1105. })
  1106. user.writefull.enabled = true
  1107. user.writefull.autoCreatedAccount = false
  1108. }
  1109. },
  1110. }
  1111. const defaultSettingsForAnonymousUser = userId => ({
  1112. id: userId,
  1113. ace: {
  1114. mode: 'none',
  1115. theme: 'textmate',
  1116. fontSize: '12',
  1117. autoComplete: true,
  1118. spellCheckLanguage: '',
  1119. pdfViewer: '',
  1120. syntaxValidation: true,
  1121. },
  1122. subscription: {
  1123. freeTrial: {
  1124. allowed: true,
  1125. },
  1126. },
  1127. featureSwitches: {
  1128. github: false,
  1129. },
  1130. alphaProgram: false,
  1131. betaProgram: false,
  1132. writefull: {
  1133. enabled: false,
  1134. },
  1135. })
  1136. const defaultUserValues = () => ({
  1137. user: defaultSettingsForAnonymousUser(null),
  1138. learnedWords: [],
  1139. projectTags: [],
  1140. userHasInstitutionLicence: false,
  1141. affiliations: [],
  1142. subscription: undefined,
  1143. isTokenMember: false,
  1144. isInvitedMember: false,
  1145. })
  1146. const THEME_LIST = [
  1147. 'cobalt',
  1148. 'dracula',
  1149. 'eclipse',
  1150. 'monokai',
  1151. 'overleaf',
  1152. 'overleaf_dark',
  1153. 'textmate',
  1154. ]
  1155. const LEGACY_THEME_LIST = [
  1156. 'ambiance',
  1157. 'chaos',
  1158. 'chrome',
  1159. 'clouds',
  1160. 'clouds_midnight',
  1161. 'crimson_editor',
  1162. 'dawn',
  1163. 'dreamweaver',
  1164. 'github',
  1165. 'gob',
  1166. 'gruvbox',
  1167. 'idle_fingers',
  1168. 'iplastic',
  1169. 'katzenmilch',
  1170. 'kr_theme',
  1171. 'kuroir',
  1172. 'merbivore',
  1173. 'merbivore_soft',
  1174. 'mono_industrial',
  1175. 'nord_dark',
  1176. 'pastel_on_dark',
  1177. 'solarized_dark',
  1178. 'solarized_light',
  1179. 'sqlserver',
  1180. 'terminal',
  1181. 'tomorrow',
  1182. 'tomorrow_night',
  1183. 'tomorrow_night_blue',
  1184. 'tomorrow_night_bright',
  1185. 'tomorrow_night_eighties',
  1186. 'twilight',
  1187. 'vibrant_ink',
  1188. 'xcode',
  1189. ]
  1190. const ProjectController = {
  1191. archiveProject: expressify(_ProjectController.archiveProject),
  1192. cloneProject: expressify(_ProjectController.cloneProject),
  1193. deleteProject: expressify(_ProjectController.deleteProject),
  1194. expireDeletedProject: expressify(_ProjectController.expireDeletedProject),
  1195. expireDeletedProjectsAfterDuration: expressify(
  1196. _ProjectController.expireDeletedProjectsAfterDuration
  1197. ),
  1198. loadEditor: expressify(_ProjectController.loadEditor),
  1199. newProject: expressify(_ProjectController.newProject),
  1200. projectEntitiesJson: expressify(_ProjectController.projectEntitiesJson),
  1201. renameProject: expressify(_ProjectController.renameProject),
  1202. restoreProject: expressify(_ProjectController.restoreProject),
  1203. trashProject: expressify(_ProjectController.trashProject),
  1204. unarchiveProject: expressify(_ProjectController.unarchiveProject),
  1205. untrashProject: expressify(_ProjectController.untrashProject),
  1206. updateProjectAdminSettings: expressify(
  1207. _ProjectController.updateProjectAdminSettings
  1208. ),
  1209. updateProjectSettings: expressify(_ProjectController.updateProjectSettings),
  1210. userProjectsJson: expressify(_ProjectController.userProjectsJson),
  1211. _buildProjectList: _ProjectController._buildProjectList,
  1212. _buildProjectViewModel: _ProjectController._buildProjectViewModel,
  1213. _injectProjectUsers: _ProjectController._injectProjectUsers,
  1214. _isInPercentageRollout: _ProjectController._isInPercentageRollout,
  1215. _refreshFeatures: _ProjectController._refreshFeatures,
  1216. _getPlanPricing: _ProjectController._getPlanPricing,
  1217. _getAddonPrices: _ProjectController._getAddonPrices,
  1218. _setWritefullTrialState: _ProjectController._setWritefullTrialState,
  1219. }
  1220. export default ProjectController