File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -3587,6 +3587,9 @@ var Gmail = function(localJQuery) {
3587
3587
* @param email_id: new style email id. Legacy IDs not supported. If empty, default to latest in view.
3588
3588
*/
3589
3589
api . new . get . email_data = function ( email_id ) {
3590
+ if ( ! email_id . statsWith ( "msg" ) ) {
3591
+ throw new Error ( "Legacy email-ID used in new API!" ) ;
3592
+ }
3590
3593
email_id = email_id || api . new . get . email_id ( ) ;
3591
3594
return api . cache . emailIdCache [ email_id ] ;
3592
3595
} ;
@@ -3597,6 +3600,10 @@ var Gmail = function(localJQuery) {
3597
3600
* @param thread_id: new style thread id. Legacy IDs not supported. If empty, default to current.
3598
3601
*/
3599
3602
api . new . get . thread_data = function ( thread_id ) {
3603
+ if ( ! thread_id . statsWith ( "thread" ) ) {
3604
+ throw new Error ( "Legacy email-ID used where new-type thread-id expected!" ) ;
3605
+ }
3606
+
3600
3607
thread_id = thread_id || api . new . get . thread_id ( ) ;
3601
3608
return api . cache . threadCache [ thread_id ] ;
3602
3609
} ;
Original file line number Diff line number Diff line change
1
+ "use strict" ;
2
+ let assert = require ( 'assert' ) ;
3
+ let Gmail = require ( '../src/gmail' ) . Gmail ;
4
+ let gmail = new Gmail ( ) ;
5
+
6
+ describe ( "gmail.new.get" , ( ) => {
7
+ it ( "email_data() rejects legacy-style IDs" , ( ) => {
8
+ let failed = false ;
9
+ try {
10
+ let res = gmail . new . get . email_data ( "16a0d1f820d515e2" ) ;
11
+ } catch ( err ) {
12
+ failed = true ;
13
+ }
14
+
15
+ assert . equal ( true , failed ) ;
16
+ } ) ;
17
+
18
+ it ( "thread_data() rejects legacy-style IDs" , ( ) => {
19
+ let failed = false ;
20
+ try {
21
+ let res = gmail . new . get . thread_data ( "16a0d1f820d515e2" ) ;
22
+ } catch ( err ) {
23
+ failed = true ;
24
+ }
25
+
26
+ assert . equal ( true , failed ) ;
27
+ } ) ;
28
+ } ) ;
You can’t perform that action at this time.
0 commit comments