dt-common-device 7.6.4 → 7.6.5
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.
|
@@ -71,7 +71,7 @@ export declare class AlertService {
|
|
|
71
71
|
/**
|
|
72
72
|
* Deactivate an alert with business logic
|
|
73
73
|
*/
|
|
74
|
-
deactivateAlert(
|
|
74
|
+
deactivateAlert(query: IAlertQuery, updatedBy: string): Promise<IAlertDocument | null>;
|
|
75
75
|
/**
|
|
76
76
|
* Snooze an alert with business logic
|
|
77
77
|
*/
|
|
@@ -483,15 +483,20 @@ let AlertService = (() => {
|
|
|
483
483
|
/**
|
|
484
484
|
* Deactivate an alert with business logic
|
|
485
485
|
*/
|
|
486
|
-
async deactivateAlert(
|
|
487
|
-
if (!
|
|
488
|
-
throw new Error("Alert
|
|
486
|
+
async deactivateAlert(query, updatedBy) {
|
|
487
|
+
if (!query || !updatedBy)
|
|
488
|
+
throw new Error("Alert query and updated by user are required");
|
|
489
|
+
const alerts = await this.queryAlerts(query);
|
|
490
|
+
if (!alerts.length)
|
|
491
|
+
return null;
|
|
492
|
+
if (alerts.length > 1) {
|
|
493
|
+
throw new Error("Multiple alerts found, please specify a more specific query");
|
|
489
494
|
}
|
|
490
|
-
const
|
|
491
|
-
if (!
|
|
495
|
+
const alert = await Alert_model_1.AlertModel.findById(alerts[0]._id);
|
|
496
|
+
if (!alert)
|
|
492
497
|
return null;
|
|
493
|
-
|
|
494
|
-
return await
|
|
498
|
+
alert.deactivate(updatedBy);
|
|
499
|
+
return await alert.save();
|
|
495
500
|
}
|
|
496
501
|
/**
|
|
497
502
|
* Snooze an alert with business logic
|