"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.markAsReadUserNotificationsValidator = exports.updateNotificationSettingsValidator = exports.listUserNotificationsValidator = void 0;
const express_validator_1 = require("express-validator");
const misc_1 = require("../../helpers/custom-validators/misc");
const user_notifications_1 = require("../../helpers/custom-validators/user-notifications");
const shared_1 = require("./shared");
const listUserNotificationsValidator = [
    (0, express_validator_1.query)('unread')
        .optional()
        .customSanitizer(misc_1.toBooleanOrNull)
        .isBoolean().withMessage('Should have a valid unread boolean'),
    (req, res, next) => {
        if ((0, shared_1.areValidationErrors)(req, res))
            return;
        return next();
    }
];
exports.listUserNotificationsValidator = listUserNotificationsValidator;
const updateNotificationSettingsValidator = [
    (0, express_validator_1.body)('newVideoFromSubscription')
        .custom(user_notifications_1.isUserNotificationSettingValid),
    (0, express_validator_1.body)('newCommentOnMyVideo')
        .custom(user_notifications_1.isUserNotificationSettingValid),
    (0, express_validator_1.body)('abuseAsModerator')
        .custom(user_notifications_1.isUserNotificationSettingValid),
    (0, express_validator_1.body)('videoAutoBlacklistAsModerator')
        .custom(user_notifications_1.isUserNotificationSettingValid),
    (0, express_validator_1.body)('blacklistOnMyVideo')
        .custom(user_notifications_1.isUserNotificationSettingValid),
    (0, express_validator_1.body)('myVideoImportFinished')
        .custom(user_notifications_1.isUserNotificationSettingValid),
    (0, express_validator_1.body)('myVideoPublished')
        .custom(user_notifications_1.isUserNotificationSettingValid),
    (0, express_validator_1.body)('commentMention')
        .custom(user_notifications_1.isUserNotificationSettingValid),
    (0, express_validator_1.body)('newFollow')
        .custom(user_notifications_1.isUserNotificationSettingValid),
    (0, express_validator_1.body)('newUserRegistration')
        .custom(user_notifications_1.isUserNotificationSettingValid),
    (0, express_validator_1.body)('newInstanceFollower')
        .custom(user_notifications_1.isUserNotificationSettingValid),
    (0, express_validator_1.body)('autoInstanceFollowing')
        .custom(user_notifications_1.isUserNotificationSettingValid),
    (req, res, next) => {
        if ((0, shared_1.areValidationErrors)(req, res))
            return;
        return next();
    }
];
exports.updateNotificationSettingsValidator = updateNotificationSettingsValidator;
const markAsReadUserNotificationsValidator = [
    (0, express_validator_1.body)('ids')
        .optional()
        .custom(misc_1.isNotEmptyIntArray).withMessage('Should have a valid array of notification ids'),
    (req, res, next) => {
        if ((0, shared_1.areValidationErrors)(req, res))
            return;
        return next();
    }
];
exports.markAsReadUserNotificationsValidator = markAsReadUserNotificationsValidator;
//# sourceMappingURL=user-notifications.js.map