import { Module } from '@nestjs/common'
import { MongooseModule } from '@nestjs/mongoose'
import { AuditModule } from '../audit/audit.module.js'
import { AuthModule } from '../auth/auth.module.js'
import { IntegrationsModule } from '../integrations/integrations.module.js'
import { Domain, DomainSchema } from '../schemas/domain.schema.js'
import { User, UserSchema } from '../schemas/user.schema.js'
import { TenantsModule } from '../tenants/tenants.module.js'
import { MailController } from './mail.controller.js'
import { MailService } from './mail.service.js'

@Module({
  imports: [
    MongooseModule.forFeature([
      { name: Domain.name, schema: DomainSchema },
      { name: User.name, schema: UserSchema },
    ]),
    AuthModule,
    AuditModule,
    IntegrationsModule,
    TenantsModule, // TenantsService — resolve tenant by slug for the membership gate
  ],
  controllers: [MailController],
  providers: [MailService],
})
export class MailModule {}
