import { Prop, Schema, SchemaFactory } from "@nestjs/mongoose";
import { Document, Types } from "mongoose";

export type ReportConversationUserDocument = ReportConversationUser & Document;

@Schema({ timestamps: true })
export class ReportConversationUser {
  @Prop({ type: Types.ObjectId, ref: "Conversation", default: null })
  conversation_id!: Types.ObjectId | null;

  @Prop({ type: Types.ObjectId, ref: "User", required: true })
  reported_user_id!: Types.ObjectId;

  @Prop({ type: Types.ObjectId, ref: "User", required: true })
  reporter_id!: Types.ObjectId;

  @Prop({ type: String, default: null })
  reason!: string | null;

  @Prop({ default: null })
  deleted_at!: Date | null;
}

export const ReportConversationUserSchema =
  SchemaFactory.createForClass(ReportConversationUser);

ReportConversationUserSchema.index(
  { reported_user_id: 1, reporter_id: 1 },
  { unique: true },
);
