Commit 5ee73fdb authored by Igor Poboiko's avatar Igor Poboiko
Browse files

[contacts] Populate remoteId of newly created contact

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

Reviewers: dvratil

Reviewed By: dvratil

Subscribers: kde-pim

Tags: #kde_pim

Differential Revision: https://phabricator.kde.org/D28179
parent e68753a9
......@@ -523,6 +523,14 @@ void ContactsResource::slotCreateJobFinished(KGAPI2::Job *job)
item.setRemoteId(contact->uid());
item.setRemoteRevision(contact->etag());
changeCommitted(item);
/**
* An Addressee inside Akonadi DB has a default UID, which differs from
* one obtained from Google, so we end up having a confision between remoteId
* and UID. Since changeCommitted does not update the payload, we need to
* update it here explicitly.
*/
item.setPayload<KContacts::Addressee>(*contact.dynamicCast<KContacts::Addressee>());
new ItemModifyJob(item);
} else if (collection.isValid()) {
ContactsGroupCreateJob *createJob = qobject_cast<ContactsGroupCreateJob *>(job);
Q_ASSERT(createJob->items().count() == 1);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment