feat: Record share link last accessed time (#2047)
* chore: Migrations * chore: Add recording of share link views * feat: Add display of share link accessed date in admin * translations * test * translations, admin pagination
This commit is contained in:
@@ -518,6 +518,8 @@ async function loadDocument({ id, shareId, user }) {
|
||||
if (!team.sharing) {
|
||||
throw new AuthorizationError();
|
||||
}
|
||||
|
||||
await share.update({ lastAccessedAt: new Date() });
|
||||
} else {
|
||||
document = await Document.findByPk(id, {
|
||||
userId: user ? user.id : undefined,
|
||||
|
||||
@@ -93,6 +93,9 @@ describe("#documents.info", () => {
|
||||
expect(body.data.id).toEqual(document.id);
|
||||
expect(body.data.createdBy).toEqual(undefined);
|
||||
expect(body.data.updatedBy).toEqual(undefined);
|
||||
|
||||
await share.reload();
|
||||
expect(share.lastAccessedAt).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should not return document from shareId if sharing is disabled for team", async () => {
|
||||
|
||||
@@ -36,7 +36,7 @@ router.post("shares.info", auth(), async (ctx) => {
|
||||
authorize(user, "read", share);
|
||||
|
||||
ctx.body = {
|
||||
data: presentShare(share),
|
||||
data: presentShare(share, user.isAdmin),
|
||||
policies: presentPolicies(user, [share]),
|
||||
};
|
||||
});
|
||||
@@ -89,7 +89,7 @@ router.post("shares.list", auth(), pagination(), async (ctx) => {
|
||||
|
||||
ctx.body = {
|
||||
pagination: ctx.state.pagination,
|
||||
data: shares.map(presentShare),
|
||||
data: shares.map((share) => presentShare(share, user.isAdmin)),
|
||||
policies: presentPolicies(user, shares),
|
||||
};
|
||||
});
|
||||
@@ -117,7 +117,7 @@ router.post("shares.update", auth(), async (ctx) => {
|
||||
});
|
||||
|
||||
ctx.body = {
|
||||
data: presentShare(share),
|
||||
data: presentShare(share, user.isAdmin),
|
||||
policies: presentPolicies(user, [share]),
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user