ProjectController.mjs 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326
  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. 'populate-clsi-cache',
  347. 'pdf-caching-cached-url-lookup',
  348. 'pdf-caching-mode',
  349. 'pdf-caching-prefetch-large',
  350. 'pdf-caching-prefetching',
  351. 'revert-file',
  352. 'revert-project',
  353. !anonymous && 'ro-mirror-on-client',
  354. 'track-pdf-download',
  355. !anonymous && 'writefull-oauth-promotion',
  356. 'hotjar',
  357. 'hotjar-editor-onboarding',
  358. 'editor-redesign',
  359. 'overleaf-assist-bundle',
  360. 'word-count-client',
  361. 'editor-popup-ux-survey',
  362. 'editor-redesign-new-users',
  363. 'writefull-frontend-migration',
  364. 'chat-edit-delete',
  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. projectOwnerHasPremiumOnPageLoad:
  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. splitTestAssignments['hotjar-editor-onboarding']?.variant ===
  815. 'enabled',
  816. isOverleafAssistBundleEnabled,
  817. customerIoEnabled,
  818. addonPrices,
  819. compileSettings: {
  820. compileTimeout: ownerFeatures?.compileTimeout,
  821. },
  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 _getPaywallPlansPrices(
  830. req,
  831. res,
  832. paywallPlans = ['collaborator', 'student']
  833. ) {
  834. const plansData = {}
  835. const locale = req.i18n.language
  836. const { currency } = await SubscriptionController.getRecommendedCurrency(
  837. req,
  838. res
  839. )
  840. paywallPlans.forEach(plan => {
  841. const planPrice = Settings.localizedPlanPricing[currency][plan].monthly
  842. const formattedPlanPrice = formatCurrency(
  843. planPrice,
  844. currency,
  845. locale,
  846. true
  847. )
  848. plansData[plan] = formattedPlanPrice
  849. })
  850. return plansData
  851. },
  852. async _getAddonPrices(req, res, addonPlans = ['assistant']) {
  853. const plansData = {}
  854. const locale = req.i18n.language
  855. const { currency } = await SubscriptionController.getRecommendedCurrency(
  856. req,
  857. res
  858. )
  859. addonPlans.forEach(plan => {
  860. const annualPrice = Settings.localizedAddOnsPricing[currency][plan].annual
  861. const monthlyPrice =
  862. Settings.localizedAddOnsPricing[currency][plan].monthly
  863. const annualDividedByTwelve =
  864. Settings.localizedAddOnsPricing[currency][plan].annualDividedByTwelve
  865. plansData[plan] = {
  866. annual: formatCurrency(annualPrice, currency, locale, true),
  867. annualDividedByTwelve: formatCurrency(
  868. annualDividedByTwelve,
  869. currency,
  870. locale,
  871. true
  872. ),
  873. monthly: formatCurrency(monthlyPrice, currency, locale, true),
  874. }
  875. })
  876. return plansData
  877. },
  878. async _refreshFeatures(req, user) {
  879. // If the feature refresh has failed in this session, don't retry
  880. // it - require the user to log in again.
  881. if (req.session.feature_refresh_failed) {
  882. metrics.inc('features-refresh', 1, {
  883. path: 'load-editor',
  884. status: 'skipped',
  885. })
  886. return user
  887. }
  888. // If the refresh takes too long then return the current
  889. // features. Note that the user.features property may still be
  890. // updated in the background after the promise is resolved.
  891. const abortController = new AbortController()
  892. const refreshTimeoutHandler = async () => {
  893. await setTimeout(5000, { signal: abortController.signal })
  894. req.session.feature_refresh_failed = {
  895. reason: 'timeout',
  896. at: new Date(),
  897. }
  898. metrics.inc('features-refresh', 1, {
  899. path: 'load-editor',
  900. status: 'timeout',
  901. })
  902. return user
  903. }
  904. // try to refresh user features now
  905. const timer = new metrics.Timer('features-refresh-on-load-editor')
  906. return Promise.race([
  907. refreshTimeoutHandler(),
  908. (async () => {
  909. try {
  910. user.features = await FeaturesUpdater.promises.refreshFeatures(
  911. user._id,
  912. 'load-editor'
  913. )
  914. metrics.inc('features-refresh', 1, {
  915. path: 'load-editor',
  916. status: 'success',
  917. })
  918. } catch (err) {
  919. // keep a record to prevent unneceary retries and leave
  920. // the original features unmodified if the refresh failed
  921. req.session.feature_refresh_failed = {
  922. reason: 'error',
  923. at: new Date(),
  924. }
  925. metrics.inc('features-refresh', 1, {
  926. path: 'load-editor',
  927. status: 'error',
  928. })
  929. }
  930. abortController.abort()
  931. timer.done()
  932. return user
  933. })(),
  934. ])
  935. },
  936. _buildProjectList(allProjects, userId) {
  937. let project
  938. const {
  939. owned,
  940. review,
  941. readAndWrite,
  942. readOnly,
  943. tokenReadAndWrite,
  944. tokenReadOnly,
  945. } = allProjects
  946. const projects = []
  947. for (project of owned) {
  948. projects.push(
  949. ProjectController._buildProjectViewModel(
  950. project,
  951. 'owner',
  952. Sources.OWNER,
  953. userId
  954. )
  955. )
  956. }
  957. // Invite-access
  958. for (project of readAndWrite) {
  959. projects.push(
  960. ProjectController._buildProjectViewModel(
  961. project,
  962. 'readWrite',
  963. Sources.INVITE,
  964. userId
  965. )
  966. )
  967. }
  968. for (project of review) {
  969. projects.push(
  970. ProjectController._buildProjectViewModel(
  971. project,
  972. 'review',
  973. Sources.INVITE,
  974. userId
  975. )
  976. )
  977. }
  978. for (project of readOnly) {
  979. projects.push(
  980. ProjectController._buildProjectViewModel(
  981. project,
  982. 'readOnly',
  983. Sources.INVITE,
  984. userId
  985. )
  986. )
  987. }
  988. // Token-access
  989. // Only add these projects if they're not already present, this gives us cascading access
  990. // from 'owner' => 'token-read-only'
  991. for (project of tokenReadAndWrite) {
  992. if (
  993. projects.filter(p => p.id.toString() === project._id.toString())
  994. .length === 0
  995. ) {
  996. projects.push(
  997. ProjectController._buildProjectViewModel(
  998. project,
  999. 'readAndWrite',
  1000. Sources.TOKEN,
  1001. userId
  1002. )
  1003. )
  1004. }
  1005. }
  1006. for (project of tokenReadOnly) {
  1007. if (
  1008. projects.filter(p => p.id.toString() === project._id.toString())
  1009. .length === 0
  1010. ) {
  1011. projects.push(
  1012. ProjectController._buildProjectViewModel(
  1013. project,
  1014. 'readOnly',
  1015. Sources.TOKEN,
  1016. userId
  1017. )
  1018. )
  1019. }
  1020. }
  1021. return projects
  1022. },
  1023. _buildProjectViewModel(project, accessLevel, source, userId) {
  1024. const archived = ProjectHelper.isArchived(project, userId)
  1025. // If a project is simultaneously trashed and archived, we will consider it archived but not trashed.
  1026. const trashed = ProjectHelper.isTrashed(project, userId) && !archived
  1027. const model = {
  1028. id: project._id,
  1029. name: project.name,
  1030. lastUpdated: project.lastUpdated,
  1031. lastUpdatedBy: project.lastUpdatedBy,
  1032. publicAccessLevel: project.publicAccesLevel,
  1033. accessLevel,
  1034. source,
  1035. archived,
  1036. trashed,
  1037. owner_ref: project.owner_ref,
  1038. isV1Project: false,
  1039. }
  1040. if (accessLevel === PrivilegeLevels.READ_ONLY && source === Sources.TOKEN) {
  1041. model.owner_ref = null
  1042. model.lastUpdatedBy = null
  1043. }
  1044. return model
  1045. },
  1046. _buildPortalTemplatesList(affiliations) {
  1047. if (affiliations == null) {
  1048. affiliations = []
  1049. }
  1050. const portalTemplates = []
  1051. for (const aff of affiliations) {
  1052. if (
  1053. aff.portal &&
  1054. aff.portal.slug &&
  1055. aff.portal.templates_count &&
  1056. aff.portal.templates_count > 0
  1057. ) {
  1058. const portalPath = aff.institution.isUniversity ? '/edu/' : '/org/'
  1059. portalTemplates.push({
  1060. name: aff.institution.name,
  1061. url: Settings.siteUrl + portalPath + aff.portal.slug,
  1062. })
  1063. }
  1064. }
  1065. return portalTemplates
  1066. },
  1067. async _setWritefullTrialState(
  1068. user,
  1069. userValues,
  1070. userId,
  1071. aiFeaturesAllowed,
  1072. userIsMemberOfGroupSubscription
  1073. ) {
  1074. let inEnterpriseCommons = false
  1075. const affiliations = userValues.affiliations || []
  1076. for (const affiliation of affiliations) {
  1077. inEnterpriseCommons =
  1078. inEnterpriseCommons || affiliation.institution?.enterpriseCommons
  1079. }
  1080. // check if a user has never tried writefull before (writefull.enabled will be null)
  1081. // if they previously accepted writefull, or are have been already assigned to a trial, user.writefull will be true,
  1082. // if they explicitly disabled it, user.writefull will be false
  1083. const shouldPushWritefull =
  1084. aiFeaturesAllowed &&
  1085. user.writefull?.enabled === null &&
  1086. !userIsMemberOfGroupSubscription
  1087. // 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
  1088. const shouldAutoCreateAccount = shouldPushWritefull && !inEnterpriseCommons
  1089. const shouldAutoLoad = shouldPushWritefull && inEnterpriseCommons
  1090. if (shouldAutoCreateAccount) {
  1091. await UserUpdater.promises.updateUser(userId, {
  1092. $set: {
  1093. writefull: { enabled: true, autoCreatedAccount: true },
  1094. },
  1095. })
  1096. user.writefull.enabled = true
  1097. user.writefull.autoCreatedAccount = true
  1098. } else if (shouldAutoLoad) {
  1099. await UserUpdater.promises.updateUser(userId, {
  1100. $set: {
  1101. writefull: { enabled: true, autoCreatedAccount: false },
  1102. },
  1103. })
  1104. user.writefull.enabled = true
  1105. user.writefull.autoCreatedAccount = false
  1106. }
  1107. },
  1108. }
  1109. const defaultSettingsForAnonymousUser = userId => ({
  1110. id: userId,
  1111. ace: {
  1112. mode: 'none',
  1113. theme: 'textmate',
  1114. fontSize: '12',
  1115. autoComplete: true,
  1116. spellCheckLanguage: '',
  1117. pdfViewer: '',
  1118. syntaxValidation: true,
  1119. },
  1120. subscription: {
  1121. freeTrial: {
  1122. allowed: true,
  1123. },
  1124. },
  1125. featureSwitches: {
  1126. github: false,
  1127. },
  1128. alphaProgram: false,
  1129. betaProgram: false,
  1130. writefull: {
  1131. enabled: false,
  1132. },
  1133. })
  1134. const defaultUserValues = () => ({
  1135. user: defaultSettingsForAnonymousUser(null),
  1136. learnedWords: [],
  1137. projectTags: [],
  1138. userHasInstitutionLicence: false,
  1139. affiliations: [],
  1140. subscription: undefined,
  1141. isTokenMember: false,
  1142. isInvitedMember: false,
  1143. })
  1144. const THEME_LIST = [
  1145. 'cobalt',
  1146. 'dracula',
  1147. 'eclipse',
  1148. 'monokai',
  1149. 'overleaf',
  1150. 'overleaf_dark',
  1151. 'textmate',
  1152. ]
  1153. const LEGACY_THEME_LIST = [
  1154. 'ambiance',
  1155. 'chaos',
  1156. 'chrome',
  1157. 'clouds',
  1158. 'clouds_midnight',
  1159. 'crimson_editor',
  1160. 'dawn',
  1161. 'dreamweaver',
  1162. 'github',
  1163. 'gob',
  1164. 'gruvbox',
  1165. 'idle_fingers',
  1166. 'iplastic',
  1167. 'katzenmilch',
  1168. 'kr_theme',
  1169. 'kuroir',
  1170. 'merbivore',
  1171. 'merbivore_soft',
  1172. 'mono_industrial',
  1173. 'nord_dark',
  1174. 'pastel_on_dark',
  1175. 'solarized_dark',
  1176. 'solarized_light',
  1177. 'sqlserver',
  1178. 'terminal',
  1179. 'tomorrow',
  1180. 'tomorrow_night',
  1181. 'tomorrow_night_blue',
  1182. 'tomorrow_night_bright',
  1183. 'tomorrow_night_eighties',
  1184. 'twilight',
  1185. 'vibrant_ink',
  1186. 'xcode',
  1187. ]
  1188. const ProjectController = {
  1189. archiveProject: expressify(_ProjectController.archiveProject),
  1190. cloneProject: expressify(_ProjectController.cloneProject),
  1191. deleteProject: expressify(_ProjectController.deleteProject),
  1192. expireDeletedProject: expressify(_ProjectController.expireDeletedProject),
  1193. expireDeletedProjectsAfterDuration: expressify(
  1194. _ProjectController.expireDeletedProjectsAfterDuration
  1195. ),
  1196. loadEditor: expressify(_ProjectController.loadEditor),
  1197. newProject: expressify(_ProjectController.newProject),
  1198. projectEntitiesJson: expressify(_ProjectController.projectEntitiesJson),
  1199. renameProject: expressify(_ProjectController.renameProject),
  1200. restoreProject: expressify(_ProjectController.restoreProject),
  1201. trashProject: expressify(_ProjectController.trashProject),
  1202. unarchiveProject: expressify(_ProjectController.unarchiveProject),
  1203. untrashProject: expressify(_ProjectController.untrashProject),
  1204. updateProjectAdminSettings: expressify(
  1205. _ProjectController.updateProjectAdminSettings
  1206. ),
  1207. updateProjectSettings: expressify(_ProjectController.updateProjectSettings),
  1208. userProjectsJson: expressify(_ProjectController.userProjectsJson),
  1209. _buildProjectList: _ProjectController._buildProjectList,
  1210. _buildProjectViewModel: _ProjectController._buildProjectViewModel,
  1211. _injectProjectUsers: _ProjectController._injectProjectUsers,
  1212. _isInPercentageRollout: _ProjectController._isInPercentageRollout,
  1213. _refreshFeatures: _ProjectController._refreshFeatures,
  1214. _getPaywallPlansPrices: _ProjectController._getPaywallPlansPrices,
  1215. _getAddonPrices: _ProjectController._getAddonPrices,
  1216. _setWritefullTrialState: _ProjectController._setWritefullTrialState,
  1217. }
  1218. export default ProjectController