[contacts] Populate remoteId of newly created contact
ClosedPublic

Authored by poboiko on Mar 21 2020, 10:20 AM.

Details

Summary

If user tries to modify a contact that has just been created, the modify job returns 404.
Although remoteId gets updated by changeCommitted, the UID inside Addressee doesn't.
We need to update the payload explicitly, in order to resolve the confusion

This patch adds an ItemModifyJob which does precisely that.

Test Plan
  1. Create contact in KAddressBook
  2. Check Web: contacts is created
  3. Change this contact inside KAB
  4. (without patch) Contact does not get changed inside Web UI, we get 404
  5. (with patch) Contact gets changed

Diff Detail

Repository
R44 KDE PIM Runtime
Branch
fix-contact-create-modify (branched from master)
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 24100
Build 24118: arc lint + arc unit
poboiko created this revision.Mar 21 2020, 10:20 AM
Restricted Application added a project: KDE PIM. · View Herald TranscriptMar 21 2020, 10:20 AM
poboiko requested review of this revision.Mar 21 2020, 10:20 AM
dvratil requested changes to this revision.Mar 21 2020, 12:12 PM
dvratil added inline comments.
resources/google/contacts/contactsresource.cpp
527

This should not be needed: the call to Akonadi::ResourceBase::changeCommitted() does internally call ItemModifyJob for the item in order to update the remoteid...

This revision now requires changes to proceed.Mar 21 2020, 12:12 PM

Hmm, that's weird.
I've looked into CalendarResource (say, slotCreateJobFinished) and the code there explicitly calls ItemModifyJob too.

Here's the debug output without this change:

org.kde.kgapi: ("http://www.google.com/m8/feeds/groups/EMAIL%40gmail.com/base/6")
org.kde.kgapi: Queued QUrl("https://www.google.com/m8/feeds/contacts/EMAIL@gmail.com/full")
org.kde.kgapi: KGAPI2::ContactCreateJob(0x556e98b54020) Dispatching request to QUrl("https://www.google.com/m8/feeds/contacts/EMAIL@gmail.com/full")
org.kde.pim.akonadicore: Deleting items from the akonadi database failed: "No items found"
org.kde.kgapi: Received reply from QUrl("https://www.google.com/m8/feeds/contacts/EMAIL@gmail.com/full?prettyPrint=false")
org.kde.kgapi: Status code:  201
org.kde.pim.akonadicore: Deleting items from the akonadi database failed: "No items found"
org.kde.kgapi: ("http://www.google.com/m8/feeds/groups/EMAIL%40gmail.com/base/6")
org.kde.kgapi: Queued QUrl("https://www.google.com/m8/feeds/contacts/EMAIL@gmail.com/full/843a45f9-b479-46c2-bb4a-607d438e92e9")
org.kde.kgapi: KGAPI2::ContactModifyJob(0x556e98b72920) Dispatching request to QUrl("https://www.google.com/m8/feeds/contacts/EMAIL@gmail.com/full/843a45f9-b479-46c2-bb4a-607d438e92e9")
org.kde.pim.akonadicore: Deleting items from the akonadi database failed: "No items found"
org.kde.kgapi: Received reply from QUrl("https://www.google.com/m8/feeds/contacts/EMAIL@gmail.com/full/843a45f9-b479-46c2-bb4a-607d438e92e9?prettyPrint=false")
org.kde.kgapi: Status code:  404
org.kde.kgapi: Requested resource does not exist
org.kde.kgapi: Queued QUrl("https://www.google.com/m8/feeds/photos/media/EMAIL@gmail.com/843a45f9-b479-46c2-bb4a-607d438e92e9")
org.kde.kgapi: KGAPI2::ContactModifyJob(0x556e98b72920) Dispatching request to QUrl("https://www.google.com/m8/feeds/photos/media/EMAIL@gmail.com/843a45f9-b479-46c2-bb4a-607d438e92e9")
org.kde.kgapi: Received reply from QUrl("https://www.google.com/m8/feeds/photos/media/EMAIL@gmail.com/843a45f9-b479-46c2-bb4a-607d438e92e9")
org.kde.kgapi: Status code:  404
org.kde.kgapi: Requested resource does not exist

The ID for newly created contact is 843a45f9-b479-46c2-bb4a-607d438e92e9, which is not right (the right one is 41c9b4289fd31e5).

Although you seem to be correct, I've checked AkonadiConsole and the remoteId there is correct. There is indeed an ItemModifyJob in the job tracker.

With the patch, however, the logs show following:

org.kde.kgapi: ("http://www.google.com/m8/feeds/groups/EMAIL%40gmail.com/base/6")
org.kde.kgapi: Queued QUrl("https://www.google.com/m8/feeds/contacts/EMAIL@gmail.com/full")
org.kde.kgapi: KGAPI2::ContactCreateJob(0x55c3a22c3590) Dispatching request to QUrl("https://www.google.com/m8/feeds/contacts/EMAIL@gmail.com/full")
org.kde.pim.akonadicore: Deleting items from the akonadi database failed: "No items found"
org.kde.kgapi: Received reply from QUrl("https://www.google.com/m8/feeds/contacts/EMAIL@gmail.com/full?prettyPrint=false")
org.kde.kgapi: Status code:  201
org.kde.pim.akonadicore: Deleting items from the akonadi database failed: "No items found"
org.kde.kgapi: ("http://www.google.com/m8/feeds/groups/EMAIL%40gmail.com/base/6")
org.kde.kgapi: Queued QUrl("https://www.google.com/m8/feeds/contacts/EMAIL@gmail.com/full/2886fa4b0a791ec9")
org.kde.kgapi: KGAPI2::ContactModifyJob(0x55c3a1df1e40) Dispatching request to QUrl("https://www.google.com/m8/feeds/contacts/EMAIL@gmail.com/full/2886fa4b0a791ec9")
org.kde.pim.akonadicore: Deleting items from the akonadi database failed: "No items found"
org.kde.kgapi: Received reply from QUrl("https://www.google.com/m8/feeds/contacts/EMAIL@gmail.com/full/2886fa4b0a791ec9?prettyPrint=false")
org.kde.kgapi: Status code:  200
org.kde.kgapi: Queued QUrl("https://www.google.com/m8/feeds/photos/media/EMAIL@gmail.com/2886fa4b0a791ec9")
org.kde.kgapi: 1 requests in requestQueue.
org.kde.kgapi: KGAPI2::ContactModifyJob(0x55c3a1df1e40) Dispatching request to QUrl("https://www.google.com/m8/feeds/photos/media/EMAIL@gmail.com/2886fa4b0a791ec9")
org.kde.kgapi: Received reply from QUrl("https://www.google.com/m8/feeds/photos/media/EMAIL@gmail.com/2886fa4b0a791ec9")
org.kde.kgapi: Status code:  200

i.e. everything works just fine. Any ideas?

OK, it might actually be a KAddressBook issue. If I:

  1. Create a contact
  2. Press F.5 to update address book
  3. Modify contact

then everything works like charm. But without updating , KAB gets that weird contact ID god knows from where, and tries to change it.

dvratil added a comment.EditedMar 22 2020, 12:45 PM

There seems to be a confusion between remoteId and the vCard UID stored in the contact payload. The ItemModifyJob in changeComitted() only updates the Item's remoteId, it does not update the payload - the contact keeps the default UID generated by KAddressBook. The event returned by Google contains UID generated by Google, so we end up with a conflict.

So your initial patch was, in fact, correct. Please just add a comment explaining that we need to update the vCard UID stored in the payload.

poboiko updated this revision to Diff 78278.Mar 23 2020, 11:23 AM

Add comment explaining what's going on here

poboiko edited the summary of this revision. (Show Details)Mar 23 2020, 11:25 AM
poboiko edited the test plan for this revision. (Show Details)
dvratil accepted this revision.Mar 23 2020, 3:38 PM

Thanks!

This revision is now accepted and ready to land.Mar 23 2020, 3:38 PM
poboiko closed this revision.Mar 24 2020, 9:25 AM