π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Simplify remaining identity resolution
Neeraj Gupta42202c21ea93
diff --git a/mobile/apps/photos/lib/services/machine_learning/face_ml/person/person_service.dart b/mobile/apps/photos/lib/services/machine_learning/face_ml/person/person_service.dartindex 29f53593cb..3c4150082f 100644--- a/mobile/apps/photos/lib/services/machine_learning/face_ml/person/person_service.dart+++ b/mobile/apps/photos/lib/services/machine_learning/face_ml/person/person_service.dart@@ -145,8 +145,9 @@ class PersonService {return null;}+ // Pre-userID Person entities are email-only; only positive IDs block fallback.static bool _canUseEmailFallback(PersonEntity person, int? requestedUserID) {- return requestedUserID == null || person.data.userID == null;+ return requestedUserID == null || (person.data.userID ?? 0) <= 0;}void clearCache() {diff --git a/mobile/apps/photos/lib/ui/viewer/people/person_face_widget.dart b/mobile/apps/photos/lib/ui/viewer/people/person_face_widget.dartindex 019968d4e2..3cf917005f 100644--- a/mobile/apps/photos/lib/ui/viewer/people/person_face_widget.dart+++ b/mobile/apps/photos/lib/ui/viewer/people/person_face_widget.dart@@ -22,6 +22,7 @@ import "package:photos/services/search_service.dart";import "package:photos/theme/ente_theme.dart";import "package:photos/ui/common/loading_widget.dart";import "package:photos/utils/avatar_util.dart";+import "package:photos/utils/contact_string_util.dart";import "package:photos/utils/face/face_thumbnail_cache.dart";final _logger = Logger("PersonFaceWidget");@@ -302,20 +303,16 @@ class _PersonFaceWidgetState extends State<PersonFaceWidget>return null;}final personData = personEntity.data;- final resolvedEmail = PhotosContactsService.instance- .getCachedResolvedEmail(- contactUserId: personData.userID,- email: personData.userID == null ? personData.email : null,- );- final resolvedName = PhotosContactsService.instance.getCachedSavedName(+ final contact = PhotosContactsService.instance.getCachedContact(contactUserId: personData.userID,- email: personData.userID == null ? personData.email : null,+ email: personData.email,);_personIdentity = AvatarIdentity.account(- label: resolvedName ?? personData.name,- email: resolvedEmail ?? personData.email,+ label: trimToNull(contact?.data?.name) ?? personData.name,+ email: trimToNull(contact?.email) ?? personData.email,userID: personData.userID,personID: personEntity.remoteID,+ currentUserID: Configuration.instance.getUserID(),currentUserEmail: Configuration.instance.getEmail(),);if (contactPhotoBytes != null) {diff --git a/mobile/apps/photos/lib/ui/viewer/search/result/edit_contact_page.dart b/mobile/apps/photos/lib/ui/viewer/search/result/edit_contact_page.dartindex 45260cefa9..1325686c6e 100644--- a/mobile/apps/photos/lib/ui/viewer/search/result/edit_contact_page.dart+++ b/mobile/apps/photos/lib/ui/viewer/search/result/edit_contact_page.dart@@ -233,6 +233,7 @@ class _EditContactPageState extends State<EditContactPage> {label: trimmedName.isNotEmpty ? trimmedName : widget.email,email: widget.email,userID: widget.contactUserId,+ currentUserID: Configuration.instance.getUserID(),currentUserEmail: Configuration.instance.getEmail(),);diff --git a/mobile/apps/photos/test/models/ml/face/person_contact_link_test.dart b/mobile/apps/photos/test/models/ml/face/person_contact_link_test.dartindex 8c2d45299c..0d15d091d7 100644--- a/mobile/apps/photos/test/models/ml/face/person_contact_link_test.dart+++ b/mobile/apps/photos/test/models/ml/face/person_contact_link_test.dart@@ -127,32 +127,26 @@ void main() {"other-user",PersonData(name: "Other", email: "[email protected]", userID: 8),),- ];-- expect(- PersonService.findPersonForUser(- persons,- userID: 8,- email: "[email protected]",- )?.remoteID,- "other-user",- );- expect(- PersonService.findPersonForUser(- persons,- userID: 7,- email: "[email protected]",- )?.remoteID,- "legacy-person",- );- expect(- PersonService.findPersonForUser(- persons,- userID: 7,- email: " [email protected] ",+ PersonEntity(+ "invalid-id-person",+ PersonData(+ name: "Invalid ID",+ email: "[email protected]",+ userID: 0,+ ),),- isNull,- );+ ];+ PersonEntity? find(int? userID, String email) =>+ PersonService.findPersonForUser(+ persons,+ userID: userID,+ email: email,+ );++ expect(find(8, "[email protected]")?.remoteID, "other-user");+ expect(find(7, "[email protected]")?.remoteID, "legacy-person");+ expect(find(7, " [email protected] "), isNull);+ expect(find(7, "[email protected]")?.remoteID, "invalid-id-person");},);diff --git a/mobile/packages/sharing/lib/extensions/user_extension.dart b/mobile/packages/sharing/lib/extensions/user_extension.dartindex 1d1e218f72..ec4bed45b4 100644--- a/mobile/packages/sharing/lib/extensions/user_extension.dart+++ b/mobile/packages/sharing/lib/extensions/user_extension.dart@@ -4,35 +4,20 @@ import "package:ente_sharing/models/user.dart";typedef ResolvedUserIdentity = ({String displayName, String email});extension UserExtension on User {- String get nameOrEmail {- return email.substring(0, email.indexOf("@"));- }-- String get resolvedDisplayName => resolvedUserDisplayName(id, email);-- String get resolvedEmail => resolvedUserEmail(id, email);+ String get resolvedDisplayName => resolveUserIdentity(id, email).displayName;bool matchesResolvedNameOrEmail(String query) =>_matchesResolvedNameOrEmail(id, email, query);}extension UserSuggestionExtension on UserSuggestion {- String get resolvedDisplayName => resolvedUserDisplayName(userID, email);-- String get resolvedEmail => resolvedUserEmail(userID, email);+ String get resolvedDisplayName =>+ resolveUserIdentity(userID, email).displayName;bool matchesResolvedNameOrEmail(String query) =>_matchesResolvedNameOrEmail(userID, email, query);}-String resolvedUserDisplayName(int? userID, String email) {- return resolveUserIdentity(userID, email).displayName;-}--String resolvedUserEmail(int? userID, String email) {- return resolveUserIdentity(userID, email).email;-}-ResolvedUserIdentity resolveUserIdentity(int? userID, String email) {final contact = ContactsDisplayService.instance.getCachedContact(contactUserId: userID,