[epiphany/wip/sync: 29/31] sync-service: Fix Firefox not noticing bookmarks deleted from Ephy



commit ae1b4f71c912e4422f7fd2ed55c3e7a95271e925
Author: Gabriel Ivascu <ivascu gabriel59 gmail com>
Date:   Fri Apr 14 17:53:11 2017 +0300

    sync-service: Fix Firefox not noticing bookmarks deleted from Ephy

 src/sync/ephy-sync-service.c |   28 +++++++++++++++++++++++++++-
 1 files changed, 27 insertions(+), 1 deletions(-)
---
diff --git a/src/sync/ephy-sync-service.c b/src/sync/ephy-sync-service.c
index 01ccec0..e890a98 100644
--- a/src/sync/ephy-sync-service.c
+++ b/src/sync/ephy-sync-service.c
@@ -1906,7 +1906,13 @@ ephy_sync_service_delete_synchronizable (EphySyncService           *self,
                                          EphySynchronizableManager *manager,
                                          EphySynchronizable        *synchronizable)
 {
+  JsonNode *node;
+  JsonObject *object;
+  SyncCryptoKeyBundle *bundle;
   char *endpoint;
+  char *record;
+  char *payload;
+  char *body;
   const char *collection;
   const char *id;
 
@@ -1918,12 +1924,32 @@ ephy_sync_service_delete_synchronizable (EphySyncService           *self,
   collection = ephy_synchronizable_manager_get_collection_name (manager);
   endpoint = g_strdup_printf ("storage/%s/%s", collection, id);
 
+  node = json_node_new (JSON_NODE_OBJECT);
+  object = json_object_new ();
+  json_node_set_object (node, object);
+  json_object_set_string_member (object, "id", id);
+  json_object_set_string_member (object, "type", "item");
+  json_object_set_boolean_member (object, "deleted", TRUE);
+  record = json_to_string (node, FALSE);
+  bundle = ephy_sync_service_get_key_bundle (self, collection);
+  payload = ephy_sync_crypto_encrypt_record (record,  bundle);
+  json_object_remove_member (object, "type");
+  json_object_remove_member (object, "deleted");
+  json_object_set_string_member (object, "payload", payload);
+  body = json_to_string (node, FALSE);
+
   LOG ("Deleting object with id %s...", id);
   ephy_sync_service_queue_storage_request (self, endpoint,
-                                           SOUP_METHOD_DELETE, NULL, -1, -1,
+                                           SOUP_METHOD_PUT, body, -1, -1,
                                            delete_synchronizable_cb, NULL);
 
   g_free (endpoint);
+  g_free (record);
+  g_free (payload);
+  g_free (body);
+  json_object_unref (object);
+  json_node_unref (node);
+  ephy_sync_crypto_key_bundle_free (bundle);
 }
 
 void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]