Add stable share fingerprints and near-match conflict routing
This commit is contained in:
@@ -106,6 +106,10 @@ void main() {
|
||||
);
|
||||
expect(first.createdProfile, isTrue);
|
||||
expect(afterFirst.people.length, before.people.length + 1);
|
||||
final SourceProfileLink createdLink = afterFirst.sourceLinks.firstWhere(
|
||||
(SourceProfileLink link) => link.profileId == first.profileId,
|
||||
);
|
||||
expect(createdLink.sourceFingerprint, 'whatsapp|u:wa:taylor quinn');
|
||||
expect(
|
||||
afterFirst.sourceLinks.any(
|
||||
(SourceProfileLink link) => link.profileId == first.profileId,
|
||||
@@ -144,6 +148,84 @@ void main() {
|
||||
},
|
||||
);
|
||||
|
||||
test(
|
||||
'queues near-match conflict and then uses fingerprint mapping for follow-up shares',
|
||||
() async {
|
||||
final ProviderContainer container = _createContainer();
|
||||
addTearDown(container.dispose);
|
||||
|
||||
await container.read(localRepositoryProvider.future);
|
||||
await container
|
||||
.read(localRepositoryProvider.notifier)
|
||||
.addPerson(
|
||||
name: 'Marek Havel',
|
||||
relationship: 'Friend',
|
||||
notes: '',
|
||||
tags: const <String>[],
|
||||
);
|
||||
final LocalDataState peopleState = await container.read(
|
||||
localRepositoryProvider.future,
|
||||
);
|
||||
final String marekId = peopleState.people
|
||||
.firstWhere((PersonProfile person) => person.name == 'Marek Havel')
|
||||
.id;
|
||||
|
||||
final SharedMessageIngestResult queued = await container
|
||||
.read(localRepositoryProvider.notifier)
|
||||
.ingestSharedMessage(
|
||||
const SharedMessageIngestInput(
|
||||
sourceApp: 'whatsapp',
|
||||
sourceDisplayName: 'Marek Havl',
|
||||
sourceUserId: 'wa:marek_882',
|
||||
messageText: 'Saw this and thought of you.',
|
||||
),
|
||||
);
|
||||
LocalDataState afterQueue = await container.read(
|
||||
localRepositoryProvider.future,
|
||||
);
|
||||
expect(queued.isQueuedForResolution, isTrue);
|
||||
expect(
|
||||
afterQueue.sharedInbox.first.reason,
|
||||
SharedInboxReason.nearProfileConflict,
|
||||
);
|
||||
expect(
|
||||
afterQueue.sharedInbox.first.candidateProfileIds,
|
||||
contains(marekId),
|
||||
);
|
||||
|
||||
final SharedMessageIngestResult resolved = await container
|
||||
.read(localRepositoryProvider.notifier)
|
||||
.resolveSharedInboxToExistingProfile(
|
||||
inboxEntryId: queued.inboxEntryId!,
|
||||
profileId: marekId,
|
||||
);
|
||||
expect(resolved.profileId, marekId);
|
||||
|
||||
final SharedMessageIngestResult followUp = await container
|
||||
.read(localRepositoryProvider.notifier)
|
||||
.ingestSharedMessage(
|
||||
const SharedMessageIngestInput(
|
||||
sourceApp: 'whatsapp',
|
||||
sourceDisplayName: 'Alias Name',
|
||||
sourceUserId: 'wa:marek_882',
|
||||
messageText: 'Second follow-up message.',
|
||||
),
|
||||
);
|
||||
afterQueue = await container.read(localRepositoryProvider.future);
|
||||
expect(followUp.isQueuedForResolution, isFalse);
|
||||
expect(followUp.profileId, marekId);
|
||||
expect(afterQueue.sharedInbox, isEmpty);
|
||||
expect(
|
||||
afterQueue.sourceLinks.any(
|
||||
(SourceProfileLink link) =>
|
||||
link.profileId == marekId &&
|
||||
link.sourceFingerprint == 'whatsapp|u:wa:marek_882',
|
||||
),
|
||||
isTrue,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
test(
|
||||
'queues ambiguous shared message into inbox for manual resolution',
|
||||
() async {
|
||||
|
||||
Reference in New Issue
Block a user