import { Entity, PrimaryGeneratedColumn, Column, ManyToOne, JoinColumn } from 'typeorm';
import { License } from './license.entity';

@Entity('notifications_config')
export class NotificationsConfig {
  @PrimaryGeneratedColumn('uuid')
  id: string;

  @Column({ type: 'uuid', unique: true })
  license_id: string;

  @Column({ type: 'text', nullable: true })
  discord_webhook_url: string | null;

  @Column({ type: 'boolean', default: false })
  discord_enabled: boolean;

  @Column({ type: 'text', nullable: true })
  pushbullet_api_key: string | null;

  @Column({ type: 'boolean', default: false })
  pushbullet_enabled: boolean;

  @Column({ type: 'boolean', default: true })
  email_alerts_enabled: boolean;

  @Column({ type: 'boolean', default: true })
  notify_wipe_start: boolean;

  @Column({ type: 'boolean', default: true })
  notify_wipe_complete: boolean;

  @Column({ type: 'boolean', default: true })
  notify_wipe_failed: boolean;

  @Column({ type: 'boolean', default: true })
  notify_server_crash: boolean;

  @Column({ type: 'boolean', default: true })
  notify_server_offline: boolean;

  @Column({ type: 'boolean', default: true })
  notify_store_purchase: boolean;

  @Column({ type: 'boolean', default: false })
  notify_player_report: boolean;

  @Column({ type: 'timestamptz', default: () => 'NOW()' })
  created_at: Date;

  @ManyToOne(() => License, { onDelete: 'CASCADE' })
  @JoinColumn({ name: 'license_id' })
  license: License;
}
