@@ -195,19 +195,17 @@ int32_t check_camel_msg_id(uint32_t folder_id, stringer_t *cookie, bool_t secure
195
195
int32_t msg_id = -1 ;
196
196
stringer_t * command = NULL , * json = NULL ;
197
197
json_t * json_root = NULL , * json_array = NULL , * json_cursor = NULL ;
198
- chr_t * messages_list = "{\"id\":2,\"method\":\"messages.list\",\"params\":{\"folderID\":%u}}" ;
198
+ chr_t * messages_list = "{\"id\":2,\"method\":\"messages.list\",\"params\":{\"folderID\":%u, \"limit\":1 }}" ;
199
199
200
200
// Contruct the command string.
201
201
if (!(command = st_alloc (ns_length_get (messages_list ) - 2 + uint32_digits (folder_id ) + 1 )) ||
202
202
st_sprint (command , messages_list , folder_id ) == -1 ) {
203
-
204
203
st_cleanup (command );
205
204
return msg_id ;
206
205
}
207
206
// Query for the contents of the folder.
208
207
else if (!(json = check_camel_print (command , cookie , secure )) || !(json_root = json_loads_d (st_char_get (json ), 0 , & err )) ||
209
208
!(json_array = json_object_get_d (json_root , "result" ))) {
210
-
211
209
if (json_root ) json_decref_d (json_root );
212
210
st_cleanup (command , json );
213
211
return msg_id ;
@@ -216,7 +214,6 @@ int32_t check_camel_msg_id(uint32_t folder_id, stringer_t *cookie, bool_t secure
216
214
// If the folder contains mail, return the messageID of the first message.
217
215
if (json_array_size_d (json_array ) <= 0 || !(json_cursor = json_array_get_d (json_array , 0 )) ||
218
216
json_unpack_d (json_cursor , "{s:i}" , "messageID" , & msg_id ) != 0 ) {
219
-
220
217
msg_id = -1 ;
221
218
}
222
219
@@ -379,8 +376,8 @@ bool_t check_camel_basic_sthread(bool_t secure, stringer_t *errmsg) {
379
376
/// Test config.edit : {"id":2,"method":"config.edit","params":{<rand_strs[0]>:<rand_strs[1]>}}"
380
377
/// Expected Response : {"jsonrpc":"2.0","result":{"config.edit":"success"},"id":2}
381
378
382
- // Set the current command string.
383
- chr_command = "{\"id\":2,\"method\":\"config.edit\",\"params\":{\"%.*s\":\"%.*s\"}}" ;
379
+ // Set the current command string.
380
+ chr_command = "{\"id\":2,\"method\":\"config.edit\",\"params\":{\"%.*s\":\"%.*s\"}}" ;
384
381
385
382
// Generate the random inputs for "key" and "value".
386
383
if (!rand_choices (choices , 64 , rand_strs [0 ]) || !rand_choices (choices , 64 , rand_strs [1 ])) {
@@ -2423,8 +2420,7 @@ bool_t check_camel_basic_sthread(bool_t secure, stringer_t *errmsg) {
2423
2420
// Retrieve the folderID of Inbox and a messageID.
2424
2421
if ((folder_ids [0 ] = check_camel_folder_id (PLACER ("Inbox" , 5 ), cookie , secure )) == -1 ||
2425
2422
(message_ids [0 ] = check_camel_msg_id (folder_ids [0 ], cookie , secure )) == -1 ) {
2426
-
2427
- st_sprint (errmsg , "Failed to retrieve the folderID of Inbox or Inbox is empty. { command # = 41 }" );
2423
+ st_sprint (errmsg , "Failed to retrieve the folderID of the Inbox or the Inbox is empty. { command # = 41 }" );
2428
2424
return false;
2429
2425
}
2430
2426
@@ -2484,8 +2480,7 @@ bool_t check_camel_basic_sthread(bool_t secure, stringer_t *errmsg) {
2484
2480
// Retrieve the folderID of Inbox and a messageID.
2485
2481
if ((folder_ids [0 ] = check_camel_folder_id (PLACER ("Inbox" , 5 ), cookie , secure )) == -1 ||
2486
2482
(message_ids [0 ] = check_camel_msg_id (folder_ids [0 ], cookie , secure )) == -1 ) {
2487
-
2488
- st_sprint (errmsg , "Failed to retrieve the folderID of Inbox or Inbox is empty. { command # = 42 }" );
2483
+ st_sprint (errmsg , "Failed to retrieve the folderID of the Inbox or the Inbox is empty. { command # = 42 }" );
2489
2484
return false;
2490
2485
}
2491
2486
@@ -2588,8 +2583,8 @@ bool_t check_camel_basic_sthread(bool_t secure, stringer_t *errmsg) {
2588
2583
// Test folders.add : {"id":46,"method":"folders.add","params":{"context":"mail","name":<rand_strs[0]>}}
2589
2584
// Expected Response : {"jsonrpc":"2.0","result":{"folderID":<folder_ids[0]>},"id":46}
2590
2585
2591
- // Set the current command string.
2592
- chr_command = "{\"id\":46,\"method\":\"folders.add\",\"params\":{\"context\":\"mail\",\"name\":\"%.*s\"}}" ;
2586
+ // Set the current command string.
2587
+ chr_command = "{\"id\":46,\"method\":\"folders.add\",\"params\":{\"context\":\"mail\",\"name\":\"%.*s\"}}" ;
2593
2588
2594
2589
// Generate the random input for "name".
2595
2590
if (!rand_choices (choices , 16 , rand_strs [0 ])) {
@@ -2646,7 +2641,7 @@ bool_t check_camel_basic_sthread(bool_t secure, stringer_t *errmsg) {
2646
2641
if ((folder_ids[1] = check_camel_folder_id(PLACER("Inbox", 5), cookie, secure)) == -1 ||
2647
2642
(message_ids[0] = check_camel_msg_id(folder_ids[1], cookie, secure)) == -1) {
2648
2643
2649
- st_sprint(errmsg, "Failed to retrieve the folderID of Inbox or Inbox is empty. { command # = 45 }");
2644
+ st_sprint(errmsg, "Failed to retrieve the folderID of the Inbox or the Inbox is empty. { command # = 45 }");
2650
2645
return false;
2651
2646
}
2652
2647
@@ -2691,14 +2686,13 @@ bool_t check_camel_basic_sthread(bool_t secure, stringer_t *errmsg) {
2691
2686
// "targetFolderID":<folder_ids[0]>}}",
2692
2687
// Expected Response : {"jsonrpc":"2.0","result":[],"id":48}
2693
2688
2694
- // Set the current command string.
2695
- chr_command = "{\"id\":48,\"method\":\"messages.copy\",\"params\":{\"messageIDs\":[%lu],\"sourceFolderID\":%lu,\"targetFolderID\":%lu}}" ;
2689
+ // Set the current command string.
2690
+ chr_command = "{\"id\":48,\"method\":\"messages.copy\",\"params\":{\"messageIDs\":[%lu],\"sourceFolderID\":%lu,\"targetFolderID\":%lu}}" ;
2696
2691
2697
2692
// Retrieve the folderID of Inbox and a messageID.
2698
2693
if ((folder_ids [1 ] = check_camel_folder_id (PLACER ("Inbox" , 5 ), cookie , secure )) == -1 ||
2699
2694
(message_ids [0 ] = check_camel_msg_id (folder_ids [1 ], cookie , secure )) == -1 ) {
2700
-
2701
- st_sprint (errmsg , "Failed to retrieve the folderID of Inbox or Inbox is empty. { command # = 46 }" );
2695
+ st_sprint (errmsg , "Failed to retrieve the folderID of the Inbox or the Inbox is empty. { command # = 46 }" );
2702
2696
return false;
2703
2697
}
2704
2698
@@ -2750,8 +2744,8 @@ bool_t check_camel_basic_sthread(bool_t secure, stringer_t *errmsg) {
2750
2744
// Test folders.remove : {"id":49,"method":"folders.remove","params":{"context":"contacts","folderID":<folder_ids[0]>}}",
2751
2745
// Expected Response : {"jsonrpc":"2.0","result":{"folder.remove":"success"},"id":49}
2752
2746
2753
- // Set the current command string.
2754
- chr_command = "{\"id\":49,\"method\":\"folders.remove\",\"params\":{\"context\":\"mail\",\"folderID\":%lu}}" ;
2747
+ // Set the current command string.
2748
+ chr_command = "{\"id\":49,\"method\":\"folders.remove\",\"params\":{\"context\":\"mail\",\"folderID\":%lu}}" ;
2755
2749
2756
2750
// Construct the command string.
2757
2751
if (!(st_sprint (command , chr_command , folder_ids [0 ]))) {
@@ -2802,14 +2796,14 @@ bool_t check_camel_basic_sthread(bool_t secure, stringer_t *errmsg) {
2802
2796
// "messageIDs":[<message_ids[0]>], "folderID":<folder_ids[0]>}}
2803
2797
// Expected Response : {"jsonrpc":"2.0","result":{"messages.flag":"success"},"id":50}
2804
2798
2805
- // Set the current command string.
2806
- chr_command = "{\"id\":50,\"method\":\"messages.flag\",\"params\":{\"action\":\"add\",\"flags\":[\"flagged\"],\"messageIDs\":[%lu],\"folderID\":%lu}}" ;
2799
+ // Set the current command string.
2800
+ chr_command = "{\"id\":50,\"method\":\"messages.flag\",\"params\":{\"action\":\"add\",\"flags\":[\"flagged\"],\"messageIDs\":[%lu],\"folderID\":%lu}}" ;
2807
2801
2808
2802
// Retrieve the folderID of Inbox and a messageID.
2809
2803
if ((folder_ids [0 ] = check_camel_folder_id (PLACER ("Inbox" , 5 ), cookie , secure )) == -1 ||
2810
2804
(message_ids [0 ] = check_camel_msg_id (folder_ids [0 ], cookie , secure )) == -1 ) {
2811
2805
2812
- st_sprint (errmsg , "Failed to retrieve the folderID of Inbox or Inbox is empty. { command # = 48 }" );
2806
+ st_sprint (errmsg , "Failed to retrieve the folderID of the Inbox or the Inbox is empty. { command # = 48 }" );
2813
2807
return false;
2814
2808
}
2815
2809
@@ -2822,7 +2816,6 @@ bool_t check_camel_basic_sthread(bool_t secure, stringer_t *errmsg) {
2822
2816
2823
2817
// Submit the command and check the status of the response.
2824
2818
else if (!(json = check_camel_print (command , cookie , secure ))) {
2825
-
2826
2819
st_sprint (errmsg , "Failed to return a successful HTTP response. { command = %.*s }" , st_length_int (command ),
2827
2820
st_char_get (command ));
2828
2821
return false;
@@ -2841,7 +2834,6 @@ bool_t check_camel_basic_sthread(bool_t secure, stringer_t *errmsg) {
2841
2834
2842
2835
// Check if the returned JSON is correct.
2843
2836
else if (st_cmp_cs_eq (NULLER ((chr_t * )json_values [0 ]), PLACER ("success" , 7 ))) {
2844
-
2845
2837
st_sprint (errmsg , "Failed parsing the returned JSON. { command = %.*s, json = %.*s }" , st_length_int (command ),
2846
2838
st_char_get (command ), st_length_int (json ), st_char_get (json ));
2847
2839
json_decref_d (json_objs [0 ]);
@@ -2871,7 +2863,7 @@ bool_t check_camel_basic_sthread(bool_t secure, stringer_t *errmsg) {
2871
2863
if ((folder_ids[0] = check_camel_folder_id(PLACER("Inbox", 5), cookie, secure)) == -1 ||
2872
2864
(message_ids[0] = check_camel_msg_id(folder_ids[0], cookie, secure)) == -1) {
2873
2865
2874
- st_sprint(errmsg, "Failed to retrieve the folderID of Inbox or Inbox is empty. { command # = 49 }");
2866
+ st_sprint(errmsg, "Failed to retrieve the folderID of the Inbox or the Inbox is empty. { command # = 49 }");
2875
2867
return false;
2876
2868
}
2877
2869
@@ -2924,14 +2916,14 @@ bool_t check_camel_basic_sthread(bool_t secure, stringer_t *errmsg) {
2924
2916
// "folderID":<folder_ids[0]>}}
2925
2917
// Expected Response : {"jsonrpc":"2.0","result":[ { an object matching messageID[0] }, ... ],"id":52}
2926
2918
2927
- // Set the current command string.
2928
- chr_command = "{\"id\":52,\"method\":\"messages.flag\",\"params\":{\"action\":\"list\",\"messageIDs\":[%lu],\"folderID\":%lu}}" ;
2919
+ // Set the current command string.
2920
+ chr_command = "{\"id\":52,\"method\":\"messages.flag\",\"params\":{\"action\":\"list\",\"messageIDs\":[%lu],\"folderID\":%lu}}" ;
2929
2921
2930
2922
// Retrieve the folderID of Inbox and a messageID.
2931
2923
if ((folder_ids [0 ] = check_camel_folder_id (PLACER ("Inbox" , 5 ), cookie , secure )) == -1 ||
2932
2924
(message_ids [0 ] = check_camel_msg_id (folder_ids [0 ], cookie , secure )) == -1 ) {
2933
2925
2934
- st_sprint (errmsg , "Failed to retrieve the folderID of Inbox or Inbox is empty. { command # = 50 }" );
2926
+ st_sprint (errmsg , "Failed to retrieve the folderID of the Inbox or the Inbox is empty. { command # = 50 }" );
2935
2927
return false;
2936
2928
}
2937
2929
@@ -2992,7 +2984,7 @@ bool_t check_camel_basic_sthread(bool_t secure, stringer_t *errmsg) {
2992
2984
if ((folder_ids[0] = check_camel_folder_id(PLACER("Inbox", 5), cookie, secure)) == -1 ||
2993
2985
(message_ids[0] = check_camel_msg_id(folder_ids[0], cookie, secure)) == -1) {
2994
2986
2995
- st_sprint(errmsg, "Failed to retrieve the folderID of Inbox or Inbox is empty. { command # = 51 }");
2987
+ st_sprint(errmsg, "Failed to retrieve the folderID of the Inbox or the Inbox is empty. { command # = 51 }");
2996
2988
return false;
2997
2989
}
2998
2990
@@ -3035,20 +3027,18 @@ bool_t check_camel_basic_sthread(bool_t secure, stringer_t *errmsg) {
3035
3027
// Test messages.list : {"id":54,"method":"messages.list","params":{"folderID":<folder_ids[0]>}}",
3036
3028
// Expected Response : {"jsonrpc":"2.0","result":{"messages.flag":"success"},"id":54}
3037
3029
3038
- // Set the current command string.
3039
- chr_command = "{\"id\":54,\"method\":\"messages.list\",\"params\":{\"folderID\":%lu}}" ;
3030
+ // Set the current command string.
3031
+ chr_command = "{\"id\":54,\"method\":\"messages.list\",\"params\":{\"folderID\":%lu}}" ;
3040
3032
3041
3033
// Retrieve the folderID of Inbox and a messageID.
3042
3034
if ((folder_ids [0 ] = check_camel_folder_id (PLACER ("Inbox" , 5 ), cookie , secure )) == -1 ||
3043
3035
(message_ids [0 ] = check_camel_msg_id (folder_ids [0 ], cookie , secure )) == -1 ) {
3044
-
3045
- st_sprint (errmsg , "Failed to retrieve the folderID of Inbox or Inbox is empty. { command # = 52 }" );
3036
+ st_sprint (errmsg , "Failed to retrieve the folderID of the Inbox or the Inbox is empty. { command # = 52 }" );
3046
3037
return false;
3047
3038
}
3048
3039
3049
3040
// Construct the command string.
3050
3041
if (!(st_sprint (command , chr_command , folder_ids [0 ]))) {
3051
-
3052
3042
st_sprint (errmsg , "Failed to create command string. { command # = 52 }" );
3053
3043
return false;
3054
3044
}
@@ -3084,13 +3074,13 @@ bool_t check_camel_basic_sthread(bool_t secure, stringer_t *errmsg) {
3084
3074
// Test messages.list : {"id":55,"method":"messages.list","params":{"context":"mail","folderID":<folder_ids[0]>}}",
3085
3075
// Expected Response : {"jsonrpc":"2.0","result":{"messages.flag":"success"},"id":55}
3086
3076
3087
- // Set the current command string.
3088
- chr_command = "{\"id\":55,\"method\":\"folders.tags\",\"params\":{\"context\":\"mail\",\"folderID\":%lu}}" ;
3077
+ // Set the current command string.
3078
+ chr_command = "{\"id\":55,\"method\":\"folders.tags\",\"params\":{\"context\":\"mail\",\"folderID\":%lu}}" ;
3089
3079
3090
3080
// Retrieve the folderID of Inbox.
3091
3081
if ((folder_ids [0 ] = check_camel_folder_id (PLACER ("Inbox" , 5 ), cookie , secure )) == -1 ) {
3092
3082
3093
- st_sprint (errmsg , "Failed to retrieve the folderID of Inbox or Inbox is empty. { command # = 53 }" );
3083
+ st_sprint (errmsg , "Failed to retrieve the folderID of the Inbox or the Inbox is empty. { command # = 53 }" );
3094
3084
return false;
3095
3085
}
3096
3086
@@ -3188,8 +3178,7 @@ bool_t check_camel_basic_sthread(bool_t secure, stringer_t *errmsg) {
3188
3178
// Retrieve the folderID of Inbox and a messageID.
3189
3179
if ((folder_ids [0 ] = check_camel_folder_id (PLACER ("Inbox" , 5 ), cookie , secure )) == -1 ||
3190
3180
(message_ids [0 ] = check_camel_msg_id (folder_ids [0 ], cookie , secure )) == -1 ) {
3191
-
3192
- st_sprint (errmsg , "Failed to retrieve the folderID of Inbox or Inbox is empty. { command # = 55 }" );
3181
+ st_sprint (errmsg , "Failed to retrieve the folderID of the Inbox or the Inbox is empty. { command # = 55 }" );
3193
3182
return false;
3194
3183
}
3195
3184
0 commit comments