ProjectController.mjs 42 KB

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