Bug 1318669 - Remove stripPrivateProps from blocklist-clients.js, r=mgoodwin
authorEthan Glasser-Camp <eglassercamp@mozilla.com>
Fri, 18 Nov 2016 10:07:39 -0500
changeset 323625 5bd73b7a3d61c5b557f3bfe0b64511378e95939b
parent 323624 43556298f164f98ea1decd3382dd70e86a5ca85c
child 323626 6a3911c19f7fd0ea8b679b7164740b19ee1dabbf
push id34477
push userryanvm@gmail.com
push dateMon, 21 Nov 2016 20:11:04 +0000
treeherderautoland@5bd73b7a3d61 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmgoodwin
bugs1318669
milestone53.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1318669 - Remove stripPrivateProps from blocklist-clients.js, r=mgoodwin MozReview-Commit-ID: 84yvzpBr3Q6
services/common/blocklist-clients.js
--- a/services/common/blocklist-clients.js
+++ b/services/common/blocklist-clients.js
@@ -37,31 +37,20 @@ const PREF_BLOCKLIST_GFX_CHECKED_SECONDS
 const PREF_BLOCKLIST_ENFORCE_SIGNING         = "services.blocklist.signing.enforced";
 
 const INVALID_SIGNATURE = "Invalid content/signature";
 
 this.FILENAME_ADDONS_JSON  = "blocklist-addons.json";
 this.FILENAME_GFX_JSON     = "blocklist-gfx.json";
 this.FILENAME_PLUGINS_JSON = "blocklist-plugins.json";
 
-function mergeChanges(localRecords, changes) {
-  // Kinto.js adds attributes to local records that aren't present on server.
-  // (e.g. _status)
-  const stripPrivateProps = (obj) => {
-    return Object.keys(obj).reduce((current, key) => {
-      if (!key.startsWith("_")) {
-        current[key] = obj[key];
-      }
-      return current;
-    }, {});
-  };
-
+function mergeChanges(collection, localRecords, changes) {
   const records = {};
   // Local records by id.
-  localRecords.forEach((record) => records[record.id] = stripPrivateProps(record));
+  localRecords.forEach((record) => records[record.id] = collection.cleanLocalFields(record));
   // All existing records are replaced by the version from the server.
   changes.forEach((record) => records[record.id] = record);
 
   return Object.values(records)
     // Filter out deleted records.
     .filter((record) => record.deleted != true)
     // Sort list by record id.
     .sort((a, b) => a.id < b.id ? -1 : a.id > b.id ? 1 : 0);
@@ -123,17 +112,17 @@ class BlocklistClient {
       let toSerialize;
       if (ignoreLocal) {
         toSerialize = {
           last_modified: `${payload.last_modified}`,
           data: payload.data
         };
       } else {
         const localRecords = (yield collection.list()).data;
-        const records = mergeChanges(localRecords, payload.changes);
+        const records = mergeChanges(collection, localRecords, payload.changes);
         toSerialize = {
           last_modified: `${payload.lastModified}`,
           data: records
         };
       }
 
       const serialized = CanonicalJSON.stringify(toSerialize);