rez_core 2.2.215 → 2.2.216
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/module/communication/controller/wrapper.controller.d.ts +1 -1
- package/dist/module/communication/service/wrapper.service.d.ts +1 -1
- package/dist/module/communication/service/wrapper.service.js +39 -5
- package/dist/module/communication/service/wrapper.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/communication/service/wrapper.service.ts +67 -12
package/package.json
CHANGED
|
@@ -38,6 +38,7 @@ export class WrapperService {
|
|
|
38
38
|
FROM cr_communication_hub
|
|
39
39
|
WHERE level_id = ?
|
|
40
40
|
AND level_type = ?
|
|
41
|
+
AND status = 1
|
|
41
42
|
AND communication_config_type = 'EMAIL'`,
|
|
42
43
|
[level_id, level_type],
|
|
43
44
|
);
|
|
@@ -80,7 +81,7 @@ export class WrapperService {
|
|
|
80
81
|
cc: payload.cc,
|
|
81
82
|
bcc: payload.bcc,
|
|
82
83
|
html: payload.html,
|
|
83
|
-
attachments: payload.attachments,
|
|
84
|
+
// attachments: payload.attachments,
|
|
84
85
|
// templateId: templateCode,
|
|
85
86
|
variables: payload.variables,
|
|
86
87
|
};
|
|
@@ -112,7 +113,7 @@ export class WrapperService {
|
|
|
112
113
|
cc: payload.cc,
|
|
113
114
|
bcc: payload.bcc,
|
|
114
115
|
html: payload.html,
|
|
115
|
-
attachments: payload.attachments,
|
|
116
|
+
// attachments: payload.attachments,
|
|
116
117
|
// templateId: payload.templateId,
|
|
117
118
|
variables: payload.variables,
|
|
118
119
|
};
|
|
@@ -152,7 +153,7 @@ export class WrapperService {
|
|
|
152
153
|
`scheduleMeetingWrapper called by user=${loggedInUser?.id || 'unknown'} Payload=${JSON.stringify(payload)}`,
|
|
153
154
|
);
|
|
154
155
|
|
|
155
|
-
const { level_id, level_type } = loggedInUser;
|
|
156
|
+
const { level_id, level_type, organization_id } = loggedInUser;
|
|
156
157
|
|
|
157
158
|
// Normalize emails (to, cc, bcc → attendees)
|
|
158
159
|
const cleanEmails = (arr: string[] = []) =>
|
|
@@ -179,12 +180,13 @@ export class WrapperService {
|
|
|
179
180
|
),
|
|
180
181
|
];
|
|
181
182
|
|
|
182
|
-
//
|
|
183
|
+
// ---- Step 1: Check user-level configs ----
|
|
183
184
|
const userConfigs = await this.datasource.query(
|
|
184
185
|
`SELECT *
|
|
185
186
|
FROM cr_communication_hub
|
|
186
187
|
WHERE level_id = ?
|
|
187
188
|
AND level_type = ?
|
|
189
|
+
AND status = 1
|
|
188
190
|
AND communication_config_type = 'EMAIL'
|
|
189
191
|
AND service = 'API'`,
|
|
190
192
|
[level_id, level_type],
|
|
@@ -197,7 +199,7 @@ export class WrapperService {
|
|
|
197
199
|
const configId = userConfigs[0]?.config_id;
|
|
198
200
|
|
|
199
201
|
if (provider === 'gmail') {
|
|
200
|
-
this.logger.log(`Using Google Calendar
|
|
202
|
+
this.logger.log(`Using Google Calendar (user-level)`);
|
|
201
203
|
const creds = await this.getConfigCred(configId);
|
|
202
204
|
|
|
203
205
|
if (creds) {
|
|
@@ -211,26 +213,79 @@ export class WrapperService {
|
|
|
211
213
|
}
|
|
212
214
|
|
|
213
215
|
const result = await this.googleService.createEvent(creds, payload);
|
|
214
|
-
|
|
215
216
|
this.logger.log(
|
|
216
|
-
`scheduleMeetingWrapper SUCCESS. Result: ${JSON.stringify(
|
|
217
|
-
result,
|
|
218
|
-
)}`,
|
|
217
|
+
`scheduleMeetingWrapper SUCCESS (user-level). Result: ${JSON.stringify(result)}`,
|
|
219
218
|
);
|
|
220
219
|
|
|
221
220
|
return { success: true, data: result };
|
|
222
221
|
}
|
|
223
222
|
}
|
|
224
223
|
|
|
225
|
-
// Non-Gmail fallback
|
|
224
|
+
// Non-Gmail user-level fallback
|
|
226
225
|
return {
|
|
227
226
|
success: true,
|
|
228
227
|
data: await this.sendIcsFallback(payload, level_id, level_type),
|
|
229
228
|
};
|
|
230
229
|
}
|
|
231
230
|
|
|
232
|
-
// ORG-level configs
|
|
233
|
-
|
|
231
|
+
// ---- Step 2: Check ORG-level configs ----
|
|
232
|
+
this.logger.log(`No user-level config found, checking ORG-level...`);
|
|
233
|
+
|
|
234
|
+
const orgConfigs = await this.datasource.query(
|
|
235
|
+
`SELECT *
|
|
236
|
+
FROM cr_communication_hub
|
|
237
|
+
WHERE level_id = 1
|
|
238
|
+
AND level_type = 'ORG'
|
|
239
|
+
AND communication_config_type = 'EMAIL'
|
|
240
|
+
AND service = 'API'`,
|
|
241
|
+
[],
|
|
242
|
+
);
|
|
243
|
+
|
|
244
|
+
this.logger.debug(`ORG configs found: ${JSON.stringify(orgConfigs)}`);
|
|
245
|
+
|
|
246
|
+
if (orgConfigs && orgConfigs.length > 0) {
|
|
247
|
+
const provider = orgConfigs[0]?.provider;
|
|
248
|
+
const configId = orgConfigs[0]?.config_id;
|
|
249
|
+
|
|
250
|
+
if (provider === 'gmail') {
|
|
251
|
+
this.logger.log(`Using Google Calendar (ORG-level)`);
|
|
252
|
+
const creds = await this.getConfigCred(configId);
|
|
253
|
+
|
|
254
|
+
if (creds) {
|
|
255
|
+
if (payload.eventId) {
|
|
256
|
+
const result = await this.googleService.updateEvent(
|
|
257
|
+
creds,
|
|
258
|
+
payload.eventId,
|
|
259
|
+
payload,
|
|
260
|
+
);
|
|
261
|
+
return { success: true, data: result };
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
const result = await this.googleService.createEvent(creds, payload);
|
|
265
|
+
this.logger.log(
|
|
266
|
+
`scheduleMeetingWrapper SUCCESS (ORG-level). Result: ${JSON.stringify(result)}`,
|
|
267
|
+
);
|
|
268
|
+
|
|
269
|
+
return { success: true, data: result };
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// Non-Gmail ORG-level fallback
|
|
274
|
+
return {
|
|
275
|
+
success: true,
|
|
276
|
+
data: await this.sendIcsFallback(payload, 1, 'ORG'),
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// ---- Step 3: Absolute fallback (no configs at all) ----
|
|
281
|
+
this.logger.warn(
|
|
282
|
+
`No user-level or ORG-level configs found, sending fallback ICS email.`,
|
|
283
|
+
);
|
|
284
|
+
|
|
285
|
+
return {
|
|
286
|
+
success: true,
|
|
287
|
+
data: await this.sendIcsFallback(payload, level_id, level_type),
|
|
288
|
+
};
|
|
234
289
|
} catch (error: any) {
|
|
235
290
|
this.logger.error(
|
|
236
291
|
`scheduleMeetingWrapper ERROR: ${error.message}`,
|