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



commit 0f8b2418004025e8b48b89ec6115559910719b2b
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 |   27 ++++++++++++++++++++++++++-
 1 files changed, 26 insertions(+), 1 deletions(-)
---
diff --git a/src/sync/ephy-sync-service.c b/src/sync/ephy-sync-service.c
index 1aed452..2c335f8 100644
--- a/src/sync/ephy-sync-service.c
+++ b/src/sync/ephy-sync-service.c
@@ -1907,7 +1907,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;
 
@@ -1919,12 +1925,31 @@ 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_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]