// Questo file fa parte di MyTown.
// MyTown è software libero: puoi ridistribuirlo e/o modificarlo secondo
// i termini della GNU Affero General Public License come pubblicata dalla
// Free Software Foundation, versione 3.
// Distribuito senza ALCUNA GARANZIA; vedi la GNU AGPL v3 per i dettagli.
// Copyright (C) Kondor Consulting & Services S.r.l.
// SPDX-License-Identifier: AGPL-3.0-or-later

export interface CmpConversation {
	conv_id: number;
	conv_type?: 'DIRECT' | 'COMPANY' | 'GROUP';
	conv_title?: string;
	conv_user1_id: number;
	conv_user2_id: number;
	conv_last_message_at: string;
	conv_created_at: string;
	other_firstname: string;
	other_lastname: string;
	other_username?: string;
	other_company_name?: string;
	other_cmp_id?: number;
	other_prt_id?: number;
	last_message_text: string;
	unread_count: number;
}

export interface CmpAttachment {
	att_id: number;
	att_msg_id: number;
	att_filename: string;
	att_mime?: string;
	att_size?: number;
	// popolato lato app: object URL del blob scaricato
	_objectUrl?: string;
}

export interface CmpMessage {
	msg_id: number;
	msg_conv_id: number;
	msg_sender_id: number;
	msg_text: string;
	msg_created_at: string;
	msg_read_at: string | null;
	msg_deleted_at?: string | null;
	msg_edited_at?: string | null;
	sender_firstname?: string;
	sender_lastname?: string;
	sender_username?: string;
	sender_company_name?: string;
	attachments?: CmpAttachment[];
}

export interface UserSearchResult {
	usr_id: number;
	usr_firstname: string;
	usr_lastname: string;
	usr_username: string;
}

export interface CmpConversationMember {
	cvm_usr_id: number;
	cvm_role: 'ADMIN' | 'MEMBER';
	cvm_active?: boolean;
	usr_firstname?: string;
	usr_lastname?: string;
	usr_username?: string;
}
