feat: Implement trip invitation functionality and notification handling
- Added TripInvitationRepository for managing trip invitations. - Created TripInvitation model with serialization methods. - Implemented notification payload parser for handling FCM notifications. - Enhanced NotificationService to manage trip invitations and related actions. - Updated UserRepository to include user search functionality. - Modified AuthRepository to store multiple FCM tokens. - Added tests for trip invitation logic and notification payload parsing. - Updated pubspec.yaml and pubspec.lock for dependency management.
This commit is contained in:
@@ -189,4 +189,47 @@ class UserRepository {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
/// Recherche des utilisateurs inscrits par email, prénom ou nom.
|
||||
///
|
||||
/// Cette méthode est utilisée pour proposer des suggestions lors de
|
||||
/// l'invitation à un voyage. La recherche est insensible à la casse
|
||||
/// et retourne au maximum [limit] résultats.
|
||||
///
|
||||
/// [query] - Texte saisi par l'utilisateur
|
||||
/// [limit] - Nombre maximum de résultats retournés
|
||||
///
|
||||
/// Retourne une liste vide si [query] est trop court ou en cas d'erreur.
|
||||
Future<List<User>> searchUsers(String query, {int limit = 8}) async {
|
||||
final normalizedQuery = query.trim().toLowerCase();
|
||||
if (normalizedQuery.length < 2) {
|
||||
return [];
|
||||
}
|
||||
|
||||
try {
|
||||
final snapshot = await _firestore.collection('users').limit(80).get();
|
||||
final results = snapshot.docs
|
||||
.map((doc) => User.fromMap({...doc.data(), 'id': doc.id}))
|
||||
.where((user) {
|
||||
final email = user.email.toLowerCase();
|
||||
final firstName = user.prenom.toLowerCase();
|
||||
final lastName = user.nom.toLowerCase();
|
||||
final fullName = '${user.prenom} ${user.nom}'.toLowerCase();
|
||||
return email.contains(normalizedQuery) ||
|
||||
firstName.contains(normalizedQuery) ||
|
||||
lastName.contains(normalizedQuery) ||
|
||||
fullName.contains(normalizedQuery);
|
||||
})
|
||||
.take(limit)
|
||||
.toList(growable: false);
|
||||
return results;
|
||||
} catch (e, stackTrace) {
|
||||
_errorService.logError(
|
||||
'UserRepository',
|
||||
'Error searching users: $e',
|
||||
stackTrace,
|
||||
);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user