Move notifications interfaces in UserNotifications class
MODIFY
src/notification/NotificationHandler.ts
src/notification/NotificationHandler.ts
import User, { UserRole } from '../types/User';
-import UserNotifications, { AccountVerificationNotification, BillingInvoiceSynchronizationFailedNotification, BillingNewInvoiceNotification, BillingUserSynchronizationFailedNotification, CarCatalogSynchronizationFailedNotification, ChargingStationRegisteredNotification, ChargingStationStatusErrorNotification, ComputeAndApplyChargingProfilesFailedNotification, EndOfChargeNotification, EndOfSessionNotification, EndOfSignedSessionNotification, EndUserErrorNotification, NewRegisteredUserNotification, Notification, NotificationSeverity, NotificationSource, OCPIPatchChargingStationsStatusesErrorNotification, OfflineChargingStationNotification, OptimalChargeReachedNotification, PreparingSessionNotStartedNotification, RequestPasswordNotification, SessionNotStartedNotification, SmtpErrorNotification, TransactionStartedNotification, UnknownUserBadgedNotification, UserAccountInactivityNotification, UserAccountStatusChangedNotification, UserNotificationKeys, VerificationEmailNotification } from '../types/UserNotifications';
+import UserNotifications, { AccountVerificationNotification, AdminAccountVerificationNotification, BillingInvoiceSynchronizationFailedNotification, BillingNewInvoiceNotification, BillingUserSynchronizationFailedNotification, CarCatalogSynchronizationFailedNotification, ChargingStationRegisteredNotification, ChargingStationStatusErrorNotification, ComputeAndApplyChargingProfilesFailedNotification, EndOfChargeNotification, EndOfSessionNotification, EndOfSignedSessionNotification, EndUserErrorNotification, NewRegisteredUserNotification, Notification, NotificationSeverity, NotificationSource, OCPIPatchChargingStationsStatusesErrorNotification, OfflineChargingStationNotification, OptimalChargeReachedNotification, PreparingSessionNotStartedNotification, RequestPasswordNotification, SessionNotStartedNotification, SmtpErrorNotification, TransactionStartedNotification, UnknownUserBadgedNotification, UserAccountInactivityNotification, UserAccountStatusChangedNotification, UserNotificationKeys, VerificationEmailNotification } from '../types/UserNotifications';
-import { AdminAccountVerificationNotification } from '../types/Notification';
import ChargingStation from '../types/ChargingStation';
import Configuration from '../utils/Configuration';
import Constants from '../utils/Constants';

MODIFY
src/notification/NotificationTask.ts
src/notification/NotificationTask.ts
-import { AccountVerificationNotification, BillingInvoiceSynchronizationFailedNotification, BillingNewInvoiceNotification, BillingUserSynchronizationFailedNotification, CarCatalogSynchronizationFailedNotification, ChargingStationRegisteredNotification, ChargingStationStatusErrorNotification, ComputeAndApplyChargingProfilesFailedNotification, EndOfChargeNotification, EndOfSessionNotification, EndOfSignedSessionNotification, EndUserErrorNotification, NewRegisteredUserNotification, NotificationSeverity, OCPIPatchChargingStationsStatusesErrorNotification, OfflineChargingStationNotification, OptimalChargeReachedNotification, PreparingSessionNotStartedNotification, RequestPasswordNotification, SessionNotStartedNotification, SmtpErrorNotification, TransactionStartedNotification, UnknownUserBadgedNotification, UserAccountInactivityNotification, UserAccountStatusChangedNotification, VerificationEmailNotification } from '../types/UserNotifications';
+import { AccountVerificationNotification, AdminAccountVerificationNotification, BillingInvoiceSynchronizationFailedNotification, BillingNewInvoiceNotification, BillingUserSynchronizationFailedNotification, CarCatalogSynchronizationFailedNotification, ChargingStationRegisteredNotification, ChargingStationStatusErrorNotification, ComputeAndApplyChargingProfilesFailedNotification, EndOfChargeNotification, EndOfSessionNotification, EndOfSignedSessionNotification, EndUserErrorNotification, NewRegisteredUserNotification, NotificationSeverity, OCPIPatchChargingStationsStatusesErrorNotification, OfflineChargingStationNotification, OptimalChargeReachedNotification, PreparingSessionNotStartedNotification, RequestPasswordNotification, SessionNotStartedNotification, SmtpErrorNotification, TransactionStartedNotification, UnknownUserBadgedNotification, UserAccountInactivityNotification, UserAccountStatusChangedNotification, VerificationEmailNotification } from '../types/UserNotifications';
-import { AdminAccountVerificationNotification } from '../types/Notification';
import Tenant from '../types/Tenant';
import User from '../types/User';

MODIFY
src/notification/email/EMailNotificationTask.ts
src/notification/email/EMailNotificationTask.ts
-import { AccountVerificationNotification, BillingInvoiceSynchronizationFailedNotification, BillingNewInvoiceNotification, BillingUserSynchronizationFailedNotification, CarCatalogSynchronizationFailedNotification, ChargingStationRegisteredNotification, ChargingStationStatusErrorNotification, ComputeAndApplyChargingProfilesFailedNotification, EmailNotificationMessage, EndOfChargeNotification, EndOfSessionNotification, EndOfSignedSessionNotification, EndUserErrorNotification, NewRegisteredUserNotification, NotificationSeverity, OCPIPatchChargingStationsStatusesErrorNotification, OfflineChargingStationNotification, OptimalChargeReachedNotification, PreparingSessionNotStartedNotification, RequestPasswordNotification, SessionNotStartedNotification, SmtpErrorNotification, TransactionStartedNotification, UnknownUserBadgedNotification, UserAccountInactivityNotification, UserAccountStatusChangedNotification, VerificationEmailNotification } from '../../types/UserNotifications';
+import { AccountVerificationNotification, AdminAccountVerificationNotification, BillingInvoiceSynchronizationFailedNotification, BillingNewInvoiceNotification, BillingUserSynchronizationFailedNotification, CarCatalogSynchronizationFailedNotification, ChargingStationRegisteredNotification, ChargingStationStatusErrorNotification, ComputeAndApplyChargingProfilesFailedNotification, EmailNotificationMessage, EndOfChargeNotification, EndOfSessionNotification, EndOfSignedSessionNotification, EndUserErrorNotification, NewRegisteredUserNotification, NotificationSeverity, OCPIPatchChargingStationsStatusesErrorNotification, OfflineChargingStationNotification, OptimalChargeReachedNotification, PreparingSessionNotStartedNotification, RequestPasswordNotification, SessionNotStartedNotification, SmtpErrorNotification, TransactionStartedNotification, UnknownUserBadgedNotification, UserAccountInactivityNotification, UserAccountStatusChangedNotification, VerificationEmailNotification } from '../../types/UserNotifications';
import { Message, SMTPClient, SMTPError } from 'emailjs';
-import { AdminAccountVerificationNotification } from '../../types/Notification';
import BackendError from '../../exception/BackendError';
import Configuration from '../../utils/Configuration';
import Constants from '../../utils/Constants';
@@ -157,7 +156,7 @@ export default class EMailNotificationTask implements NotificationTask {
// Email configuration sanity checks
if (!this.smtpMainClientInstance) {
// No suitable main SMTP server configuration found to send the email
- Logging.logError({
+ await Logging.logError({
tenantID: tenant.id,
source: Utils.objectHasProperty(data, 'chargeBoxID') && data.chargeBoxID,
action: ServerAction.EMAIL_NOTIFICATION,
@@ -169,7 +168,7 @@ export default class EMailNotificationTask implements NotificationTask {
}
if (useSmtpClientBackup && !this.smtpBackupClientInstance) {
// No suitable backup SMTP server configuration found or activated to send the email
- Logging.logError({
+ await Logging.logError({
tenantID: tenant.id,
source: Utils.objectHasProperty(data, 'chargeBoxID') && data.chargeBoxID,
action: ServerAction.EMAIL_NOTIFICATION,
@@ -197,7 +196,7 @@ export default class EMailNotificationTask implements NotificationTask {
// Send the message
const messageSent: Message = await smtpClient.sendAsync(messageToSend);
// Email sent successfully
- Logging.logDebug({
+ await Logging.logDebug({
tenantID: tenant.id ? tenant.id : Constants.DEFAULT_TENANT,
source: Utils.objectHasProperty(data, 'chargeBoxID') && data.chargeBoxID,
action: ServerAction.EMAIL_NOTIFICATION,
@@ -219,7 +218,7 @@ export default class EMailNotificationTask implements NotificationTask {
} catch (error) {
// Log
try {
- Logging.logError({
+ await Logging.logError({
tenantID: tenant.id ? tenant.id : Constants.DEFAULT_TENANT,
source: Utils.objectHasProperty(data, 'chargeBoxID') && data.chargeBoxID,
action: ServerAction.EMAIL_NOTIFICATION,
@@ -391,7 +390,7 @@ export default class EMailNotificationTask implements NotificationTask {
html: html
}, data, tenant, user, severity, useSmtpClientBackup);
} catch (error) {
- Logging.logError({
+ await Logging.logError({
tenantID: tenant.id,
source: Utils.objectHasProperty(data, 'chargeBoxID') && data.chargeBoxID,
action: ServerAction.EMAIL_NOTIFICATION,

MODIFY
src/storage/mongodb/TransactionStorage.ts
src/storage/mongodb/TransactionStorage.ts
@@ -9,7 +9,7 @@ import { DataResult } from '../../types/DataResult';
import DatabaseUtils from './DatabaseUtils';
import DbParams from '../../types/database/DbParams';
import Logging from '../../utils/Logging';
-import { NotifySessionNotStarted } from '../../types/Notification';
+import { NotifySessionNotStarted } from '../../types/UserNotifications';
import { ServerAction } from '../../types/Server';
import Utils from '../../utils/Utils';
import moment from 'moment';

DELETE
src/types/Notification.ts
-import ChargingStation from './ChargingStation';
-import User from './User';
-
-export interface NotifySessionNotStarted {
- chargingStation: ChargingStation;
- tagID: string;
- authDate: Date;
- user: User;
-}
-export interface AdminAccountVerificationNotification {
- user: User;
- evseDashboardURL: string;
- evseUserToVerifyURL: string;
- tenantLogoURL: string;
-}

MODIFY
src/types/UserNotifications.ts
src/types/UserNotifications.ts
import User, { UserStatus } from './User';
import { BillingInvoice } from './Billing';
+import ChargingStation from './ChargingStation';
import NotificationTask from '../notification/NotificationTask';
import { SMTPError } from 'emailjs';
@@ -306,3 +307,16 @@ export interface AccountVerificationNotification extends BaseNotification {
userStatus: UserStatus;
evseDashboardURL: string;
}
+
+export interface NotifySessionNotStarted extends BaseNotification {
+ chargingStation: ChargingStation;
+ tagID: string;
+ authDate: Date;
+ user: User;
+}
+
+export interface AdminAccountVerificationNotification extends BaseNotification {
+ user: User;
+ evseDashboardURL: string;
+ evseUserToVerifyURL: string;
+}

Move notifications interfaces in UserNotifications class