@messenger-box/platform-server 10.0.3-alpha.7 → 10.0.3-alpha.72
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/lib/containers/containers.js +4 -1
- package/lib/containers/containers.js.map +1 -1
- package/lib/containers/context-services-from-container.d.ts +1 -1
- package/lib/containers/context-services-from-container.js +1 -1
- package/lib/containers/context-services-from-container.js.map +1 -1
- package/lib/graphql/resolvers/channel-member.d.ts +3 -2
- package/lib/graphql/resolvers/channel-member.js +30 -5
- package/lib/graphql/resolvers/channel-member.js.map +1 -1
- package/lib/graphql/resolvers/channel.d.ts +3 -2
- package/lib/graphql/resolvers/channel.js +279 -53
- package/lib/graphql/resolvers/channel.js.map +1 -1
- package/lib/graphql/resolvers/extended-token-account.d.ts +3 -2
- package/lib/graphql/resolvers/extended-token-account.js +90 -23
- package/lib/graphql/resolvers/extended-token-account.js.map +1 -1
- package/lib/graphql/resolvers/index.d.ts +1 -1
- package/lib/graphql/resolvers/post-thread.d.ts +1 -1
- package/lib/graphql/resolvers/post-thread.js +294 -132
- package/lib/graphql/resolvers/post-thread.js.map +1 -1
- package/lib/graphql/resolvers/post.d.ts +2 -3
- package/lib/graphql/resolvers/post.js +696 -234
- package/lib/graphql/resolvers/post.js.map +1 -1
- package/lib/graphql/resolvers/reaction.d.ts +3 -2
- package/lib/graphql/resolvers/reaction.js +96 -14
- package/lib/graphql/resolvers/reaction.js.map +1 -1
- package/lib/graphql/schema/channel-member.graphql +110 -21
- package/lib/graphql/schema/channel-member.graphql.js +1 -1
- package/lib/graphql/schema/channel.graphql +337 -38
- package/lib/graphql/schema/channel.graphql.js +1 -1
- package/lib/graphql/schema/post-thread.graphql +167 -21
- package/lib/graphql/schema/post-thread.graphql.js +1 -1
- package/lib/graphql/schema/post.graphql +284 -40
- package/lib/graphql/schema/post.graphql.js +1 -1
- package/lib/graphql/schema/reaction.graphql +71 -13
- package/lib/graphql/schema/reaction.graphql.js +1 -1
- package/lib/graphql/schema/services.graphql +2 -0
- package/lib/graphql/schema/users.graphql +76 -13
- package/lib/graphql/schema/users.graphql.js +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/interfaces/index.d.ts +0 -1
- package/lib/interfaces/services.d.ts +1 -1
- package/lib/migrations/dbMigrations/AddPostsConfigurationsMigration.d.ts +17 -0
- package/lib/migrations/dbMigrations/AddPostsConfigurationsMigration.js +44 -0
- package/lib/migrations/dbMigrations/AddPostsConfigurationsMigration.js.map +1 -0
- package/lib/migrations/dbMigrations/index.d.ts +1 -0
- package/lib/migrations/index.d.ts +1 -0
- package/lib/migrations/mail-template-migration.js +1 -1
- package/lib/migrations/message-notification-template-migration.d.ts +1 -1
- package/lib/migrations/message-notification-template-migration.js +1 -1
- package/lib/plugins/channel-moleculer-service.d.ts +21 -1
- package/lib/plugins/channel-moleculer-service.js +417 -115
- package/lib/plugins/channel-moleculer-service.js.map +1 -1
- package/lib/plugins/extended-token-account-moleculer-service.d.ts +25 -1
- package/lib/plugins/extended-token-account-moleculer-service.js +348 -22
- package/lib/plugins/extended-token-account-moleculer-service.js.map +1 -1
- package/lib/plugins/messenger-notification-moleculer-service.d.ts +27 -3
- package/lib/plugins/messenger-notification-moleculer-service.js +404 -58
- package/lib/plugins/messenger-notification-moleculer-service.js.map +1 -1
- package/lib/plugins/post-moleculer-service.d.ts +85 -21
- package/lib/plugins/post-moleculer-service.js +986 -256
- package/lib/plugins/post-moleculer-service.js.map +1 -1
- package/lib/plugins/post-thread-moleculer-service.d.ts +33 -1
- package/lib/plugins/post-thread-moleculer-service.js +326 -8
- package/lib/plugins/post-thread-moleculer-service.js.map +1 -1
- package/lib/plugins/reaction-moleculer-service.js +1 -1
- package/lib/plugins/reaction-moleculer-service.js.map +1 -1
- package/lib/preferences/settings/post-settings.d.ts +2 -0
- package/lib/preferences/settings/post-settings.js +47 -9
- package/lib/preferences/settings/post-settings.js.map +1 -1
- package/lib/services/channel-service.d.ts +179 -33
- package/lib/services/channel-service.js +821 -274
- package/lib/services/channel-service.js.map +1 -1
- package/lib/services/extended-token-account-service.d.ts +130 -14
- package/lib/services/extended-token-account-service.js +462 -52
- package/lib/services/extended-token-account-service.js.map +1 -1
- package/lib/services/index.d.ts +1 -0
- package/lib/services/messenger-notification-service.d.ts +106 -13
- package/lib/services/messenger-notification-service.js +824 -442
- package/lib/services/messenger-notification-service.js.map +1 -1
- package/lib/services/post-service.d.ts +182 -16
- package/lib/services/post-service.js +731 -115
- package/lib/services/post-service.js.map +1 -1
- package/lib/services/post-thread-service.d.ts +114 -5
- package/lib/services/post-thread-service.js +400 -13
- package/lib/services/post-thread-service.js.map +1 -1
- package/lib/services/proxy-services/channel-microservice.d.ts +5 -3
- package/lib/services/proxy-services/channel-microservice.js +19 -10
- package/lib/services/proxy-services/channel-microservice.js.map +1 -1
- package/lib/services/proxy-services/messenger-notification-microservice.d.ts +128 -8
- package/lib/services/proxy-services/messenger-notification-microservice.js +324 -29
- package/lib/services/proxy-services/messenger-notification-microservice.js.map +1 -1
- package/lib/services/proxy-services/post-microservice.d.ts +186 -12
- package/lib/services/proxy-services/post-microservice.js +543 -54
- package/lib/services/proxy-services/post-microservice.js.map +1 -1
- package/lib/services/proxy-services/post-thread-microservice.d.ts +134 -3
- package/lib/services/proxy-services/post-thread-microservice.js +388 -6
- package/lib/services/proxy-services/post-thread-microservice.js.map +1 -1
- package/lib/services/proxy-services/reaction-microservice.d.ts +161 -3
- package/lib/services/proxy-services/reaction-microservice.js +474 -2
- package/lib/services/proxy-services/reaction-microservice.js.map +1 -1
- package/lib/services/reaction-service.d.ts +124 -4
- package/lib/services/reaction-service.js +415 -3
- package/lib/services/reaction-service.js.map +1 -1
- package/lib/services/redis-cache-manager.d.ts +18 -0
- package/lib/services/redis-cache-manager.js +83 -0
- package/lib/services/redis-cache-manager.js.map +1 -0
- package/lib/store/models/account-token-store.d.ts +1 -1
- package/lib/store/models/account-token-store.js.map +1 -1
- package/lib/store/models/channel.d.ts +2 -3
- package/lib/store/models/channel.js +181 -72
- package/lib/store/models/channel.js.map +1 -1
- package/lib/store/models/post-thread.d.ts +3 -3
- package/lib/store/models/post-thread.js +96 -14
- package/lib/store/models/post-thread.js.map +1 -1
- package/lib/store/models/post.d.ts +2 -3
- package/lib/store/models/post.js +143 -23
- package/lib/store/models/post.js.map +1 -1
- package/lib/store/models/reaction.d.ts +2 -3
- package/lib/store/models/reaction.js +67 -8
- package/lib/store/models/reaction.js.map +1 -1
- package/lib/store/repositories/__tests__/__fixtures__/team-repository.d.ts +3 -3
- package/lib/store/repositories/channel-repository.d.ts +6 -6
- package/lib/store/repositories/channel-repository.js +5 -2
- package/lib/store/repositories/channel-repository.js.map +1 -1
- package/lib/store/repositories/post-repository.d.ts +6 -6
- package/lib/store/repositories/post-repository.js +5 -2
- package/lib/store/repositories/post-repository.js.map +1 -1
- package/lib/store/repositories/post-thread-repository.d.ts +6 -6
- package/lib/store/repositories/post-thread-repository.js +5 -2
- package/lib/store/repositories/post-thread-repository.js.map +1 -1
- package/lib/store/repositories/reaction-repository.d.ts +6 -6
- package/lib/store/repositories/reaction-repository.js +5 -2
- package/lib/store/repositories/reaction-repository.js.map +1 -1
- package/lib/templates/constants/SERVER_TYPES.ts.template +0 -3
- package/lib/templates/repositories/ChannelRepository.ts.template +3 -3
- package/lib/templates/repositories/PostRepository.ts.template +3 -3
- package/lib/templates/repositories/PostThreadRepository.ts.template +3 -3
- package/lib/templates/repositories/ReactionRepository.ts.template +3 -4
- package/lib/templates/services/ChannelService.ts.template +280 -39
- package/lib/templates/services/ExtendedTokenAccountService.ts.template +104 -9
- package/lib/templates/services/MessengerNotificationService.ts.template +94 -19
- package/lib/templates/services/PostService.ts.template +184 -20
- package/lib/templates/services/PostThreadService.ts.template +151 -6
- package/lib/templates/services/ReactionService.ts.template +129 -3
- package/lib/templates/services/RedisCacheManager.ts.template +22 -0
- package/package.json +6 -5
- package/lib/interfaces/context.d.ts +0 -14
- package/lib/store/models/common-options.js +0 -20
- package/lib/store/models/common-options.js.map +0 -1
|
@@ -1,113 +1,459 @@
|
|
|
1
|
-
import {Service}from'moleculer';import {SERVER_TYPES,MoleculerServiceName,MessengerNotificationServiceCommands}from'common';import {ApolloClientMixin}from'@adminide-stack/platform-server';import {config}from'../config/env-config.js';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import {Service}from'moleculer';import {SERVER_TYPES,MoleculerServiceName,MessengerNotificationServiceCommands}from'common/server';import {ApolloClientMixin}from'@adminide-stack/platform-server';import {config}from'../config/env-config.js';import {logger}from'@common-stack/server-core';/**
|
|
2
|
+
* Messenger Notification Moleculer Service
|
|
3
|
+
*
|
|
4
|
+
* This Moleculer service provides a comprehensive microservice interface for notification
|
|
5
|
+
* management within the messenger platform. It orchestrates various notification workflows
|
|
6
|
+
* including email, SMS, push notifications, and Expo notifications through event-driven
|
|
7
|
+
* architecture.
|
|
8
|
+
*
|
|
9
|
+
* Key capabilities:
|
|
10
|
+
* - Multi-channel notification delivery (email, SMS, push, Expo)
|
|
11
|
+
* - Unread message notification scheduling and management
|
|
12
|
+
* - Post-based notification triggering and routing
|
|
13
|
+
* - Alert message notification broadcasting
|
|
14
|
+
* - Support service notification handling
|
|
15
|
+
* - Cross-service communication and event handling
|
|
16
|
+
* - Cron job integration for scheduled notifications
|
|
17
|
+
* - Template-based notification customization
|
|
18
|
+
* - User preference-based notification filtering
|
|
19
|
+
* - Comprehensive error handling and monitoring
|
|
20
|
+
*
|
|
21
|
+
* The service integrates with multiple external services through Moleculer broker
|
|
22
|
+
* and provides robust notification management for real-time messaging workflows.
|
|
23
|
+
*/
|
|
24
|
+
class MessengerNotificationMoleculerService extends Service {
|
|
25
|
+
messengerNotificationService;
|
|
26
|
+
container;
|
|
5
27
|
constructor(broker, {
|
|
6
|
-
container
|
|
28
|
+
container,
|
|
29
|
+
settings
|
|
7
30
|
}) {
|
|
8
31
|
super(broker);
|
|
9
|
-
const messengerService = container.get(SERVER_TYPES.MessengerNotificationService);
|
|
10
32
|
this.container = container;
|
|
33
|
+
// Initialize the messenger notification service
|
|
34
|
+
this.messengerNotificationService = container.get(SERVER_TYPES.MessengerNotificationService);
|
|
11
35
|
this.parseServiceSchema({
|
|
12
36
|
name: MoleculerServiceName.MessengerNotificationService,
|
|
13
|
-
|
|
37
|
+
dependencies: [MoleculerServiceName.MailService, MoleculerServiceName.SmsService, MoleculerServiceName.AccountUser],
|
|
14
38
|
settings: {
|
|
15
39
|
apolloClient: {
|
|
16
40
|
serverUri: config.GRAPHQL_URL
|
|
41
|
+
},
|
|
42
|
+
...settings
|
|
43
|
+
},
|
|
44
|
+
mixins: [ApolloClientMixin],
|
|
45
|
+
events: {
|
|
46
|
+
/**
|
|
47
|
+
* Handles post creation events for notification triggering
|
|
48
|
+
*
|
|
49
|
+
* @description Processes new posts and triggers appropriate notifications
|
|
50
|
+
* based on post type and channel configuration
|
|
51
|
+
*/
|
|
52
|
+
'post.created': {
|
|
53
|
+
handler: async ctx => {
|
|
54
|
+
const {
|
|
55
|
+
event
|
|
56
|
+
} = ctx?.params || {};
|
|
57
|
+
try {
|
|
58
|
+
logger.debug('Processing post creation notification', {
|
|
59
|
+
postId: event?.post?.id,
|
|
60
|
+
channelId: event?.post?.channel,
|
|
61
|
+
hasNotificationData: !!event?.notificationData
|
|
62
|
+
});
|
|
63
|
+
if (!event?.post) {
|
|
64
|
+
logger.warn('Missing post data in post creation event');
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
// Send general post notification
|
|
68
|
+
const notificationResult = await this.messengerNotificationService.sendNotificationOnPost(event.post);
|
|
69
|
+
if (notificationResult instanceof Error) {
|
|
70
|
+
logger.error('Failed to send post notification: %o', notificationResult);
|
|
71
|
+
throw notificationResult;
|
|
72
|
+
}
|
|
73
|
+
// Send Expo notification if notification data is provided
|
|
74
|
+
if (event.notificationData) {
|
|
75
|
+
const expoResult = await this.messengerNotificationService.sendExpoNotificationOnPost(event.post, event.notificationData);
|
|
76
|
+
if (expoResult instanceof Error) {
|
|
77
|
+
logger.error('Failed to send Expo notification: %o', expoResult);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
logger.debug('Post notification processed successfully', {
|
|
81
|
+
postId: event.post.id,
|
|
82
|
+
notificationSent: notificationResult,
|
|
83
|
+
expoNotificationSent: !!event.notificationData
|
|
84
|
+
});
|
|
85
|
+
// Emit success event for monitoring
|
|
86
|
+
this.broker.emit('notification.post.sent', {
|
|
87
|
+
postId: event.post.id,
|
|
88
|
+
channelId: event.post.channel,
|
|
89
|
+
timestamp: new Date()
|
|
90
|
+
});
|
|
91
|
+
} catch (error) {
|
|
92
|
+
logger.error('Error processing post notification: %o', error);
|
|
93
|
+
// Emit error event for monitoring
|
|
94
|
+
this.broker.emit('notification.post.failed', {
|
|
95
|
+
postId: event?.post?.id,
|
|
96
|
+
channelId: event?.post?.channel,
|
|
97
|
+
error: error.message,
|
|
98
|
+
timestamp: new Date()
|
|
99
|
+
});
|
|
100
|
+
throw error;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
/**
|
|
105
|
+
* Handles alert message events
|
|
106
|
+
*
|
|
107
|
+
* @description Processes alert messages with immediate notification
|
|
108
|
+
*/
|
|
109
|
+
'alert.message.created': {
|
|
110
|
+
handler: async ctx => {
|
|
111
|
+
const {
|
|
112
|
+
event
|
|
113
|
+
} = ctx?.params || {};
|
|
114
|
+
try {
|
|
115
|
+
logger.debug('Processing alert message notification', {
|
|
116
|
+
postId: event?.post?.id,
|
|
117
|
+
priority: event?.priority
|
|
118
|
+
});
|
|
119
|
+
if (!event?.post) {
|
|
120
|
+
logger.warn('Missing post data in alert event');
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
const result = await this.messengerNotificationService.sendNotificationOnPost(event.post);
|
|
124
|
+
if (result instanceof Error) {
|
|
125
|
+
logger.error('Failed to send alert notification: %o', result);
|
|
126
|
+
throw result;
|
|
127
|
+
}
|
|
128
|
+
logger.debug('Alert notification sent successfully', {
|
|
129
|
+
postId: event.post.id,
|
|
130
|
+
priority: event.priority
|
|
131
|
+
});
|
|
132
|
+
// Emit alert notification event
|
|
133
|
+
this.broker.emit('notification.alert.sent', {
|
|
134
|
+
postId: event.post.id,
|
|
135
|
+
priority: event.priority,
|
|
136
|
+
timestamp: new Date()
|
|
137
|
+
});
|
|
138
|
+
} catch (error) {
|
|
139
|
+
logger.error('Error processing alert notification: %o', error);
|
|
140
|
+
this.broker.emit('notification.alert.failed', {
|
|
141
|
+
postId: event?.post?.id,
|
|
142
|
+
priority: event?.priority,
|
|
143
|
+
error: error.message,
|
|
144
|
+
timestamp: new Date()
|
|
145
|
+
});
|
|
146
|
+
throw error;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
/**
|
|
151
|
+
* Handles support service configuration updates
|
|
152
|
+
*
|
|
153
|
+
* @description Updates support service notification settings
|
|
154
|
+
*/
|
|
155
|
+
'support.service.config.updated': {
|
|
156
|
+
handler: async ctx => {
|
|
157
|
+
const {
|
|
158
|
+
event
|
|
159
|
+
} = ctx?.params || {};
|
|
160
|
+
try {
|
|
161
|
+
logger.debug('Processing support service config update');
|
|
162
|
+
if (!event?.config) {
|
|
163
|
+
logger.warn('Missing config data in support service update');
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
await this.messengerNotificationService.setSupportServiceConfig(event.config);
|
|
167
|
+
logger.debug('Support service config updated successfully');
|
|
168
|
+
// Emit config update event
|
|
169
|
+
this.broker.emit('support.service.config.applied', {
|
|
170
|
+
hasEmail: !!event.config.email,
|
|
171
|
+
hasTemplateId: !!event.config.templateId,
|
|
172
|
+
timestamp: new Date()
|
|
173
|
+
});
|
|
174
|
+
} catch (error) {
|
|
175
|
+
logger.error('Error updating support service config: %o', error);
|
|
176
|
+
this.broker.emit('support.service.config.failed', {
|
|
177
|
+
error: error.message,
|
|
178
|
+
timestamp: new Date()
|
|
179
|
+
});
|
|
180
|
+
throw error;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
/**
|
|
185
|
+
* Handles bulk notification requests
|
|
186
|
+
*
|
|
187
|
+
* @description Processes bulk notification operations
|
|
188
|
+
*/
|
|
189
|
+
'notification.bulk.send': {
|
|
190
|
+
handler: async ctx => {
|
|
191
|
+
const {
|
|
192
|
+
event
|
|
193
|
+
} = ctx?.params || {};
|
|
194
|
+
try {
|
|
195
|
+
logger.debug('Processing bulk notification request', {
|
|
196
|
+
notificationCount: event?.notifications?.length,
|
|
197
|
+
priority: event?.priority
|
|
198
|
+
});
|
|
199
|
+
if (!event?.notifications || event.notifications.length === 0) {
|
|
200
|
+
logger.warn('No notifications provided for bulk send');
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
const results = await Promise.allSettled(event.notifications.map(async notification => {
|
|
204
|
+
switch (notification.type) {
|
|
205
|
+
case 'post':
|
|
206
|
+
case 'alert':
|
|
207
|
+
return await this.messengerNotificationService.sendNotificationOnPost(notification.data);
|
|
208
|
+
case 'expo':
|
|
209
|
+
return await this.messengerNotificationService.sendPushNotificationsExpo(notification.data);
|
|
210
|
+
default:
|
|
211
|
+
throw new Error(`Unknown notification type: ${notification.type}`);
|
|
212
|
+
}
|
|
213
|
+
}));
|
|
214
|
+
const successCount = results.filter(result => result.status === 'fulfilled' && result.value !== false && result.value !== null).length;
|
|
215
|
+
logger.debug('Bulk notification completed', {
|
|
216
|
+
totalNotifications: event.notifications.length,
|
|
217
|
+
successfulSends: successCount,
|
|
218
|
+
priority: event.priority
|
|
219
|
+
});
|
|
220
|
+
// Emit completion event
|
|
221
|
+
this.broker.emit('notification.bulk.completed', {
|
|
222
|
+
totalNotifications: event.notifications.length,
|
|
223
|
+
successfulSends: successCount,
|
|
224
|
+
priority: event.priority,
|
|
225
|
+
timestamp: new Date()
|
|
226
|
+
});
|
|
227
|
+
} catch (error) {
|
|
228
|
+
logger.error('Error processing bulk notifications: %o', error);
|
|
229
|
+
throw error;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
17
232
|
}
|
|
18
233
|
},
|
|
19
|
-
dependencies: [],
|
|
20
234
|
async started() {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
235
|
+
try {
|
|
236
|
+
logger.debug('MessengerNotificationMoleculerService started successfully');
|
|
237
|
+
// Emit service ready event
|
|
238
|
+
this.broker.emit('service.notification.ready', {
|
|
239
|
+
serviceName: MoleculerServiceName.MessengerNotificationService,
|
|
240
|
+
timestamp: new Date()
|
|
241
|
+
});
|
|
242
|
+
} catch (error) {
|
|
243
|
+
logger.error('Error starting MessengerNotificationMoleculerService: %o', error);
|
|
244
|
+
throw error;
|
|
245
|
+
}
|
|
25
246
|
},
|
|
26
247
|
actions: {
|
|
248
|
+
/**
|
|
249
|
+
* Action: Send notification for unread messages
|
|
250
|
+
*/
|
|
27
251
|
[MessengerNotificationServiceCommands.SendNotificationOfUnreadMessages]: {
|
|
28
252
|
params: {
|
|
29
253
|
unit: 'string',
|
|
30
254
|
value: 'number'
|
|
31
255
|
},
|
|
32
|
-
handler
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
256
|
+
handler: async ctx => {
|
|
257
|
+
try {
|
|
258
|
+
const {
|
|
259
|
+
unit,
|
|
260
|
+
value
|
|
261
|
+
} = ctx.params;
|
|
262
|
+
if (!unit || typeof value !== 'number' || value <= 0) {
|
|
263
|
+
throw new Error('Valid time unit and positive value are required');
|
|
264
|
+
}
|
|
265
|
+
return await this.messengerNotificationService.sendNotificationOfUnreadMessages(unit, value);
|
|
266
|
+
} catch (error) {
|
|
267
|
+
logger.error('Error in sendNotificationOfUnreadMessages action: %o', error);
|
|
268
|
+
throw error;
|
|
269
|
+
}
|
|
40
270
|
}
|
|
41
271
|
},
|
|
272
|
+
/**
|
|
273
|
+
* Action: Send notification on post
|
|
274
|
+
*/
|
|
42
275
|
[MessengerNotificationServiceCommands.SendNotificationOnPost]: {
|
|
43
276
|
params: {
|
|
44
277
|
post: 'object'
|
|
45
278
|
},
|
|
46
|
-
handler
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
279
|
+
handler: async ctx => {
|
|
280
|
+
try {
|
|
281
|
+
const {
|
|
282
|
+
post
|
|
283
|
+
} = ctx.params;
|
|
284
|
+
if (!post) {
|
|
285
|
+
throw new Error('Post data is required');
|
|
286
|
+
}
|
|
287
|
+
return await this.messengerNotificationService.sendNotificationOnPost(post);
|
|
288
|
+
} catch (error) {
|
|
289
|
+
logger.error('Error in sendNotificationOnPost action: %o', error);
|
|
290
|
+
throw error;
|
|
291
|
+
}
|
|
53
292
|
}
|
|
54
293
|
},
|
|
294
|
+
/**
|
|
295
|
+
* Action: Send notification for alert messages
|
|
296
|
+
*/
|
|
55
297
|
[MessengerNotificationServiceCommands.SendNotificationOfAlertMessages]: {
|
|
56
298
|
params: {
|
|
57
299
|
unit: 'string',
|
|
58
300
|
value: 'number'
|
|
59
301
|
},
|
|
60
|
-
handler
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
302
|
+
handler: async ctx => {
|
|
303
|
+
try {
|
|
304
|
+
const {
|
|
305
|
+
unit,
|
|
306
|
+
value
|
|
307
|
+
} = ctx.params;
|
|
308
|
+
if (!unit || typeof value !== 'number' || value <= 0) {
|
|
309
|
+
throw new Error('Valid time unit and positive value are required');
|
|
310
|
+
}
|
|
311
|
+
return await this.messengerNotificationService.sendNotificationOfAlertMessages(unit, value);
|
|
312
|
+
} catch (error) {
|
|
313
|
+
logger.error('Error in sendNotificationOfAlertMessages action: %o', error);
|
|
314
|
+
throw error;
|
|
315
|
+
}
|
|
68
316
|
}
|
|
69
317
|
},
|
|
318
|
+
/**
|
|
319
|
+
* Action: Send Expo push notifications
|
|
320
|
+
*/
|
|
70
321
|
[MessengerNotificationServiceCommands.SendPushNotificationsExpo]: {
|
|
71
322
|
params: {
|
|
72
323
|
data: 'object'
|
|
73
324
|
},
|
|
74
|
-
handler
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
325
|
+
handler: async ctx => {
|
|
326
|
+
try {
|
|
327
|
+
const {
|
|
328
|
+
data
|
|
329
|
+
} = ctx.params;
|
|
330
|
+
if (!data) {
|
|
331
|
+
throw new Error('Notification data is required');
|
|
332
|
+
}
|
|
333
|
+
return await this.messengerNotificationService.sendPushNotificationsExpo(data);
|
|
334
|
+
} catch (error) {
|
|
335
|
+
logger.error('Error in sendPushNotificationsExpo action: %o', error);
|
|
336
|
+
throw error;
|
|
337
|
+
}
|
|
81
338
|
}
|
|
82
339
|
},
|
|
340
|
+
/**
|
|
341
|
+
* Action: Send Expo notification on post
|
|
342
|
+
*/
|
|
83
343
|
[MessengerNotificationServiceCommands.SendExpoNotificationOnPost]: {
|
|
84
344
|
params: {
|
|
85
345
|
post: 'object',
|
|
86
346
|
notificationData: 'object'
|
|
87
347
|
},
|
|
88
|
-
handler
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
348
|
+
handler: async ctx => {
|
|
349
|
+
try {
|
|
350
|
+
const {
|
|
351
|
+
post,
|
|
352
|
+
notificationData
|
|
353
|
+
} = ctx.params;
|
|
354
|
+
if (!post) {
|
|
355
|
+
throw new Error('Post data is required');
|
|
356
|
+
}
|
|
357
|
+
return await this.messengerNotificationService.sendExpoNotificationOnPost(post, notificationData);
|
|
358
|
+
} catch (error) {
|
|
359
|
+
logger.error('Error in sendExpoNotificationOnPost action: %o', error);
|
|
360
|
+
throw error;
|
|
361
|
+
}
|
|
96
362
|
}
|
|
97
363
|
},
|
|
364
|
+
/**
|
|
365
|
+
* Action: Send notification for unread service messages
|
|
366
|
+
*/
|
|
98
367
|
[MessengerNotificationServiceCommands.SendNotificationOfUnreadServiceMessages]: {
|
|
99
368
|
params: {
|
|
100
369
|
unit: 'string',
|
|
101
370
|
value: 'number'
|
|
102
371
|
},
|
|
103
|
-
handler
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
372
|
+
handler: async ctx => {
|
|
373
|
+
try {
|
|
374
|
+
const {
|
|
375
|
+
unit,
|
|
376
|
+
value
|
|
377
|
+
} = ctx.params;
|
|
378
|
+
if (!unit || typeof value !== 'number' || value <= 0) {
|
|
379
|
+
throw new Error('Valid time unit and positive value are required');
|
|
380
|
+
}
|
|
381
|
+
return await this.messengerNotificationService.sendNotificationOfUnreadServiceMessages(unit, value);
|
|
382
|
+
} catch (error) {
|
|
383
|
+
logger.error('Error in sendNotificationOfUnreadServiceMessages action: %o', error);
|
|
384
|
+
throw error;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
},
|
|
388
|
+
/**
|
|
389
|
+
* Action: Set support service configuration
|
|
390
|
+
*/
|
|
391
|
+
setSupportServiceConfig: {
|
|
392
|
+
params: {
|
|
393
|
+
config: 'object'
|
|
394
|
+
},
|
|
395
|
+
handler: async ctx => {
|
|
396
|
+
try {
|
|
397
|
+
const {
|
|
398
|
+
config
|
|
399
|
+
} = ctx.params;
|
|
400
|
+
if (!config) {
|
|
401
|
+
throw new Error('Support service configuration is required');
|
|
402
|
+
}
|
|
403
|
+
return await this.messengerNotificationService.setSupportServiceConfig(config);
|
|
404
|
+
} catch (error) {
|
|
405
|
+
logger.error('Error in setSupportServiceConfig action: %o', error);
|
|
406
|
+
throw error;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
},
|
|
410
|
+
/**
|
|
411
|
+
* Action: Get notification statistics
|
|
412
|
+
*/
|
|
413
|
+
getNotificationStats: {
|
|
414
|
+
handler: async () => {
|
|
415
|
+
try {
|
|
416
|
+
// This would be implemented to return notification statistics
|
|
417
|
+
return {
|
|
418
|
+
totalSent: 0,
|
|
419
|
+
totalFailed: 0,
|
|
420
|
+
emailsSent: 0,
|
|
421
|
+
smsSent: 0,
|
|
422
|
+
pushNotificationsSent: 0,
|
|
423
|
+
lastProcessed: new Date()
|
|
424
|
+
};
|
|
425
|
+
} catch (error) {
|
|
426
|
+
logger.error('Error getting notification stats: %o', error);
|
|
427
|
+
throw error;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
},
|
|
431
|
+
/**
|
|
432
|
+
* Action: Health check for the service
|
|
433
|
+
*/
|
|
434
|
+
health: {
|
|
435
|
+
handler: async () => {
|
|
436
|
+
try {
|
|
437
|
+
return {
|
|
438
|
+
status: 'healthy',
|
|
439
|
+
timestamp: new Date(),
|
|
440
|
+
service: 'MessengerNotificationMoleculerService',
|
|
441
|
+
version: '1.0.0',
|
|
442
|
+
dependencies: {
|
|
443
|
+
mailService: 'connected',
|
|
444
|
+
smsService: 'connected',
|
|
445
|
+
accountService: 'connected'
|
|
446
|
+
}
|
|
447
|
+
};
|
|
448
|
+
} catch (error) {
|
|
449
|
+
logger.error('Health check failed: %o', error);
|
|
450
|
+
return {
|
|
451
|
+
status: 'unhealthy',
|
|
452
|
+
timestamp: new Date(),
|
|
453
|
+
service: 'MessengerNotificationMoleculerService',
|
|
454
|
+
error: error.message
|
|
455
|
+
};
|
|
456
|
+
}
|
|
111
457
|
}
|
|
112
458
|
}
|
|
113
459
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messenger-notification-moleculer-service.js","sources":["../../src/plugins/messenger-notification-moleculer-service.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"messenger-notification-moleculer-service.js","sources":["../../src/plugins/messenger-notification-moleculer-service.ts"],"sourcesContent":[null],"names":[],"mappings":"+RAsBA;;;;;;;;;;;;;;;;;;;;;;AAsBG;AACG,MAAO,qCAAsC,SAAQ,OAAO,CAAA;AAC7C,EAAA,4BA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AAA;;qBAEP;AACJ,gBAAA,SAAA,EAAA,CAAA;AAED,gBAAA,WAAA,EAAA,CAAA;;AAEG,gBAAA,OAAA,EAAA,CAAA;AACH,gBAAA,qBAAQ,EAAA,CAAA;6BACK,EAAK,IAAA,IAAM;AAChB,eAAA;4BACI;AACI,cAAA,MAAA,CAAA,KAAA,CAAA,sCAAiB,EAAA,KAAA,CAAA;;AAEjB;AACA;AACA,SAAA;AACI;AACA;AACA;AACH,QAAA,MAAA,EAAA;+BACH;;;AAEF,gBAAA,MAAA,EAAA,SAAA;+BACO,IAAA,EAAA;AACH,gBAAA,OAAA,EAAA,uCAAmB;gCACnB;AACA,gBAAA,YAAA,EAAA;0CACY;8BACd,WAAA;gCACL,EAAA;;AAER,eAAA;AACJ,aAAA,CAAA,OAAA,KAAA,EAAA;AACJ,cAAE,MAAA,CAAA,KAAA,CAAA,yBAAA,EAAA,KAAA,CAAA;cACN,OAAA;AA0CJ,gBAAA,MAAA,EAAA,WAAA;;;;;;;;;;;"}
|
|
@@ -1,34 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Post Moleculer Service
|
|
3
|
+
* ----------------------
|
|
4
|
+
*
|
|
5
|
+
* This Moleculer service provides comprehensive post management capabilities within
|
|
6
|
+
* the messenger platform ecosystem. It acts as a distributed service layer for
|
|
7
|
+
* handling post creation, file attachments, message threading, real-time notifications,
|
|
8
|
+
* and cross-service communication.
|
|
9
|
+
*
|
|
10
|
+
* Key capabilities:
|
|
11
|
+
* - Post lifecycle management with threading support
|
|
12
|
+
* - File attachment and upload link generation
|
|
13
|
+
* - Real-time message delivery and read receipts
|
|
14
|
+
* - Post thread creation and management
|
|
15
|
+
* - Channel integration and message counting
|
|
16
|
+
* - Event-driven architecture for real-time updates
|
|
17
|
+
* - Distributed service communication via Moleculer
|
|
18
|
+
* - Comprehensive error handling and logging
|
|
19
|
+
*
|
|
20
|
+
* The service integrates with multiple platform components including channels,
|
|
21
|
+
* notifications, file management, and real-time publishing systems to provide
|
|
22
|
+
* a cohesive messaging experience across the platform.
|
|
23
|
+
*/
|
|
1
24
|
import { Service, ServiceBroker } from 'moleculer';
|
|
2
|
-
import { IPost, IPostThread, CreatePostThreadOptions } from 'common';
|
|
25
|
+
import { IPost, IPostThread, CreatePostThreadOptions } from 'common/server';
|
|
3
26
|
import { Container } from 'inversify';
|
|
27
|
+
/**
|
|
28
|
+
* PostMoleculerService Class
|
|
29
|
+
*
|
|
30
|
+
* Comprehensive Moleculer service for distributed post management operations.
|
|
31
|
+
* Provides event-driven architecture, real-time communication, and seamless
|
|
32
|
+
* integration with other platform services.
|
|
33
|
+
*/
|
|
4
34
|
export declare class PostMoleculerService extends Service {
|
|
5
35
|
private readonly postService;
|
|
6
|
-
|
|
36
|
+
private readonly container;
|
|
37
|
+
constructor(broker: ServiceBroker, { container, settings }: {
|
|
7
38
|
container: Container;
|
|
39
|
+
settings?: any;
|
|
8
40
|
});
|
|
41
|
+
/**
|
|
42
|
+
* Handles post thread creation logic
|
|
43
|
+
*
|
|
44
|
+
* @description Creates or updates post threads with proper participant management
|
|
45
|
+
*
|
|
46
|
+
* @param {Object} params - Post thread creation parameters
|
|
47
|
+
* @returns {Promise<IPostThread>} - Created or updated post thread
|
|
48
|
+
*/
|
|
9
49
|
handlePostThreadCreate({ post, responderId, accountId, threadMessageInput, orgId, postThreadId, }: Omit<CreatePostThreadOptions, 'channelId' | 'postParentId'> & {
|
|
10
50
|
post: IPost;
|
|
11
|
-
postThreadId
|
|
51
|
+
postThreadId?: IPostThread;
|
|
12
52
|
}): Promise<IPostThread>;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
53
|
+
/**
|
|
54
|
+
* Retrieves a post thread by criteria
|
|
55
|
+
*
|
|
56
|
+
* @description Finds existing post threads based on various criteria
|
|
57
|
+
*
|
|
58
|
+
* @param {Object} params - Search criteria
|
|
59
|
+
* @returns {Promise<IPostThread>} - Found post thread
|
|
60
|
+
*/
|
|
61
|
+
getPostThread({ postThreadId, channelId, postParentId, accountId, role, orgId, }: {
|
|
62
|
+
postThreadId?: IPostThread;
|
|
63
|
+
channelId?: string;
|
|
64
|
+
postParentId?: string;
|
|
65
|
+
accountId?: string;
|
|
66
|
+
role?: string;
|
|
67
|
+
orgId?: string;
|
|
20
68
|
}): Promise<IPostThread>;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
69
|
+
/**
|
|
70
|
+
* Dispatches post events with parent ID for thread updates
|
|
71
|
+
*
|
|
72
|
+
* @description Handles event dispatching for post thread updates
|
|
73
|
+
*
|
|
74
|
+
* @param {Object} params - Event parameters
|
|
75
|
+
* @returns {Promise<IPostThread>} - Updated post thread
|
|
76
|
+
*/
|
|
77
|
+
dispatchPostEventsWithParentId({ post, postThread, accountId, orgId, role, }: {
|
|
78
|
+
post: IPost;
|
|
79
|
+
postThread: IPostThread;
|
|
80
|
+
accountId: string;
|
|
81
|
+
orgId: string;
|
|
82
|
+
role: string;
|
|
27
83
|
}): Promise<IPostThread>;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
84
|
+
/**
|
|
85
|
+
* Creates a new post thread
|
|
86
|
+
*
|
|
87
|
+
* @description Creates a new thread for organizing related posts
|
|
88
|
+
*
|
|
89
|
+
* @param {Object} params - Thread creation parameters
|
|
90
|
+
* @returns {Promise<IPostThread>} - Created post thread
|
|
91
|
+
*/
|
|
92
|
+
createPostThread({ channelId, postParentId, post, participants, }: {
|
|
93
|
+
channelId: string;
|
|
94
|
+
postParentId: string;
|
|
95
|
+
post: IPost;
|
|
96
|
+
participants: any[];
|
|
33
97
|
}): Promise<IPostThread>;
|
|
34
98
|
}
|