From f10cfbbd9e0fdb407eabb59340f89921f56a1246 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Wed, 6 Apr 2022 21:35:45 -0700 Subject: [PATCH] fix: Missing user scope in collection mailer --- server/mailer.tsx | 4 +++- server/models/Collection.ts | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/server/mailer.tsx b/server/mailer.tsx index dc106beed..aedddcff3 100644 --- a/server/mailer.tsx +++ b/server/mailer.tsx @@ -249,7 +249,9 @@ export class Mailer { collectionId: string; unsubscribeUrl: string; }) => { - const collection = await Collection.findByPk(opts.collectionId); + const collection = await Collection.scope("withUser").findByPk( + opts.collectionId + ); invariant(collection, "Collection not found"); this.sendMail({ diff --git a/server/models/Collection.ts b/server/models/Collection.ts index 258e1420a..f48f60ec2 100644 --- a/server/models/Collection.ts +++ b/server/models/Collection.ts @@ -73,6 +73,15 @@ type Sort = CollectionSort; }, ], }, + withUser: () => ({ + include: [ + { + model: User, + required: true, + as: "user", + }, + ], + }), withMembership: (userId: string) => ({ include: [ {