diff --git a/app/models/Document.js b/app/models/Document.js index bebb34c8..c6061ff2 100644 --- a/app/models/Document.js +++ b/app/models/Document.js @@ -24,7 +24,7 @@ export default class Document extends BaseModel { @observable lastViewedAt: ?string; store: DocumentsStore; - collaborators: User[]; + collaboratorIds: string[]; collectionId: string; createdAt: string; createdBy: User; diff --git a/server/presenters/document.js b/server/presenters/document.js index fe48c06e..edfc4fa8 100644 --- a/server/presenters/document.js +++ b/server/presenters/document.js @@ -1,6 +1,5 @@ // @flow -import { takeRight } from "lodash"; -import { Attachment, Document, User } from "../models"; +import { Attachment, Document } from "../models"; import parseAttachmentIds from "../utils/parseAttachmentIds"; import { getSignedImageUrl } from "../utils/s3"; import presentUser from "./user"; @@ -53,7 +52,7 @@ export default async function present(document: Document, options: ?Options) { teamId: document.teamId, template: document.template, templateId: document.templateId, - collaborators: [], + collaboratorIds: [], starred: document.starred ? !!document.starred.length : undefined, revision: document.revisionCount, pinned: undefined, @@ -72,15 +71,7 @@ export default async function present(document: Document, options: ?Options) { data.parentDocumentId = document.parentDocumentId; data.createdBy = presentUser(document.createdBy); data.updatedBy = presentUser(document.updatedBy); - - // TODO: This could be further optimized - data.collaborators = ( - await User.findAll({ - where: { - id: takeRight(document.collaboratorIds, 10) || [], - }, - }) - ).map(presentUser); + data.collaboratorIds = document.collaboratorIds; } return data;