feat: Document subscriptions (#3834)
Co-authored-by: Tom Moor <tom.moor@gmail.com>
This commit is contained in:
committed by
GitHub
parent
864f585e5b
commit
24c71c38a5
@@ -17,6 +17,7 @@ import {
|
||||
WebhookSubscription,
|
||||
WebhookDelivery,
|
||||
ApiKey,
|
||||
Subscription,
|
||||
} from "@server/models";
|
||||
import {
|
||||
FileOperationState,
|
||||
@@ -88,6 +89,31 @@ export async function buildStar(overrides: Partial<Star> = {}) {
|
||||
});
|
||||
}
|
||||
|
||||
export async function buildSubscription(overrides: Partial<Subscription> = {}) {
|
||||
let user;
|
||||
|
||||
if (overrides.userId) {
|
||||
user = await User.findByPk(overrides.userId);
|
||||
} else {
|
||||
user = await buildUser();
|
||||
overrides.userId = user.id;
|
||||
}
|
||||
|
||||
if (!overrides.documentId) {
|
||||
const document = await buildDocument({
|
||||
createdById: overrides.userId,
|
||||
teamId: user?.teamId,
|
||||
});
|
||||
overrides.documentId = document.id;
|
||||
}
|
||||
|
||||
return Subscription.create({
|
||||
enabled: true,
|
||||
event: "documents.update",
|
||||
...overrides,
|
||||
});
|
||||
}
|
||||
|
||||
export function buildTeam(overrides: Record<string, any> = {}) {
|
||||
count++;
|
||||
return Team.create(
|
||||
|
||||
Reference in New Issue
Block a user