feat(mobile): intégration complète API messagerie backend

Connecte le système de communication mobile aux endpoints backend créés.

## Datasource (messaging_remote_datasource.dart)
-  Correction URLs : /api/messaging/* → /api/conversations et /api/messages
-  Ajout archiveConversation (PUT /api/conversations/{id}/archive)
-  Ajout markConversationAsRead (PUT /api/conversations/{id}/mark-read)
-  Ajout toggleMuteConversation (PUT /api/conversations/{id}/toggle-mute)
-  Ajout togglePinConversation (PUT /api/conversations/{id}/toggle-pin)
-  Ajout editMessage (PUT /api/messages/{id})
-  Ajout deleteMessage (DELETE /api/messages/{id})
- Correction paramètres : organizationId → organisationId (backend)
- Ajout type: GROUP dans createConversation (requis par backend)

## Repository (messaging_repository_impl.dart)
Remplacement 6 stubs NotImplementedFailure par vrais appels API :
-  archiveConversation : appel datasource avec gestion erreurs
-  markConversationAsRead : appel datasource avec gestion erreurs
-  toggleMuteConversation : appel datasource avec gestion erreurs
-  togglePinConversation : appel datasource avec gestion erreurs
-  editMessage : appel datasource avec gestion erreurs + NotFoundException
-  deleteMessage : appel datasource avec gestion erreurs + NotFoundException

## État final
- 14 méthodes implémentées (sur 22 définies dans le repository)
- 8 stubs restants (templates + sendTargetedMessage) → backend non implémenté
- Analyse Flutter : 0 erreur de compilation (990 warnings de style)
- Communication feature : 100% fonctionnelle côté CRUD de base

Débloquer la fonctionnalité Communication mobile (était 100% stubs).

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
dahoud
2026-03-16 06:46:47 +00:00
parent 5c5ec3ad00
commit df1e8f417d
2 changed files with 209 additions and 36 deletions

View File

@@ -219,12 +219,24 @@ class MessagingRepositoryImpl implements MessagingRepository {
}
}
// === MÉTHODES NON IMPLÉMENTÉES (Stubs pour compilation) ===
// À implémenter selon besoins backend
// === CONVERSATION ACTIONS ===
@override
Future<Either<Failure, void>> archiveConversation(String conversationId) async {
return Left(NotImplementedFailure('Fonctionnalité en cours de développement'));
if (!await networkInfo.isConnected) {
return Left(NetworkFailure('Pas de connexion Internet'));
}
try {
await remoteDatasource.archiveConversation(conversationId);
return const Right(null);
} on UnauthorizedException {
return Left(UnauthorizedFailure('Session expirée'));
} on ServerException catch (e) {
return Left(ServerFailure(e.message));
} catch (e) {
return Left(UnexpectedFailure('Erreur inattendue: $e'));
}
}
@override
@@ -235,35 +247,110 @@ class MessagingRepositoryImpl implements MessagingRepository {
required String content,
MessagePriority priority = MessagePriority.normal,
}) async {
// TODO: Backend needs specific endpoint for targeted messages
return Left(NotImplementedFailure('Fonctionnalité en cours de développement'));
}
@override
Future<Either<Failure, void>> markConversationAsRead(String conversationId) async {
return Left(NotImplementedFailure('Fonctionnalité en cours de développement'));
if (!await networkInfo.isConnected) {
return Left(NetworkFailure('Pas de connexion Internet'));
}
try {
await remoteDatasource.markConversationAsRead(conversationId);
return const Right(null);
} on UnauthorizedException {
return Left(UnauthorizedFailure('Session expirée'));
} on ServerException catch (e) {
return Left(ServerFailure(e.message));
} catch (e) {
return Left(UnexpectedFailure('Erreur inattendue: $e'));
}
}
@override
Future<Either<Failure, void>> toggleMuteConversation(String conversationId) async {
return Left(NotImplementedFailure('Fonctionnalité en cours de développement'));
if (!await networkInfo.isConnected) {
return Left(NetworkFailure('Pas de connexion Internet'));
}
try {
await remoteDatasource.toggleMuteConversation(conversationId);
return const Right(null);
} on UnauthorizedException {
return Left(UnauthorizedFailure('Session expirée'));
} on ServerException catch (e) {
return Left(ServerFailure(e.message));
} catch (e) {
return Left(UnexpectedFailure('Erreur inattendue: $e'));
}
}
@override
Future<Either<Failure, void>> togglePinConversation(String conversationId) async {
return Left(NotImplementedFailure('Fonctionnalité en cours de développement'));
if (!await networkInfo.isConnected) {
return Left(NetworkFailure('Pas de connexion Internet'));
}
try {
await remoteDatasource.togglePinConversation(conversationId);
return const Right(null);
} on UnauthorizedException {
return Left(UnauthorizedFailure('Session expirée'));
} on ServerException catch (e) {
return Left(ServerFailure(e.message));
} catch (e) {
return Left(UnexpectedFailure('Erreur inattendue: $e'));
}
}
// === MESSAGE ACTIONS ===
@override
Future<Either<Failure, Message>> editMessage({
required String messageId,
required String newContent,
}) async {
return Left(NotImplementedFailure('Fonctionnalité en cours de développement'));
if (!await networkInfo.isConnected) {
return Left(NetworkFailure('Pas de connexion Internet'));
}
try {
final message = await remoteDatasource.editMessage(
messageId: messageId,
newContent: newContent,
);
return Right(message);
} on NotFoundException {
return Left(NotFoundFailure('Message non trouvé'));
} on UnauthorizedException {
return Left(UnauthorizedFailure('Session expirée'));
} on ServerException catch (e) {
return Left(ServerFailure(e.message));
} catch (e) {
return Left(UnexpectedFailure('Erreur inattendue: $e'));
}
}
@override
Future<Either<Failure, void>> deleteMessage(String messageId) async {
return Left(NotImplementedFailure('Fonctionnalité en cours de développement'));
if (!await networkInfo.isConnected) {
return Left(NetworkFailure('Pas de connexion Internet'));
}
try {
await remoteDatasource.deleteMessage(messageId);
return const Right(null);
} on NotFoundException {
return Left(NotFoundFailure('Message non trouvé'));
} on UnauthorizedException {
return Left(UnauthorizedFailure('Session expirée'));
} on ServerException catch (e) {
return Left(ServerFailure(e.message));
} catch (e) {
return Left(UnexpectedFailure('Erreur inattendue: $e'));
}
}
@override