const _ = require('lodash');
const { apiResponse } = require("../../core/response/response")
const { SUCCESS, REDIRECTION, CLIENT_ERROR, SERVER_ERROR } = require("../../core/response/statusCode")
const { ERROR_MSG, SUCCESS_MSG } = require("../../core/response/messages")
const { Notification } = require("../../models/notification")
export { };
exports.addNotification = async (schema, req,res) => {
    const lang = req.headers["accept-language"] || 'en'
    try {
        new Notification(_.pick(schema, ['subject', 'user_id', 'notify_en','notify_fr','notify_ar', 'booking_id'])).save()
            .then(async function (data) {
               
                return true
            })
            .catch(function (err) {
                return apiResponse(res, true, [], ERROR_MSG[`SYSTEM-ERROR-${lang}`], SERVER_ERROR.internalServerError, 0, [], req)
            });

    } catch (error) {
        return apiResponse(res, true, [], ERROR_MSG['SYSTEM-ERROR'], SERVER_ERROR.internalServerError, 0, [])
    }
}