Skip to content

Commit b6af173

Browse files
authored
Merge pull request #1532 from SuperFlyTV/feat/add-notifications-to-lsg
feat: add notifications to lsg
2 parents 0144543 + 0c6692c commit b6af173

34 files changed

+1027
-20
lines changed

meteor/server/publications/system.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { RundownId, RundownPlaylistId, StudioId } from '@sofie-automation/coreli
55
import { check } from 'meteor/check'
66
import { SYSTEM_ID } from '@sofie-automation/meteor-lib/dist/collections/CoreSystem'
77
import { triggerWriteAccessBecauseNoCheckNecessary } from '../security/securityVerify'
8+
import { CorelibPubSub } from '@sofie-automation/corelib/dist/pubsub'
89

910
meteorPublish(MeteorPubSub.coreSystem, async function (_token: string | undefined) {
1011
triggerWriteAccessBecauseNoCheckNecessary()
@@ -26,7 +27,7 @@ meteorPublish(MeteorPubSub.coreSystem, async function (_token: string | undefine
2627
})
2728
})
2829

29-
meteorPublish(MeteorPubSub.notificationsForRundown, async function (studioId: StudioId, rundownId: RundownId) {
30+
meteorPublish(CorelibPubSub.notificationsForRundown, async function (studioId: StudioId, rundownId: RundownId) {
3031
// HACK: This should do real auth
3132
triggerWriteAccessBecauseNoCheckNecessary()
3233

@@ -41,7 +42,7 @@ meteorPublish(MeteorPubSub.notificationsForRundown, async function (studioId: St
4142
})
4243

4344
meteorPublish(
44-
MeteorPubSub.notificationsForRundownPlaylist,
45+
CorelibPubSub.notificationsForRundownPlaylist,
4546
async function (studioId: StudioId, playlistId: RundownPlaylistId) {
4647
// HACK: This should do real auth
4748
triggerWriteAccessBecauseNoCheckNecessary()

packages/corelib/src/pubsub.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import { BlueprintId, BucketId, RundownPlaylistActivationId, SegmentId, ShowStyl
3838
import { PackageInfoDB } from './dataModel/PackageInfos.js'
3939
import { UIPieceContentStatus } from './dataModel/PieceContentStatus.js'
4040
import { Bucket } from './dataModel/Bucket.js'
41+
import { DBNotificationObj } from './dataModel/Notifications.js'
4142

4243
/**
4344
* Ids of possible DDP subscriptions for any the UI and gateways accessing the Rundown & RundownPlaylist model.
@@ -130,6 +131,14 @@ export enum CorelibPubSub {
130131
* Fetch all Expected Package statuses in the specified Studios
131132
*/
132133
expectedPackageWorkStatuses = 'expectedPackageWorkStatuses',
134+
/**
135+
* Fetch notifications for playlist
136+
*/
137+
notificationsForRundownPlaylist = 'notificationsForRundownPlaylist',
138+
/**
139+
* Fetch notifications for rundown
140+
*/
141+
notificationsForRundown = 'notificationsForRundown',
133142
/**
134143
* Fetch all Package container statuses in the specified Studios
135144
*/
@@ -328,6 +337,11 @@ export interface CorelibPubSubTypes {
328337
studioIds: StudioId[],
329338
token?: string
330339
) => CollectionName.PackageContainerStatuses
340+
[CorelibPubSub.notificationsForRundown]: (studioId: StudioId, rundownId: RundownId) => CollectionName.Notifications
341+
[CorelibPubSub.notificationsForRundownPlaylist]: (
342+
studioId: StudioId,
343+
playlistId: RundownPlaylistId
344+
) => CollectionName.Notifications
331345
[CorelibPubSub.packageInfos]: (deviceId: PeripheralDeviceId, token?: string) => CollectionName.PackageInfos
332346

333347
[CorelibPubSub.uiPieceContentStatuses]: (
@@ -345,6 +359,7 @@ export type CorelibPubSubCollections = {
345359
[CollectionName.ExpectedPackages]: ExpectedPackageDBBase
346360
[CollectionName.ExpectedPackageWorkStatuses]: ExpectedPackageWorkStatus
347361
[CollectionName.ExternalMessageQueue]: ExternalMessageQueueObj
362+
[CollectionName.Notifications]: DBNotificationObj
348363
[CollectionName.NrcsIngestDataCache]: NrcsIngestDataCacheObj
349364
[CollectionName.PartInstances]: DBPartInstance
350365
[CollectionName.PackageContainerStatuses]: PackageContainerStatusDB

packages/live-status-gateway-api/api/asyncapi.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,5 @@ channels:
4747
$ref: './topics/packages/packagesTopic.yaml'
4848
buckets:
4949
$ref: './topics/buckets/bucketsTopic.yaml'
50+
notifications:
51+
$ref: './topics/notifications/notificationsTopic.yaml'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
event: notifications
2+
activeNotifications:
3+
- $ref: '../../notificationObj/notificationObj-example.yaml'
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
$defs:
2+
notificationsEvent:
3+
type: object
4+
title: NotificationsEvent
5+
description: Active notifications in Sofie
6+
properties:
7+
event:
8+
type: string
9+
const: notifications
10+
activeNotifications:
11+
description: Active notifications in Sofie
12+
type: array
13+
items:
14+
$ref: '../../notificationObj/notificationObj.yaml#/$defs/NotificationObj'
15+
required: [event, activeNotifications]
16+
additionalProperties: false
17+
examples:
18+
- $ref: './notificationsEvent-example.yaml'
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
components:
2+
messages:
3+
notificationsMessage:
4+
messageId: notificationsUpdate
5+
title: Active notifications in Sofie
6+
payload:
7+
$ref: '../events/notificationsEvent/notificationsEvent.yaml#/$defs/notificationsEvent'
8+
examples:
9+
- payload:
10+
$ref: '../events/notificationsEvent/notificationsEvent-example.yaml'
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
_id: 'notif123'
2+
severity: error
3+
message: 'disk.space.low'
4+
relatedTo:
5+
$ref: '../target/pieceInstance/notificationTargetPieceInstance-example.yaml'
6+
created: 1694784932
7+
modified: 1694784950
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
$defs:
2+
NotificationObj:
3+
type: object
4+
title: NotificationObj
5+
description: This describes a notification that should be shown to a user. These can come from various sources, and are added and removed dynamically during system usage
6+
required:
7+
- _id
8+
- severity
9+
- message
10+
- relatedTo
11+
- created
12+
properties:
13+
_id:
14+
type: string
15+
description: Unique identifier for the notification
16+
severity:
17+
$ref: '../notificationSeverity.yaml#/$defs/severity'
18+
message:
19+
type: string
20+
description: The message of the notification
21+
relatedTo:
22+
$ref: '../target/notificationTarget.yaml#/$defs/NotificationTarget'
23+
created:
24+
type: integer
25+
format: int64
26+
description: Unix timestamp of creation
27+
modified:
28+
type: integer
29+
format: int64
30+
description: Unix timestamp of last modification
31+
additionalProperties: false
32+
examples:
33+
- $ref: './notificationObj-example.yaml'
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
$defs:
2+
severity:
3+
type: string
4+
title: NotificationSeverity
5+
description: Severity level of the notification.
6+
enum:
7+
- warning
8+
- error
9+
- info
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
$defs:
2+
NotificationTarget:
3+
title: NotificationTarget
4+
description: Describes what the notification is related to
5+
oneOf:
6+
- $ref: './rundown/notificationTargetRundown.yaml#/$defs/NotificationTargetRundown'
7+
- $ref: './rundownPlaylist/notificationTargetRundownPlaylist.yaml#/$defs/NotificationTargetRundownPlaylist'
8+
- $ref: './partInstance/notificationTargetPartInstance.yaml#/$defs/NotificationTargetPartInstance'
9+
- $ref: './pieceInstance/notificationTargetPieceInstance.yaml#/$defs/NotificationTargetPieceInstance'
10+
- $ref: './unknown/notificationTargetUnknown.yaml#/$defs/NotificationTargetUnknown'
11+
examples:
12+
- $ref: './rundown/notificationTargetRundown-example.yaml'
13+
- $ref: './rundownPlaylist/notificationTargetRundownPlaylist-example.yaml'
14+
- $ref: './partInstance/notificationTargetPartInstance-example.yaml'
15+
- $ref: './pieceInstance/notificationTargetPieceInstance-example.yaml'
16+
- $ref: './unknown/notificationTargetUnknown-example.yaml'

0 commit comments

Comments
 (0)