From d96c31abf7dc9c81cacd13ef338a8f1164ad952d Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Tue, 27 May 2014 14:54:16 -0700 Subject: [PATCH] Remove stupid cycling UUID scheme. Instead, limit server-side pin deduping to a single instance. --- lib/models.py | 1 + static/cosmopolite.js | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/models.py b/lib/models.py index c026efd..7d7e794 100644 --- a/lib/models.py +++ b/lib/models.py @@ -230,6 +230,7 @@ class Subject(db.Model): Pin.all() .ancestor(subject) .filter('sender_message_id =', sender_message_id) + .filter('instance =', instance) .fetch(1)) if pins: raise DuplicateMessage(sender_message_id) diff --git a/static/cosmopolite.js b/static/cosmopolite.js index 8955684..c079f8c 100644 --- a/static/cosmopolite.js +++ b/static/cosmopolite.js @@ -403,9 +403,10 @@ Cosmopolite.prototype.pin = function(subject, message) { */ Cosmopolite.prototype.unpin = function(id) { return new Promise(function(resolve, reject) { + var pin = this.pins_[id]; var args = { - 'subject': this.pins_[id]['subject'], - 'sender_message_id': id, + 'subject': pin['subject'], + 'sender_message_id': pin['sender_message_id'], }; delete this.pins_[id]; @@ -768,7 +769,6 @@ Cosmopolite.prototype.onReconnect_ = function() { for (var id in this.pins_) { /** @type {typeMessage} */ var pin = this.pins_[id]; - pin['sender_message_id'] = this.uuid_(); rpcs.push({ 'command': 'pin', 'arguments': pin,