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:
27
functions/notification_tokens.js
Normal file
27
functions/notification_tokens.js
Normal file
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* Retourne tous les tokens FCM d'un profil utilisateur.
|
||||
*
|
||||
* La méthode supporte le format historique `fcmToken` (string) et le nouveau
|
||||
* format `fcmTokens` (array de strings) pour gérer le multi-appareils.
|
||||
*/
|
||||
function extractUserFcmTokens(userData) {
|
||||
const tokens = [];
|
||||
|
||||
if (typeof userData.fcmToken === "string" && userData.fcmToken.length > 0) {
|
||||
tokens.push(userData.fcmToken);
|
||||
}
|
||||
|
||||
if (Array.isArray(userData.fcmTokens)) {
|
||||
for (const token of userData.fcmTokens) {
|
||||
if (typeof token === "string" && token.length > 0) {
|
||||
tokens.push(token);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return tokens;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
extractUserFcmTokens,
|
||||
};
|
||||
Reference in New Issue
Block a user