feat(communication): module messagerie unifié + contact policies + blocages

Aligné avec le backend MessagingResource :
- Nouveau module communication (conversations, messages, participants)
- Respect des ContactPolicy (qui peut parler à qui par rôle)
- Gestion MemberBlock (blocages individuels)
- UI : conversations list, conversation detail, broadcast, tiles
- BLoC : MessagingBloc avec events (envoyer, démarrer conversation rôle, etc.)
This commit is contained in:
dahoud
2026-04-15 20:26:35 +00:00
parent 07b8488714
commit 45dcd2171e
23 changed files with 2096 additions and 1588 deletions

View File

@@ -1,8 +1,7 @@
/// Événements du BLoC Messaging
/// Événements du BLoC Messagerie v4
library messaging_event;
import 'package:equatable/equatable.dart';
import '../../domain/entities/message.dart';
abstract class MessagingEvent extends Equatable {
const MessagingEvent();
@@ -11,108 +10,126 @@ abstract class MessagingEvent extends Equatable {
List<Object?> get props => [];
}
/// Charger les conversations
class LoadConversations extends MessagingEvent {
final String? organizationId;
final bool includeArchived;
// ── Conversations ─────────────────────────────────────────────────────────────
const LoadConversations({
this.organizationId,
this.includeArchived = false,
/// Charger la liste des conversations
class LoadMesConversations extends MessagingEvent {
const LoadMesConversations();
}
/// Ouvrir une conversation (charge le détail)
class OpenConversation extends MessagingEvent {
final String conversationId;
const OpenConversation(this.conversationId);
@override
List<Object?> get props => [conversationId];
}
/// Démarrer une conversation directe avec un membre
class DemarrerConversationDirecte extends MessagingEvent {
final String destinataireId;
final String organisationId;
final String? premierMessage;
const DemarrerConversationDirecte({
required this.destinataireId,
required this.organisationId,
this.premierMessage,
});
@override
List<Object?> get props => [organizationId, includeArchived];
List<Object?> get props => [destinataireId, organisationId, premierMessage];
}
/// Charger les messages d'une conversation
/// Démarrer un canal de communication avec un rôle
class DemarrerConversationRole extends MessagingEvent {
final String roleCible;
final String organisationId;
final String? premierMessage;
const DemarrerConversationRole({
required this.roleCible,
required this.organisationId,
this.premierMessage,
});
@override
List<Object?> get props => [roleCible, organisationId, premierMessage];
}
/// Archiver une conversation
class ArchiverConversation extends MessagingEvent {
final String conversationId;
const ArchiverConversation(this.conversationId);
@override
List<Object?> get props => [conversationId];
}
// ── Messages ──────────────────────────────────────────────────────────────────
/// Envoyer un message texte
class EnvoyerMessageTexte extends MessagingEvent {
final String conversationId;
final String contenu;
final String? messageParentId;
const EnvoyerMessageTexte({
required this.conversationId,
required this.contenu,
this.messageParentId,
});
@override
List<Object?> get props => [conversationId, contenu, messageParentId];
}
/// Charger l'historique des messages
class LoadMessages extends MessagingEvent {
final String conversationId;
final int? limit;
final String? beforeMessageId;
final int page;
const LoadMessages({
required this.conversationId,
this.limit,
this.beforeMessageId,
});
const LoadMessages({required this.conversationId, this.page = 0});
@override
List<Object?> get props => [conversationId, limit, beforeMessageId];
List<Object?> get props => [conversationId, page];
}
/// Envoyer un message
class SendMessageEvent extends MessagingEvent {
/// Marquer une conversation comme lue
class MarquerLu extends MessagingEvent {
final String conversationId;
final String content;
final List<String>? attachments;
final MessagePriority priority;
const SendMessageEvent({
required this.conversationId,
required this.content,
this.attachments,
this.priority = MessagePriority.normal,
});
const MarquerLu(this.conversationId);
@override
List<Object?> get props => [conversationId, content, attachments, priority];
List<Object?> get props => [conversationId];
}
/// Envoyer un broadcast
class SendBroadcastEvent extends MessagingEvent {
final String organizationId;
final String subject;
final String content;
final MessagePriority priority;
final List<String>? attachments;
const SendBroadcastEvent({
required this.organizationId,
required this.subject,
required this.content,
this.priority = MessagePriority.normal,
this.attachments,
});
@override
List<Object?> get props => [organizationId, subject, content, priority, attachments];
}
/// Marquer un message comme lu
class MarkMessageAsReadEvent extends MessagingEvent {
/// Supprimer un message
class SupprimerMessage extends MessagingEvent {
final String conversationId;
final String messageId;
const MarkMessageAsReadEvent(this.messageId);
@override
List<Object?> get props => [messageId];
}
/// Charger le nombre de messages non lus
class LoadUnreadCount extends MessagingEvent {
final String? organizationId;
const LoadUnreadCount({this.organizationId});
@override
List<Object?> get props => [organizationId];
}
/// Créer une nouvelle conversation
class CreateConversationEvent extends MessagingEvent {
final String name;
final List<String> participantIds;
final String? organizationId;
final String? description;
const CreateConversationEvent({
required this.name,
required this.participantIds,
this.organizationId,
this.description,
const SupprimerMessage({
required this.conversationId,
required this.messageId,
});
@override
List<Object?> get props => [name, participantIds, organizationId, description];
List<Object?> get props => [conversationId, messageId];
}
// ── Temps réel WebSocket ───────────────────────────────────────────────────────
/// Nouveau message reçu via WebSocket
class NouveauMessageWebSocket extends MessagingEvent {
final String conversationId;
const NouveauMessageWebSocket(this.conversationId);
@override
List<Object?> get props => [conversationId];
}