summaryrefslogtreecommitdiff
path: root/common/src/leap/soledad/common/ddocs/syncs/updates/put.js
blob: 722f695a935d6af8f24a7c1773366cc5b75ff706 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
function(doc, req){
    if (!doc) {
        doc = {}
        doc['_id'] = 'u1db_sync_log';
        doc['syncs'] = [];
    }
    body = JSON.parse(req.body);
    // remove outdated info
    doc['syncs'] = doc['syncs'].filter(
        function (entry) {
            return entry[0] != body['other_replica_uid'];
        }
    );
    // store u1db rev
    doc['syncs'].push([
        body['other_replica_uid'],
        body['other_generation'],
        body['other_transaction_id']
    ]);
    return [doc, 'ok'];
}