Files
outline/server/presenters/share.ts
Tom Moor 32b76303e5 Add simple count of views to share links (#4036)
* Add simple count of views to share links

* Remove no longer applicable tests

* Avoid incrementing view count for known bots
2022-08-30 23:16:40 -07:00

26 lines
690 B
TypeScript

import { Share } from "@server/models";
import { presentUser } from ".";
export default function present(share: Share, isAdmin = false) {
const data = {
id: share.id,
documentId: share.documentId,
documentTitle: share.document?.title,
documentUrl: share.document?.url,
published: share.published,
url: `${share.team.url}/share/${share.id}`,
createdBy: presentUser(share.user),
includeChildDocuments: share.includeChildDocuments,
lastAccessedAt: share.lastAccessedAt || undefined,
views: share.views || 0,
createdAt: share.createdAt,
updatedAt: share.updatedAt,
};
if (!isAdmin) {
delete data.lastAccessedAt;
}
return data;
}