Add notifications for document and collection access (#6460)

* Add notification for added to document

* Add notifications for document and collection access

* Add notification delay

* fix: Collection notifications not appearing

* Add notification settings
This commit is contained in:
Tom Moor
2024-01-31 15:01:27 -08:00
committed by GitHub
parent 5ce8827a8c
commit 47d168a29b
18 changed files with 437 additions and 31 deletions

View File

@@ -1475,6 +1475,7 @@ router.post(
"documents.add_user",
auth(),
validate(T.DocumentsAddUserSchema),
rateLimiter(RateLimiterStrategy.OneHundredPerHour),
transaction(),
async (ctx: APIContext<T.DocumentsAddUserReq>) => {
const { auth, transaction } = ctx.state;
@@ -1521,7 +1522,7 @@ router.post(
UserMemberships.length ? UserMemberships[0].index : null
);
const [membership] = await UserMembership.findOrCreate({
const [membership, isNew] = await UserMembership.findOrCreate({
where: {
documentId: id,
userId,
@@ -1553,6 +1554,11 @@ router.post(
teamId: document.teamId,
actorId: actor.id,
ip: ctx.request.ip,
data: {
title: document.title,
isNew,
permission: membership.permission,
},
},
{
transaction,