const config = require('../../config');
const providers = config.providers;
const crypto = require('crypto');
const bcrypt = require('bcrypt');
const moment = require('moment');

module.exports = function(sequelize, DataTypes) {
  const content_moderation_reports = sequelize.define(
    'content_moderation_reports',
    {
      id: {
        type: DataTypes.UUID,
        defaultValue: DataTypes.UUIDV4,
        primaryKey: true,
      },

target_type: {
        type: DataTypes.ENUM,
      
      

        values: [

"post",


"comment",


"message",


"user",


"live_stream"

        ],

      },

reason_code: {
        type: DataTypes.ENUM,
      
      

        values: [

"spam",


"hate_speech",


"harassment",


"nudity",


"violence",


"self_harm",


"copyright",


"scam",


"other"

        ],

      },

details_text: {
        type: DataTypes.TEXT,
      
      

      },

status: {
        type: DataTypes.ENUM,
      
      

        values: [

"open",


"under_review",


"action_taken",


"dismissed"

        ],

      },

reported_at: {
        type: DataTypes.DATE,
      
      

      },

resolved_at: {
        type: DataTypes.DATE,
      
      

      },

      importHash: {
        type: DataTypes.STRING(255),
        allowNull: true,
        unique: true,
      },
    },
    {
      timestamps: true,
      paranoid: true,
      freezeTableName: true,
    },
  );

  content_moderation_reports.associate = (db) => {


/// loop through entities and it's fields, and if ref === current e[name] and create relation has many on parent entity



























//end loop



    db.content_moderation_reports.belongsTo(db.users, {
      as: 'reporter',
      foreignKey: {
        name: 'reporterId',
      },
      constraints: false,
    });

    db.content_moderation_reports.belongsTo(db.posts, {
      as: 'post',
      foreignKey: {
        name: 'postId',
      },
      constraints: false,
    });

    db.content_moderation_reports.belongsTo(db.comments, {
      as: 'comment',
      foreignKey: {
        name: 'commentId',
      },
      constraints: false,
    });

    db.content_moderation_reports.belongsTo(db.messages, {
      as: 'message',
      foreignKey: {
        name: 'messageId',
      },
      constraints: false,
    });

    db.content_moderation_reports.belongsTo(db.users, {
      as: 'reported_user',
      foreignKey: {
        name: 'reported_userId',
      },
      constraints: false,
    });

    db.content_moderation_reports.belongsTo(db.live_streams, {
      as: 'live_stream',
      foreignKey: {
        name: 'live_streamId',
      },
      constraints: false,
    });

    db.content_moderation_reports.belongsTo(db.users, {
      as: 'assigned_moderator',
      foreignKey: {
        name: 'assigned_moderatorId',
      },
      constraints: false,
    });




    db.content_moderation_reports.belongsTo(db.users, {
      as: 'createdBy',
    });

    db.content_moderation_reports.belongsTo(db.users, {
      as: 'updatedBy',
    });
  };



  return content_moderation_reports;
};


