diff --git a/src/gmail.js b/src/gmail.js index 284b7593..366b8414 100755 --- a/src/gmail.js +++ b/src/gmail.js @@ -3587,6 +3587,9 @@ var Gmail = function(localJQuery) { * @param email_id: new style email id. Legacy IDs not supported. If empty, default to latest in view. */ api.new.get.email_data = function(email_id) { + if (!email_id.statsWith("msg")) { + throw new Error("Legacy email-ID used in new API!"); + } email_id = email_id || api.new.get.email_id(); return api.cache.emailIdCache[email_id]; }; @@ -3597,6 +3600,10 @@ var Gmail = function(localJQuery) { * @param thread_id: new style thread id. Legacy IDs not supported. If empty, default to current. */ api.new.get.thread_data = function(thread_id) { + if (!thread_id.statsWith("thread")) { + throw new Error("Legacy email-ID used where new-type thread-id expected!"); + } + thread_id = thread_id || api.new.get.thread_id(); return api.cache.threadCache[thread_id]; }; diff --git a/test/test.new.js b/test/test.new.js new file mode 100644 index 00000000..655295cd --- /dev/null +++ b/test/test.new.js @@ -0,0 +1,28 @@ +"use strict"; +let assert = require('assert'); +let Gmail = require('../src/gmail').Gmail; +let gmail = new Gmail(); + +describe("gmail.new.get", () => { + it("email_data() rejects legacy-style IDs", () => { + let failed = false; + try { + let res = gmail.new.get.email_data("16a0d1f820d515e2"); + } catch (err) { + failed = true; + } + + assert.equal(true, failed); + }); + + it("thread_data() rejects legacy-style IDs", () => { + let failed = false; + try { + let res = gmail.new.get.thread_data("16a0d1f820d515e2"); + } catch (err) { + failed = true; + } + + assert.equal(true, failed); + }); +});