import { Timestamp, MultiLanguageString, } from './common'; import {StudentId} from './student'; import {FamilyId} from './family'; import {UserId, UserTypeGuardian, Role} from './user'; import {Image} from './fileManager'; export type MessageId = string; export type ConversationId = string; export type SystemMessageType = "welcome" | "joined" | "left" | "deleted"; export type ConversationType = "family" | "office"; export interface MessageV2 { createdAt: Timestamp; createdBy: { id: string; fid: string; nameFurigana: string; nameKanji: string; nameRomaji: string; avatarUrl?: string; // ??? childRelationship: string; userType: Role; } | UserId; id: MessageId; message: string; readBy: { [uid: UserId]: Timestamp; }; received: boolean; sentByOffice?: boolean; system?: boolean; image?: string; childRelationship?: UserTypeGuardian | null; extra?: { user?: { avatar: string; name: MultiLanguageString; uid: UserId; userType: Role; childRelationship?: UserTypeGuardian | null | undefined; }; image?: Image; systemType?: SystemMessageType; [id:string]: unknown; }; updated?: boolean; updatedAt?: Timestamp; // video?: string; } export interface ConversationV2 { conversationType: ConversationType; createdAt: Timestamp; family: FamilyId; guardians: { [uid: UserId]: boolean; }; hasGuardians: boolean; id: ConversationId; lastMessage: ConversationLastMessageV2; students: { [studentId: StudentId]: boolean; }; } export interface ConversationLastMessageV2 { mid: string; message: string; createdAt: Timestamp; createdBy: UserId; readBy: { [uid: UserId]: Timestamp; }; sentByOffice?: boolean; childRelationship?: UserTypeGuardian | null | undefined; avatarUrl?: string | null; // V2? nameRomaji: string; nameKanji: string; nameFurigana: string; }