fix: Document subscriptions backfill not recursive
This commit is contained in:
@@ -14,7 +14,6 @@ import {
|
||||
NotificationSetting,
|
||||
Subscription,
|
||||
} from "@server/models";
|
||||
import { can } from "@server/policies";
|
||||
import {
|
||||
CollectionEvent,
|
||||
RevisionEvent,
|
||||
@@ -133,7 +132,6 @@ export default class NotificationsProcessor extends BaseProcessor {
|
||||
const users = await document.collaborators({ transaction });
|
||||
|
||||
for (const user of users) {
|
||||
if (user && can(user, "subscribe", document)) {
|
||||
await subscriptionCreator({
|
||||
user,
|
||||
documentId: document.id,
|
||||
@@ -143,7 +141,6 @@ export default class NotificationsProcessor extends BaseProcessor {
|
||||
ip: event.ip,
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import "./bootstrap";
|
||||
import { Subscription, Document } from "@server/models";
|
||||
|
||||
const limit = 100;
|
||||
const limit = 1000;
|
||||
let page = parseInt(process.argv[2], 10);
|
||||
page = Number.isNaN(page) ? 0 : page;
|
||||
|
||||
export default async function main(exit = false) {
|
||||
const work = async (page: number) => {
|
||||
const work = async (page: number): Promise<void> => {
|
||||
console.log(`Backfill subscription… page ${page}`);
|
||||
|
||||
// Retrieve all documents within set limit.
|
||||
@@ -36,6 +36,8 @@ export default async function main(exit = false) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return documents.length === limit ? work(page + 1) : undefined;
|
||||
};
|
||||
|
||||
await work(page);
|
||||
|
||||
Reference in New Issue
Block a user