import { Module } from '@nestjs/common'
import { MongooseModule } from '@nestjs/mongoose'
import {
  Email, EmailSchema,
  UserEmailAccount, UserEmailAccountSchema,
  ClientFolder, ClientFolderSchema,
  Matter, MatterSchema,
  EmailServerSettings, EmailServerSettingsSchema,
} from '../common/schemas'
import { EmailService } from './email.service'
import { EmailController } from './email.controller'
import { EmailAssociationService } from './email-association.service'
import { SmtpListenerService } from './smtp-listener.service'
import { ImapPollingService } from './imap-polling.service'

@Module({
  imports: [
    MongooseModule.forFeature([
      { name: Email.name,            schema: EmailSchema },
      { name: UserEmailAccount.name, schema: UserEmailAccountSchema },
      { name: ClientFolder.name,        schema: ClientFolderSchema },
      { name: Matter.name,             schema: MatterSchema },
      { name: EmailServerSettings.name, schema: EmailServerSettingsSchema },
    ]),
  ],
  controllers: [EmailController],
  providers: [EmailService, EmailAssociationService, SmtpListenerService, ImapPollingService],
  exports:   [EmailService],
})
export class EmailModule {}
