repair: notification error log created_by
This commit is contained in:
@@ -7,6 +7,7 @@ const {
|
||||
deleteNotificationErrorLogDb
|
||||
} = require('../db/notification_error_log.db');
|
||||
|
||||
const { getUserByIdDb } = require('../db/user.db');
|
||||
const { ErrorHandler } = require('../helpers/error');
|
||||
|
||||
class NotificationErrorLogService {
|
||||
@@ -40,15 +41,34 @@ class NotificationErrorLogService {
|
||||
}
|
||||
|
||||
// Create Notification Error Log
|
||||
static async createNotificationErrorLog(data) {
|
||||
static async createNotificationErrorLog(data, userId) {
|
||||
try {
|
||||
if (!data || typeof data !== 'object') data = {};
|
||||
|
||||
let createdBy = null;
|
||||
let contactPhone = data.contact_phone || null;
|
||||
|
||||
if (userId) {
|
||||
try {
|
||||
const user = await getUserByIdDb(userId);
|
||||
|
||||
if (user && user.user_id) {
|
||||
createdBy = Number(user.user_id);
|
||||
} else {
|
||||
createdBy = null;
|
||||
contactPhone = userId;
|
||||
}
|
||||
} catch (dbError) {
|
||||
createdBy = null;
|
||||
contactPhone = userId;
|
||||
}
|
||||
}
|
||||
|
||||
const store = {
|
||||
notification_error_id: data.notification_error_id,
|
||||
contact_phone: data.contact_phone,
|
||||
contact_phone: contactPhone,
|
||||
notification_error_log_description: data.notification_error_log_description,
|
||||
created_by: data.created_by
|
||||
created_by: createdBy
|
||||
};
|
||||
|
||||
const result = await createNotificationErrorLogDb(store);
|
||||
|
||||
Reference in New Issue
Block a user