Skip to content

Commit 7d12edf

Browse files
committed
fix: publications not becoming ready when stopping evaluation early
1 parent 00ec691 commit 7d12edf

File tree

6 files changed

+120
-30
lines changed

6 files changed

+120
-30
lines changed

meteor/server/publications/organization.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ import { getCurrentTime } from '../lib/lib'
1818
meteorPublish(
1919
MeteorPubSub.organization,
2020
async function (organizationId: OrganizationId | null, token: string | undefined) {
21-
if (!organizationId) return null
21+
if (!organizationId) {
22+
this.ready()
23+
return null
24+
}
2225

2326
const { cred, selector } = await AutoFillSelector.organizationId(this.userId, { _id: organizationId }, token)
2427
const modifier: FindOptions<DBOrganization> = {
@@ -43,7 +46,10 @@ meteorPublish(CorelibPubSub.blueprints, async function (blueprintIds: BlueprintI
4346
check(blueprintIds, Match.Maybe(Array))
4447

4548
// If values were provided, they must have values
46-
if (blueprintIds && blueprintIds.length === 0) return null
49+
if (blueprintIds && blueprintIds.length === 0) {
50+
this.ready()
51+
return null
52+
}
4753

4854
const { cred, selector } = await AutoFillSelector.organizationId<Blueprint>(this.userId, {}, token)
4955

meteor/server/publications/peripheralDevice.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ meteorPublish(
4444
check(peripheralDeviceIds, Match.Maybe(Array))
4545

4646
// If values were provided, they must have values
47-
if (peripheralDeviceIds && peripheralDeviceIds.length === 0) return null
47+
if (peripheralDeviceIds && peripheralDeviceIds.length === 0) {
48+
this.ready()
49+
return null
50+
}
4851

4952
const { cred, selector } = await AutoFillSelector.organizationId<PeripheralDevice>(this.userId, {}, token)
5053

meteor/server/publications/rundown.ts

Lines changed: 68 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@ meteorPublish(PeripheralDevicePubSub.rundownsForDevice, async function (deviceId
6565
throw new Meteor.Error(403, 'Publication can only be used by authorized PeripheralDevices')
6666

6767
// No studio, then no rundowns
68-
if (!resolvedCred.device.studioId) return null
68+
if (!resolvedCred.device.studioId) {
69+
this.ready()
70+
return null
71+
}
6972

7073
selector.studioId = resolvedCred.device.studioId
7174

@@ -87,7 +90,10 @@ meteorPublish(
8790
check(playlistIds, Array)
8891

8992
// If values were provided, they must have values
90-
if (playlistIds.length === 0) return null
93+
if (playlistIds.length === 0) {
94+
this.ready()
95+
return null
96+
}
9197

9298
const { cred, selector } = await AutoFillSelector.organizationId<DBRundown>(
9399
this.userId,
@@ -121,7 +127,10 @@ meteorPublish(
121127
async function (showStyleBaseIds: ShowStyleBaseId[], token: string | undefined) {
122128
check(showStyleBaseIds, Array)
123129

124-
if (showStyleBaseIds.length === 0) return null
130+
if (showStyleBaseIds.length === 0) {
131+
this.ready()
132+
return null
133+
}
125134

126135
const { cred, selector } = await AutoFillSelector.organizationId<DBRundown>(
127136
this.userId,
@@ -156,7 +165,10 @@ meteorPublish(
156165
async function (rundownIds: RundownId[], filter: { omitHidden?: boolean } | undefined, token: string | undefined) {
157166
check(rundownIds, Array)
158167

159-
if (rundownIds.length === 0) return null
168+
if (rundownIds.length === 0) {
169+
this.ready()
170+
return null
171+
}
160172

161173
const selector: MongoQuery<DBSegment> = {
162174
rundownId: { $in: rundownIds },
@@ -183,8 +195,14 @@ meteorPublish(
183195
check(rundownIds, Array)
184196
check(segmentIds, Match.Maybe(Array))
185197

186-
if (rundownIds.length === 0) return null
187-
if (segmentIds && segmentIds.length === 0) return null
198+
if (rundownIds.length === 0) {
199+
this.ready()
200+
return null
201+
}
202+
if (segmentIds && segmentIds.length === 0) {
203+
this.ready()
204+
return null
205+
}
188206

189207
const modifier: FindOptions<DBPart> = {
190208
fields: {
@@ -219,7 +237,10 @@ meteorPublish(
219237
check(rundownIds, Array)
220238
check(playlistActivationId, Match.Maybe(String))
221239

222-
if (rundownIds.length === 0 || !playlistActivationId) return null
240+
if (rundownIds.length === 0 || !playlistActivationId) {
241+
this.ready()
242+
return null
243+
}
223244

224245
const modifier: FindOptions<DBPartInstance> = {
225246
fields: {
@@ -252,7 +273,10 @@ meteorPublish(
252273
) {
253274
check(rundownIds, Array)
254275

255-
if (rundownIds.length === 0) return null
276+
if (rundownIds.length === 0) {
277+
this.ready()
278+
return null
279+
}
256280

257281
const selector: MongoQuery<DBPartInstance> = {
258282
rundownId: { $in: rundownIds },
@@ -290,7 +314,10 @@ meteorPublish(
290314
check(partIds, Match.Maybe(Array))
291315

292316
// If values were provided, they must have values
293-
if (partIds && partIds.length === 0) return null
317+
if (partIds && partIds.length === 0) {
318+
this.ready()
319+
return null
320+
}
294321

295322
const selector: MongoQuery<Piece> = {
296323
startRundownId: { $in: rundownIds },
@@ -361,7 +388,10 @@ const adlibPiecesSubFields: MongoFieldSpecifierZeroes<AdLibPiece> = {
361388
meteorPublish(CorelibPubSub.adLibPieces, async function (rundownIds: RundownId[], token: string | undefined) {
362389
check(rundownIds, Array)
363390

364-
if (rundownIds.length === 0) return null
391+
if (rundownIds.length === 0) {
392+
this.ready()
393+
return null
394+
}
365395

366396
const selector: MongoQuery<AdLibPiece> = {
367397
rundownId: { $in: rundownIds },
@@ -417,8 +447,14 @@ meteorPublish(
417447
check(partInstanceIds, Match.Maybe(Array))
418448

419449
// If values were provided, they must have values
420-
if (rundownIds.length === 0) return null
421-
if (partInstanceIds && partInstanceIds.length === 0) return null
450+
if (rundownIds.length === 0) {
451+
this.ready()
452+
return null
453+
}
454+
if (partInstanceIds && partInstanceIds.length === 0) {
455+
this.ready()
456+
return null
457+
}
422458

423459
const selector: MongoQuery<PieceInstance> = {
424460
rundownId: { $in: rundownIds },
@@ -485,7 +521,10 @@ meteorPublish(
485521
) {
486522
check(rundownIds, Array)
487523

488-
if (rundownIds.length === 0) return null
524+
if (rundownIds.length === 0) {
525+
this.ready()
526+
return null
527+
}
489528

490529
const selector: MongoQuery<PieceInstance> = {
491530
rundownId: { $in: rundownIds },
@@ -522,7 +561,10 @@ meteorPublish(
522561
if (!peripheralDevice) throw new Meteor.Error(`PeripheralDevice "${deviceId}" not found`)
523562

524563
const studioId = peripheralDevice.studioId
525-
if (!studioId) return null
564+
if (!studioId) {
565+
this.ready()
566+
return null
567+
}
526568

527569
return ExpectedPlayoutItems.findWithCursor({ studioId })
528570
}
@@ -551,7 +593,10 @@ meteorPublish(
551593
async function (rundownIds: RundownId[], token: string | undefined) {
552594
check(rundownIds, Array)
553595

554-
if (rundownIds.length === 0) return null
596+
if (rundownIds.length === 0) {
597+
this.ready()
598+
return null
599+
}
555600

556601
const selector: MongoQuery<RundownBaselineAdLibItem> = {
557602
rundownId: { $in: rundownIds },
@@ -579,7 +624,10 @@ const adlibActionSubFields: MongoFieldSpecifierZeroes<AdLibAction> = {
579624
meteorPublish(CorelibPubSub.adLibActions, async function (rundownIds: RundownId[], token: string | undefined) {
580625
check(rundownIds, Array)
581626

582-
if (rundownIds.length === 0) return null
627+
if (rundownIds.length === 0) {
628+
this.ready()
629+
return null
630+
}
583631

584632
const selector: MongoQuery<AdLibAction> = {
585633
rundownId: { $in: rundownIds },
@@ -618,7 +666,10 @@ meteorPublish(
618666
async function (rundownIds: RundownId[], token: string | undefined) {
619667
check(rundownIds, Array)
620668

621-
if (rundownIds.length === 0) return null
669+
if (rundownIds.length === 0) {
670+
this.ready()
671+
return null
672+
}
622673

623674
const selector: MongoQuery<RundownBaselineAdLibAction> = {
624675
rundownId: { $in: rundownIds },

meteor/server/publications/rundownPlaylist.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,14 @@ meteorPublish(
2424
check(studioIds, Match.Maybe(Array))
2525

2626
// If values were provided, they must have values
27-
if (rundownPlaylistIds && rundownPlaylistIds.length === 0) return null
28-
if (studioIds && studioIds.length === 0) return null
27+
if (rundownPlaylistIds && rundownPlaylistIds.length === 0) {
28+
this.ready()
29+
return null
30+
}
31+
if (studioIds && studioIds.length === 0) {
32+
this.ready()
33+
return null
34+
}
2935

3036
const { cred, selector } = await AutoFillSelector.organizationId<DBRundownPlaylist>(this.userId, {}, token)
3137

meteor/server/publications/showStyle.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ meteorPublish(
1919
check(showStyleBaseIds, Match.Maybe(Array))
2020

2121
// If values were provided, they must have values
22-
if (showStyleBaseIds && showStyleBaseIds.length === 0) return null
22+
if (showStyleBaseIds && showStyleBaseIds.length === 0) {
23+
this.ready()
24+
return null
25+
}
2326

2427
const { cred, selector } = await AutoFillSelector.organizationId<DBShowStyleBase>(this.userId, {}, token)
2528

@@ -50,8 +53,14 @@ meteorPublish(
5053
check(showStyleVariantIds, Match.Maybe(Array))
5154

5255
// If values were provided, they must have values
53-
if (showStyleBaseIds && showStyleBaseIds.length === 0) return null
54-
if (showStyleVariantIds && showStyleVariantIds.length === 0) return null
56+
if (showStyleBaseIds && showStyleBaseIds.length === 0) {
57+
this.ready()
58+
return null
59+
}
60+
if (showStyleVariantIds && showStyleVariantIds.length === 0) {
61+
this.ready()
62+
return null
63+
}
5564

5665
const { cred, selector } = await AutoFillSelector.showStyleBaseId<DBShowStyleVariant>(this.userId, {}, token)
5766

@@ -77,7 +86,10 @@ meteorPublish(
7786
check(showStyleBaseIds, Match.Maybe(Array))
7887

7988
// If values were provided, they must have values
80-
if (showStyleBaseIds && showStyleBaseIds.length === 0) return null
89+
if (showStyleBaseIds && showStyleBaseIds.length === 0) {
90+
this.ready()
91+
return null
92+
}
8193

8294
const selector0: MongoQuery<RundownLayoutBase> = {}
8395
if (showStyleBaseIds) selector0.showStyleBaseId = { $in: showStyleBaseIds }

meteor/server/publications/studio.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ meteorPublish(CorelibPubSub.studios, async function (studioIds: StudioId[] | nul
4242
check(studioIds, Match.Maybe(Array))
4343

4444
// If values were provided, they must have values
45-
if (studioIds && studioIds.length === 0) return null
45+
if (studioIds && studioIds.length === 0) {
46+
this.ready()
47+
return null
48+
}
4649

4750
const { cred, selector } = await AutoFillSelector.organizationId<DBStudio>(this.userId, {}, token)
4851

@@ -78,7 +81,10 @@ meteorPublish(CorelibPubSub.expectedPackages, async function (studioIds: StudioI
7881
// Note: This differs from the expected packages sent to the Package Manager, instead @see PubSub.expectedPackagesForDevice
7982
check(studioIds, Array)
8083

81-
if (studioIds.length === 0) return null
84+
if (studioIds.length === 0) {
85+
this.ready()
86+
return null
87+
}
8288

8389
if (await StudioReadAccess.studioContent(studioIds, { userId: this.userId, token })) {
8490
return ExpectedPackages.findWithCursor({
@@ -92,7 +98,10 @@ meteorPublish(
9298
async function (studioIds: StudioId[], token: string | undefined) {
9399
check(studioIds, Array)
94100

95-
if (studioIds.length === 0) return null
101+
if (studioIds.length === 0) {
102+
this.ready()
103+
return null
104+
}
96105

97106
if (await StudioReadAccess.studioContent(studioIds, { userId: this.userId, token })) {
98107
return ExpectedPackageWorkStatuses.findWithCursor({
@@ -107,7 +116,10 @@ meteorPublish(
107116
async function (studioIds: StudioId[], token: string | undefined) {
108117
check(studioIds, Array)
109118

110-
if (studioIds.length === 0) return null
119+
if (studioIds.length === 0) {
120+
this.ready()
121+
return null
122+
}
111123

112124
if (await StudioReadAccess.studioContent(studioIds, { userId: this.userId, token })) {
113125
return PackageContainerStatuses.findWithCursor({

0 commit comments

Comments
 (0)