'use strict';

const generateControllers = require('../../core/controllers');
const commentService = require('./comment.service');
const { buildContext } = require('../../core/controllers');

// Module Name
const MODULE_NAME = '[comment.controller]';

const controllerOptions = { MODULE_NAME };
const extraControllers = {
    deleteCommentsByUser: async (req, res, next) => {
        const context = {};

        try {
            const user = {
                id: req.body.id,
                phone: req.body.phone,
                email: req.body.email,
            };

            await commentService.delete({
                query: {
                    userId: user.id
                }
            }, context);

            next();
        } catch (error) {
            console.error(error);
        }
    }
};

module.exports = generateControllers(commentService, extraControllers, controllerOptions);

