import { Announcement, AnnouncementType } from '../entities/announcement.entity';

export interface AnnouncementWithReadStatus {
  announcement: Announcement;
  isRead: boolean;
  readAt: Date | null;
}

export interface IAnnouncementRepository {
  save(announcement: Announcement): Promise<Announcement>;
  findById(id: string): Promise<Announcement | null>;
  findAll(params?: {
    type?: AnnouncementType;
    isEnabled?: boolean;
    limit?: number;
    offset?: number;
  }): Promise<[Announcement[], number]>;
  findForUser(params: {
    userId: string;
    userTags: string[];
    type?: AnnouncementType;
    limit?: number;
    offset?: number;
  }): Promise<AnnouncementWithReadStatus[]>;
  countUnreadForUser(userId: string, userTags: string[]): Promise<number>;
  markAsRead(announcementId: string, userId: string): Promise<void>;
  markAllAsRead(userId: string, userTags: string[]): Promise<void>;
  delete(id: string): Promise<void>;
  saveTagTargets(announcementId: string, tags: string[]): Promise<void>;
  saveUserTargets(announcementId: string, userIds: string[]): Promise<void>;
  clearTargets(announcementId: string): Promise<void>;
}

export const ANNOUNCEMENT_REPOSITORY = Symbol('IAnnouncementRepository');
