podverse-notifications 5.1.19-alpha.0 → 5.1.21-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/index.d.ts +1 -0
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +1 -0
- package/dist/services/notifications/notificationOrchestrator.d.ts +3 -1
- package/dist/services/notifications/notificationOrchestrator.d.ts.map +1 -1
- package/dist/services/notifications/notificationOrchestrator.js +18 -8
- package/dist/services/unifiedpush/unifiedpushNotification.d.ts +0 -1
- package/dist/services/unifiedpush/unifiedpushNotification.d.ts.map +1 -1
- package/dist/services/unifiedpush/unifiedpushNotification.js +3 -2
- package/dist/services/unifiedpush/unifiedpushNotificationOrchestrator.d.ts +2 -1
- package/dist/services/unifiedpush/unifiedpushNotificationOrchestrator.d.ts.map +1 -1
- package/dist/services/unifiedpush/unifiedpushNotificationOrchestrator.js +3 -3
- package/dist/services/webpush/webpushNotification.d.ts +0 -1
- package/dist/services/webpush/webpushNotification.d.ts.map +1 -1
- package/dist/services/webpush/webpushNotification.js +3 -2
- package/dist/services/webpush/webpushNotificationOrchestrator.d.ts +2 -1
- package/dist/services/webpush/webpushNotificationOrchestrator.d.ts.map +1 -1
- package/dist/services/webpush/webpushNotificationOrchestrator.js +3 -3
- package/package.json +3 -3
package/dist/config/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM;;;;;;;;;;;;;CAalB,CAAC;AAEF,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAI1D;AAED,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C"}
|
package/dist/config/index.js
CHANGED
|
@@ -5,6 +5,7 @@ exports.getWebBaseUrl = getWebBaseUrl;
|
|
|
5
5
|
exports.getWebBaseUrlWithPath = getWebBaseUrlWithPath;
|
|
6
6
|
exports.getWebIconImageUrl = getWebIconImageUrl;
|
|
7
7
|
exports.config = {
|
|
8
|
+
brandName: process.env.BRAND_NAME || "Podverse",
|
|
8
9
|
web: {
|
|
9
10
|
protocol: process.env.WEB_PROTOCOL || "http",
|
|
10
11
|
host: process.env.WEB_DOMAIN || "localhost",
|
|
@@ -7,8 +7,10 @@ type BaseNotificationOrchestratorParams = {
|
|
|
7
7
|
messageText: string;
|
|
8
8
|
messageType: NotificationMessageType;
|
|
9
9
|
locale: string;
|
|
10
|
-
|
|
10
|
+
body?: string;
|
|
11
|
+
image?: string;
|
|
11
12
|
linkIdText?: string;
|
|
13
|
+
mediumId: number;
|
|
12
14
|
data?: Record<string, unknown>;
|
|
13
15
|
};
|
|
14
16
|
type FirebaseNotificationOrchestratorParams = BaseNotificationOrchestratorParams & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notificationOrchestrator.d.ts","sourceRoot":"","sources":["../../../src/services/notifications/notificationOrchestrator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"notificationOrchestrator.d.ts","sourceRoot":"","sources":["../../../src/services/notifications/notificationOrchestrator.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAqB,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAEjF,MAAM,MAAM,oBAAoB,GAAG,KAAK,GAAG,SAAS,GAAG,KAAK,CAAC;AAC7D,MAAM,MAAM,mBAAmB,GAAG,UAAU,GAAG,SAAS,GAAG,aAAa,CAAC;AAmCzE,KAAK,kCAAkC,GAAG;IACxC,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,uBAAuB,CAAC;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC,CAAC;AAGF,KAAK,sCAAsC,GAAG,kCAAkC,GAAG;IACjF,OAAO,EAAE,UAAU,CAAC;IACpB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAGF,KAAK,qCAAqC,GAAG,kCAAkC,GAAG;IAChF,OAAO,EAAE,SAAS,CAAC;IACnB,aAAa,EAAE,mBAAmB,EAAE,CAAC;CACtC,CAAC;AAGF,KAAK,yCAAyC,GAAG,kCAAkC,GAAG;IACpF,OAAO,EAAE,aAAa,CAAC;IACvB,aAAa,EAAE,cAAc,EAAE,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,8BAA8B,GACtC,sCAAsC,GACtC,qCAAqC,GACrC,yCAAyC,CAAC;AAS9C,wBAAsB,wBAAwB,CAAC,MAAM,EAAE,8BAA8B,kBAuDpF"}
|
|
@@ -10,14 +10,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.notificationOrchestrator = notificationOrchestrator;
|
|
13
|
+
const podverse_helpers_1 = require("podverse-helpers");
|
|
13
14
|
const podverse_external_services_1 = require("podverse-external-services");
|
|
14
15
|
const webpush_1 = require("../webpush");
|
|
15
16
|
const unifiedpush_1 = require("../unifiedpush");
|
|
16
17
|
const i18nNotifications_1 = require("./i18nNotifications");
|
|
17
18
|
/**
|
|
18
19
|
* Gets the URL path prefix for a given notification message type
|
|
20
|
+
* @param messageType - The type of notification message
|
|
21
|
+
* @param mediumId - Medium ID for medium-specific paths (e.g., livestreams)
|
|
19
22
|
*/
|
|
20
|
-
function getLinkPathFromMessageType(messageType) {
|
|
23
|
+
function getLinkPathFromMessageType(messageType, mediumId) {
|
|
21
24
|
switch (messageType) {
|
|
22
25
|
case 'new-episode':
|
|
23
26
|
return '/episode';
|
|
@@ -33,7 +36,11 @@ function getLinkPathFromMessageType(messageType) {
|
|
|
33
36
|
return '/album';
|
|
34
37
|
case 'livestream-started':
|
|
35
38
|
case 'livestream-scheduled':
|
|
36
|
-
|
|
39
|
+
// Music livestreams use /music/livestream, all others use /podcast/livestream
|
|
40
|
+
if (mediumId === podverse_helpers_1.MediumEnum.Music) {
|
|
41
|
+
return '/music/livestream';
|
|
42
|
+
}
|
|
43
|
+
return '/podcast/livestream';
|
|
37
44
|
case 'new':
|
|
38
45
|
default:
|
|
39
46
|
return '';
|
|
@@ -47,12 +54,12 @@ function getFinalText(messageText, messageType, locale) {
|
|
|
47
54
|
}
|
|
48
55
|
function notificationOrchestrator(params) {
|
|
49
56
|
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
-
const { service, messageText, messageType, locale, linkIdText,
|
|
57
|
+
const { service, messageText, messageType, locale, body, linkIdText, mediumId, image, data } = params;
|
|
51
58
|
const finalText = getFinalText(messageText, messageType, locale);
|
|
52
|
-
// Construct the link from messageType and linkIdText
|
|
59
|
+
// Construct the link from messageType, mediumId, and linkIdText
|
|
53
60
|
let link;
|
|
54
61
|
if (linkIdText) {
|
|
55
|
-
const pathPrefix = getLinkPathFromMessageType(messageType);
|
|
62
|
+
const pathPrefix = getLinkPathFromMessageType(messageType, mediumId);
|
|
56
63
|
link = pathPrefix ? `${pathPrefix}/${linkIdText}` : undefined;
|
|
57
64
|
}
|
|
58
65
|
switch (service) {
|
|
@@ -62,8 +69,9 @@ function notificationOrchestrator(params) {
|
|
|
62
69
|
tokens: firebaseParams.tokens,
|
|
63
70
|
platform: firebaseParams.platform,
|
|
64
71
|
finalText,
|
|
72
|
+
body,
|
|
65
73
|
link,
|
|
66
|
-
|
|
74
|
+
image,
|
|
67
75
|
channelId: firebaseParams.channelId,
|
|
68
76
|
badge: firebaseParams.badge,
|
|
69
77
|
sound: firebaseParams.sound,
|
|
@@ -75,8 +83,9 @@ function notificationOrchestrator(params) {
|
|
|
75
83
|
return yield (0, webpush_1.webpushNotificationBatchOrchestrator)({
|
|
76
84
|
subscriptions: webpushParams.subscriptions,
|
|
77
85
|
finalText,
|
|
86
|
+
body,
|
|
78
87
|
link,
|
|
79
|
-
|
|
88
|
+
image,
|
|
80
89
|
data,
|
|
81
90
|
});
|
|
82
91
|
}
|
|
@@ -85,8 +94,9 @@ function notificationOrchestrator(params) {
|
|
|
85
94
|
return yield (0, unifiedpush_1.unifiedpushNotificationBatchOrchestrator)({
|
|
86
95
|
subscriptions: upParams.subscriptions,
|
|
87
96
|
finalText,
|
|
97
|
+
body,
|
|
88
98
|
link,
|
|
89
|
-
|
|
99
|
+
image,
|
|
90
100
|
data,
|
|
91
101
|
});
|
|
92
102
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unifiedpushNotification.d.ts","sourceRoot":"","sources":["../../../src/services/unifiedpush/unifiedpushNotification.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGtD,KAAK,SAAS,GAAG;IACf,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,
|
|
1
|
+
{"version":3,"file":"unifiedpushNotification.d.ts","sourceRoot":"","sources":["../../../src/services/unifiedpush/unifiedpushNotification.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGtD,KAAK,SAAS,GAAG;IACf,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC,CAAC;AAEF,KAAK,QAAQ,GAAG;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAsB,uBAAuB,CAC3C,aAAa,EAAE,cAAc,EAAE,EAC/B,OAAO,EAAE,SAAS,GACjB,OAAO,CAAC,QAAQ,EAAE,CAAC,CA0ErB"}
|
|
@@ -33,10 +33,11 @@ function sendUPNotificationBatch(subscriptions, payload) {
|
|
|
33
33
|
const headers = {
|
|
34
34
|
'Content-Type': 'text/plain',
|
|
35
35
|
'X-Title': payload.title,
|
|
36
|
+
'X-Tags': config_1.config.brandName,
|
|
36
37
|
'X-Click': payload.link ? (0, config_1.getWebBaseUrlWithPath)(payload.link) : (0, config_1.getWebBaseUrl)(),
|
|
37
|
-
'X-Icon':
|
|
38
|
+
'X-Icon': (0, config_1.getWebIconImageUrl)(), // Always use app icon for branding
|
|
38
39
|
};
|
|
39
|
-
// Add
|
|
40
|
+
// Add item/channel artwork as image attachment for preview
|
|
40
41
|
if (payload.image) {
|
|
41
42
|
headers['X-Attach'] = payload.image;
|
|
42
43
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unifiedpushNotificationOrchestrator.d.ts","sourceRoot":"","sources":["../../../src/services/unifiedpush/unifiedpushNotificationOrchestrator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,KAAK,oBAAoB,GAAG;IAC1B,aAAa,EAAE,cAAc,EAAE,CAAC;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC,CAAC;AAEF,wBAAsB,wCAAwC,CAAC,MAAM,EAAE,oBAAoB;;;;KAc1F"}
|
|
1
|
+
{"version":3,"file":"unifiedpushNotificationOrchestrator.d.ts","sourceRoot":"","sources":["../../../src/services/unifiedpush/unifiedpushNotificationOrchestrator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,KAAK,oBAAoB,GAAG;IAC1B,aAAa,EAAE,cAAc,EAAE,CAAC;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC,CAAC;AAEF,wBAAsB,wCAAwC,CAAC,MAAM,EAAE,oBAAoB;;;;KAc1F"}
|
|
@@ -13,11 +13,11 @@ exports.unifiedpushNotificationBatchOrchestrator = unifiedpushNotificationBatchO
|
|
|
13
13
|
const unifiedpushNotification_1 = require("./unifiedpushNotification");
|
|
14
14
|
function unifiedpushNotificationBatchOrchestrator(params) {
|
|
15
15
|
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
-
const { subscriptions, finalText,
|
|
16
|
+
const { subscriptions, finalText, body, image, link, data } = params;
|
|
17
17
|
const payload = {
|
|
18
18
|
title: finalText,
|
|
19
|
-
body
|
|
20
|
-
|
|
19
|
+
body,
|
|
20
|
+
image,
|
|
21
21
|
link,
|
|
22
22
|
data,
|
|
23
23
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webpushNotification.d.ts","sourceRoot":"","sources":["../../../src/services/webpush/webpushNotification.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAGvD,KAAK,cAAc,GAAG;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,
|
|
1
|
+
{"version":3,"file":"webpushNotification.d.ts","sourceRoot":"","sources":["../../../src/services/webpush/webpushNotification.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAGvD,KAAK,cAAc,GAAG;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC,CAAC;AAEF,KAAK,aAAa,GAAG;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,wBAAsB,4BAA4B,CAChD,aAAa,EAAE,mBAAmB,EAAE,EACpC,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,aAAa,EAAE,CAAC,CA4D1B"}
|
|
@@ -26,8 +26,8 @@ function sendWebPushNotificationBatch(subscriptions, payload) {
|
|
|
26
26
|
const notificationPayload = JSON.stringify({
|
|
27
27
|
title: payload.title,
|
|
28
28
|
body: payload.body || "",
|
|
29
|
-
icon:
|
|
30
|
-
image: payload.image,
|
|
29
|
+
icon: (0, config_1.getWebIconImageUrl)(), // Always use app icon for branding
|
|
30
|
+
image: payload.image, // Item/channel artwork
|
|
31
31
|
link: payload.link ? (0, config_1.getWebBaseUrlWithPath)(payload.link) : (0, config_1.getWebBaseUrl)(),
|
|
32
32
|
data: payload.data,
|
|
33
33
|
});
|
|
@@ -41,6 +41,7 @@ function sendWebPushNotificationBatch(subscriptions, payload) {
|
|
|
41
41
|
urgency: 'normal',
|
|
42
42
|
});
|
|
43
43
|
return { success: true, endpoint: subscription.endpoint };
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
44
45
|
}
|
|
45
46
|
catch (error) {
|
|
46
47
|
console.error(`Web Push send failed for ${subscription.endpoint}:`, error.message);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webpushNotificationOrchestrator.d.ts","sourceRoot":"","sources":["../../../src/services/webpush/webpushNotificationOrchestrator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,KAAK,yBAAyB,GAAG;IAC/B,aAAa,EAAE,mBAAmB,EAAE,CAAC;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC,CAAC;AAEF,wBAAsB,oCAAoC,CAAC,MAAM,EAAE,yBAAyB;;;;KAc3F"}
|
|
1
|
+
{"version":3,"file":"webpushNotificationOrchestrator.d.ts","sourceRoot":"","sources":["../../../src/services/webpush/webpushNotificationOrchestrator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,KAAK,yBAAyB,GAAG;IAC/B,aAAa,EAAE,mBAAmB,EAAE,CAAC;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC,CAAC;AAEF,wBAAsB,oCAAoC,CAAC,MAAM,EAAE,yBAAyB;;;;KAc3F"}
|
|
@@ -13,11 +13,11 @@ exports.webpushNotificationBatchOrchestrator = webpushNotificationBatchOrchestra
|
|
|
13
13
|
const webpushNotification_1 = require("./webpushNotification");
|
|
14
14
|
function webpushNotificationBatchOrchestrator(params) {
|
|
15
15
|
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
-
const { subscriptions, finalText,
|
|
16
|
+
const { subscriptions, finalText, body, image, link, data } = params;
|
|
17
17
|
const payload = {
|
|
18
18
|
title: finalText,
|
|
19
|
-
body
|
|
20
|
-
|
|
19
|
+
body,
|
|
20
|
+
image,
|
|
21
21
|
link,
|
|
22
22
|
data,
|
|
23
23
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "podverse-notifications",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.21-alpha.0",
|
|
4
4
|
"description": "Push notification helper module for Podverse use cases",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
"license": "AGPLv3",
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"module-alias": "^2.2.3",
|
|
20
|
-
"podverse-external-services": "^5.1.
|
|
21
|
-
"podverse-helpers": "^5.1.
|
|
20
|
+
"podverse-external-services": "^5.1.21-alpha.0",
|
|
21
|
+
"podverse-helpers": "^5.1.21-alpha.0",
|
|
22
22
|
"web-push": "^3.6.7"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|