@bolt.tech/kafka-utils 1.0.13 → 2.0.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/build/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { notificationType } from './store/types/notification.type';
|
|
2
2
|
import { IUser, IMessage, ISmsObj, IOneSignalPayload, IAttachment } from './store/interfaces/notification.interface';
|
|
3
|
+
import { IWhatsappPayload } from './store/interfaces/whatsappPayload.interface';
|
|
3
4
|
export declare function initialiseNotification(paramStorePath: string, nodeEnvLocal: string, serviceName: string, notificationType: notificationType): Promise<void>;
|
|
4
5
|
export declare function sendEmailNotifications(user: IUser, message: IMessage, attachment?: IAttachment): Promise<void>;
|
|
5
6
|
export declare function sendSmsNotifications(user: IUser, message: IMessage, smsObj: ISmsObj): Promise<void>;
|
|
6
7
|
export declare function sendPushNotification(user: IUser, message: IMessage, appId: string, oneSignalPayload: IOneSignalPayload): Promise<void>;
|
|
7
8
|
export declare function sendInAppNotification(user: IUser, message: IMessage, appId: string): Promise<void>;
|
|
9
|
+
export declare function sendWhatsappNotification(whatsappPayload: IWhatsappPayload): Promise<void>;
|
package/build/index.js
CHANGED
|
@@ -14,6 +14,7 @@ exports.sendEmailNotifications = sendEmailNotifications;
|
|
|
14
14
|
exports.sendSmsNotifications = sendSmsNotifications;
|
|
15
15
|
exports.sendPushNotification = sendPushNotification;
|
|
16
16
|
exports.sendInAppNotification = sendInAppNotification;
|
|
17
|
+
exports.sendWhatsappNotification = sendWhatsappNotification;
|
|
17
18
|
const notificationSchema_registry_1 = require("./utils/schemaRegistry/notificationSchema.registry");
|
|
18
19
|
const getTopic = require('./utils/kafka/topicMap.kafka');
|
|
19
20
|
const publishToKafka = require('./utils/kafka/publisher.kafka');
|
|
@@ -126,3 +127,18 @@ function sendInAppNotification(user, message, appId) {
|
|
|
126
127
|
yield sendNotificationToKafka(user.inAppNotificationUserId, payload);
|
|
127
128
|
});
|
|
128
129
|
}
|
|
130
|
+
/* send whatsapp notifications to users */
|
|
131
|
+
function sendWhatsappNotification(whatsappPayload) {
|
|
132
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
133
|
+
var _a;
|
|
134
|
+
if (!((_a = whatsappPayload === null || whatsappPayload === void 0 ? void 0 : whatsappPayload.phone) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
135
|
+
console.log("No phone number provided");
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
const payload = {
|
|
139
|
+
user: { phoneNumbers: [whatsappPayload.phone] },
|
|
140
|
+
whatsappPayload,
|
|
141
|
+
};
|
|
142
|
+
yield sendNotificationToKafka(whatsappPayload.phone, payload);
|
|
143
|
+
});
|
|
144
|
+
}
|
|
@@ -27,4 +27,10 @@ message AssetsTriggerNotification {
|
|
|
27
27
|
optional bool sos = 2;
|
|
28
28
|
optional string vin = 3;
|
|
29
29
|
}
|
|
30
|
+
message WhatsappPayload {
|
|
31
|
+
optional string name = 1;
|
|
32
|
+
optional string phone = 2;
|
|
33
|
+
optional string template_name = 3;
|
|
34
|
+
map<string, string> template_params = 4;
|
|
35
|
+
}
|
|
30
36
|
}
|