text: const rootPrefix = '../../..',
    CommonValidators = require(rootPrefix + '/lib/validators/Common'),
    UserNotificationPublisherBase = require(rootPrefix + '/lib/userNotificationPublisher/Base'),
    logger = require(rootPrefix + '/lib/logger/customConsoleLogger'),
    responseHelper = require(rootPrefix + '/lib/formatter/response'),
    notificationHookConstants = require(rootPrefix + '/lib/globalConstant/big/notificationHook'),
    userNotificationConstants = require(rootPrefix + '/lib/globalConstant/cassandra/userNotification');
  
  /**
   * Class for user mention in video with channel name.
   *
   * @class UserMentionWithChannelName
   */
  class UserMentionWithChannelName extends UserNotificationPublisherBase {
    /**
     * Constructor for video user mention.
     *
     * @param {object} params
     * @param {number} params.videoId
     * @param {number} params.userId
     * @param {Array} params.publishUserIds
     * @param {Array} params.channelId
     *
     * @augments UserNotificationPublisherBase
     *
     * @constructor
     */
    constructor(params) {
      super();
  
      const oThis = this;
  
      oThis.videoId = params.videoId;
      oThis.userId = params.userId;
      oThis.publishUserIds = params.publishUserIds;
      oThis.channelId = params.channelId;
    }
  
    /**
     * Async performer.
     *
     * @return {Promise<void>}
     */
    async _asyncPerform() {
      const oThis = this;
  
      await oThis._validateAndSanitizeParams();
  
      await oThis._setNotificationCentrePayload();
  
      await oThis.enqueueUserNotification();
  
      // Insert into notification_hooks table for hook push notifications.
      await oThis._insertIntoNotificationHook();
  
      return responseHelper.successWithData({});
    }
  
    /**
     * Validate and sanitize parameters.
     *
     * @return {Promise<void>}
     * @private
     */
    async _validateAndSanitizeParams() {
      const oThis = this;
  
      logger.log('Start:: Validate for UserMentionWithChannelName');
      let hasError = false;
  
      if (
        !CommonValidators.validateNonZeroInteger(oThis.videoId) ||
        !CommonValidators.validateNonZeroInteger(oThis.userId)
      ) {
        hasError = true;
      }
  
      if (hasError) {
        return Promise.reject(
          responseHelper.error({
            internal_error_identifier: 'l_unp_um_vas_1',
            api_error_identifier: 'invalid_api_params',
            debug_options: { videoId: oThis.videoId, userId: oThis.userId }
          })
        );
      }
  
      logger.log('End:: Validate for UserMentionWithChannelName');
    }
  
    /**
     * Set payload for notification.
     *
     * @sets oThis.payload
     *
     * @return {Promise<void>}
     * @private
     */
    async _setNotificationCentrePayload() {
      const oThis = this;
      logger.log('Start:: _setNotificationCentrePayload for UserMentionWithChannelName');
  
      oThis.payload = {
        actorIds: [oThis.userId],
        actorCount: 1,
        subjectUserId: oThis.userId,
        payload: {
          videoId: oThis.videoId,
          channelId: oThis.channelId
        }
      };
  
      logger.log('End:: _setNotificationCentrePayload for UserMentionWithChannelName');
    }
  
    /**
     * Set user notification kind.
     *
     * @returns {string}
     * @private
     */
    _userNotificationKind() {
      return userNotificationConstants.userMentionInChannelKind;
    }
  
    /**
     * Set hook kind.
     *
     * @returns {string}
     * @private
     */
    _notificationHookKind() {
      return notificationHookConstants.userMentionInChannelKind;
    }
  }
  
  module.exports = UserMentionWithChannelName;
  