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_items = sequelize.define(
    'content_moderation_items',
    {
      id: {
        type: DataTypes.UUID,
        defaultValue: DataTypes.UUIDV4,
        primaryKey: true,
      },

content_type: {
        type: DataTypes.ENUM,
      
      

        values: [

"profile_photo",


"message",


"bio"

        ],

      },

text_excerpt: {
        type: DataTypes.TEXT,
      
      

      },

status: {
        type: DataTypes.ENUM,
      
      

        values: [

"queued",


"approved",


"rejected",


"removed"

        ],

      },

queued_at: {
        type: DataTypes.DATE,
      
      

      },

reviewed_at: {
        type: DataTypes.DATE,
      
      

      },

moderation_notes: {
        type: DataTypes.TEXT,
      
      

      },

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

  content_moderation_items.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_items.belongsTo(db.users, {
      as: 'user',
      foreignKey: {
        name: 'userId',
      },
      constraints: false,
    });

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

    db.content_moderation_items.belongsTo(db.user_photos, {
      as: 'photo',
      foreignKey: {
        name: 'photoId',
      },
      constraints: false,
    });

    db.content_moderation_items.belongsTo(db.admin_users, {
      as: 'reviewed_by',
      foreignKey: {
        name: 'reviewed_byId',
      },
      constraints: false,
    });




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

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



  return content_moderation_items;
};


