From 08f6886f3e2e45d16fa2bea266ee3c5d987d6f91 Mon Sep 17 00:00:00 2001 From: Daniel Gasienica Date: Tue, 27 Mar 2018 19:00:25 -0400 Subject: [PATCH] Strengthen precondition of `ConversationController.getOrCreate` --- js/conversation_controller.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/js/conversation_controller.js b/js/conversation_controller.js index a8bae8511..05c6dc658 100644 --- a/js/conversation_controller.js +++ b/js/conversation_controller.js @@ -99,6 +99,14 @@ return conversations.add(attributes); }, getOrCreate: function(id, type) { + if (typeof id !== 'string') { + throw new TypeError('"id" must be a string'); + } + + if (type !== 'private' && type !== 'group') { + throw new TypeError('"type" must be "private" or "group"; got: ' + type); + } + if (!this._initialFetchComplete) { throw new Error('ConversationController.get() needs complete initial fetch'); }