Skip to content

Commit 788a39a

Browse files
committed
Added a start and limit params to messages.list camelface function.
1 parent e700913 commit 788a39a

File tree

5 files changed

+81
-50
lines changed

5 files changed

+81
-50
lines changed

check/magma/servers/camel/camel_check.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,6 @@ START_TEST (check_camel_basic_s) {
416416
}
417417
END_TEST
418418

419-
420419
Suite * suite_check_camel(void) {
421420

422421
Suite *s = suite_create("\tCAMEL");
@@ -429,7 +428,7 @@ Suite * suite_check_camel(void) {
429428
// which has significantly more overhead for each allocate/free oepration. As a result we give the camelface
430429
// tests twice as much time to complete when applicable. (The timeout is disabled when a debugger, or profiler
431430
// is in use.)
432-
suite_check_testcase_timeout(s, "HTTP CAMEL", "HTTP Network Camel Basic/S", check_camel_basic_s, ( case_timeout * 2 ));
431+
suite_check_testcase_timeout(s, "HTTP CAMEL", "HTTP Network Camel Basic/S", check_camel_basic_s, ( case_timeout * 4 ));
433432

434433
return s;
435434
}

check/magma/servers/camel/camel_check_network.c

+28-39
Original file line numberDiff line numberDiff line change
@@ -195,19 +195,17 @@ int32_t check_camel_msg_id(uint32_t folder_id, stringer_t *cookie, bool_t secure
195195
int32_t msg_id = -1;
196196
stringer_t *command = NULL, *json = NULL;
197197
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}}";
199199

200200
// Contruct the command string.
201201
if (!(command = st_alloc(ns_length_get(messages_list) - 2 + uint32_digits(folder_id) + 1)) ||
202202
st_sprint(command, messages_list, folder_id) == -1) {
203-
204203
st_cleanup(command);
205204
return msg_id;
206205
}
207206
// Query for the contents of the folder.
208207
else if (!(json = check_camel_print(command, cookie, secure)) || !(json_root = json_loads_d(st_char_get(json), 0, &err)) ||
209208
!(json_array = json_object_get_d(json_root, "result"))) {
210-
211209
if (json_root) json_decref_d(json_root);
212210
st_cleanup(command, json);
213211
return msg_id;
@@ -216,7 +214,6 @@ int32_t check_camel_msg_id(uint32_t folder_id, stringer_t *cookie, bool_t secure
216214
// If the folder contains mail, return the messageID of the first message.
217215
if (json_array_size_d(json_array) <= 0 || !(json_cursor = json_array_get_d(json_array, 0)) ||
218216
json_unpack_d(json_cursor, "{s:i}", "messageID", &msg_id) != 0) {
219-
220217
msg_id = -1;
221218
}
222219

@@ -379,8 +376,8 @@ bool_t check_camel_basic_sthread(bool_t secure, stringer_t *errmsg) {
379376
/// Test config.edit : {"id":2,"method":"config.edit","params":{<rand_strs[0]>:<rand_strs[1]>}}"
380377
/// Expected Response : {"jsonrpc":"2.0","result":{"config.edit":"success"},"id":2}
381378

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\"}}";
384381

385382
// Generate the random inputs for "key" and "value".
386383
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) {
24232420
// Retrieve the folderID of Inbox and a messageID.
24242421
if ((folder_ids[0] = check_camel_folder_id(PLACER("Inbox", 5), cookie, secure)) == -1 ||
24252422
(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 }");
24282424
return false;
24292425
}
24302426

@@ -2484,8 +2480,7 @@ bool_t check_camel_basic_sthread(bool_t secure, stringer_t *errmsg) {
24842480
// Retrieve the folderID of Inbox and a messageID.
24852481
if ((folder_ids[0] = check_camel_folder_id(PLACER("Inbox", 5), cookie, secure)) == -1 ||
24862482
(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 }");
24892484
return false;
24902485
}
24912486

@@ -2588,8 +2583,8 @@ bool_t check_camel_basic_sthread(bool_t secure, stringer_t *errmsg) {
25882583
// Test folders.add : {"id":46,"method":"folders.add","params":{"context":"mail","name":<rand_strs[0]>}}
25892584
// Expected Response : {"jsonrpc":"2.0","result":{"folderID":<folder_ids[0]>},"id":46}
25902585

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\"}}";
25932588

25942589
// Generate the random input for "name".
25952590
if (!rand_choices(choices, 16, rand_strs[0])) {
@@ -2646,7 +2641,7 @@ bool_t check_camel_basic_sthread(bool_t secure, stringer_t *errmsg) {
26462641
if ((folder_ids[1] = check_camel_folder_id(PLACER("Inbox", 5), cookie, secure)) == -1 ||
26472642
(message_ids[0] = check_camel_msg_id(folder_ids[1], cookie, secure)) == -1) {
26482643
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 }");
26502645
return false;
26512646
}
26522647
@@ -2691,14 +2686,13 @@ bool_t check_camel_basic_sthread(bool_t secure, stringer_t *errmsg) {
26912686
// "targetFolderID":<folder_ids[0]>}}",
26922687
// Expected Response : {"jsonrpc":"2.0","result":[],"id":48}
26932688

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}}";
26962691

26972692
// Retrieve the folderID of Inbox and a messageID.
26982693
if ((folder_ids[1] = check_camel_folder_id(PLACER("Inbox", 5), cookie, secure)) == -1 ||
26992694
(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 }");
27022696
return false;
27032697
}
27042698

@@ -2750,8 +2744,8 @@ bool_t check_camel_basic_sthread(bool_t secure, stringer_t *errmsg) {
27502744
// Test folders.remove : {"id":49,"method":"folders.remove","params":{"context":"contacts","folderID":<folder_ids[0]>}}",
27512745
// Expected Response : {"jsonrpc":"2.0","result":{"folder.remove":"success"},"id":49}
27522746

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}}";
27552749

27562750
// Construct the command string.
27572751
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) {
28022796
// "messageIDs":[<message_ids[0]>], "folderID":<folder_ids[0]>}}
28032797
// Expected Response : {"jsonrpc":"2.0","result":{"messages.flag":"success"},"id":50}
28042798

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}}";
28072801

28082802
// Retrieve the folderID of Inbox and a messageID.
28092803
if ((folder_ids[0] = check_camel_folder_id(PLACER("Inbox", 5), cookie, secure)) == -1 ||
28102804
(message_ids[0] = check_camel_msg_id(folder_ids[0], cookie, secure)) == -1) {
28112805

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 }");
28132807
return false;
28142808
}
28152809

@@ -2822,7 +2816,6 @@ bool_t check_camel_basic_sthread(bool_t secure, stringer_t *errmsg) {
28222816

28232817
// Submit the command and check the status of the response.
28242818
else if (!(json = check_camel_print(command, cookie, secure))) {
2825-
28262819
st_sprint(errmsg, "Failed to return a successful HTTP response. { command = %.*s }", st_length_int(command),
28272820
st_char_get(command));
28282821
return false;
@@ -2841,7 +2834,6 @@ bool_t check_camel_basic_sthread(bool_t secure, stringer_t *errmsg) {
28412834

28422835
// Check if the returned JSON is correct.
28432836
else if (st_cmp_cs_eq(NULLER((chr_t *)json_values[0]), PLACER("success", 7))) {
2844-
28452837
st_sprint(errmsg, "Failed parsing the returned JSON. { command = %.*s, json = %.*s }", st_length_int(command),
28462838
st_char_get(command), st_length_int(json), st_char_get(json));
28472839
json_decref_d(json_objs[0]);
@@ -2871,7 +2863,7 @@ bool_t check_camel_basic_sthread(bool_t secure, stringer_t *errmsg) {
28712863
if ((folder_ids[0] = check_camel_folder_id(PLACER("Inbox", 5), cookie, secure)) == -1 ||
28722864
(message_ids[0] = check_camel_msg_id(folder_ids[0], cookie, secure)) == -1) {
28732865
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 }");
28752867
return false;
28762868
}
28772869
@@ -2924,14 +2916,14 @@ bool_t check_camel_basic_sthread(bool_t secure, stringer_t *errmsg) {
29242916
// "folderID":<folder_ids[0]>}}
29252917
// Expected Response : {"jsonrpc":"2.0","result":[ { an object matching messageID[0] }, ... ],"id":52}
29262918

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}}";
29292921

29302922
// Retrieve the folderID of Inbox and a messageID.
29312923
if ((folder_ids[0] = check_camel_folder_id(PLACER("Inbox", 5), cookie, secure)) == -1 ||
29322924
(message_ids[0] = check_camel_msg_id(folder_ids[0], cookie, secure)) == -1) {
29332925

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 }");
29352927
return false;
29362928
}
29372929

@@ -2992,7 +2984,7 @@ bool_t check_camel_basic_sthread(bool_t secure, stringer_t *errmsg) {
29922984
if ((folder_ids[0] = check_camel_folder_id(PLACER("Inbox", 5), cookie, secure)) == -1 ||
29932985
(message_ids[0] = check_camel_msg_id(folder_ids[0], cookie, secure)) == -1) {
29942986
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 }");
29962988
return false;
29972989
}
29982990
@@ -3035,20 +3027,18 @@ bool_t check_camel_basic_sthread(bool_t secure, stringer_t *errmsg) {
30353027
// Test messages.list : {"id":54,"method":"messages.list","params":{"folderID":<folder_ids[0]>}}",
30363028
// Expected Response : {"jsonrpc":"2.0","result":{"messages.flag":"success"},"id":54}
30373029

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}}";
30403032

30413033
// Retrieve the folderID of Inbox and a messageID.
30423034
if ((folder_ids[0] = check_camel_folder_id(PLACER("Inbox", 5), cookie, secure)) == -1 ||
30433035
(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 }");
30463037
return false;
30473038
}
30483039

30493040
// Construct the command string.
30503041
if (!(st_sprint(command, chr_command, folder_ids[0]))) {
3051-
30523042
st_sprint(errmsg, "Failed to create command string. { command # = 52 }");
30533043
return false;
30543044
}
@@ -3084,13 +3074,13 @@ bool_t check_camel_basic_sthread(bool_t secure, stringer_t *errmsg) {
30843074
// Test messages.list : {"id":55,"method":"messages.list","params":{"context":"mail","folderID":<folder_ids[0]>}}",
30853075
// Expected Response : {"jsonrpc":"2.0","result":{"messages.flag":"success"},"id":55}
30863076

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}}";
30893079

30903080
// Retrieve the folderID of Inbox.
30913081
if ((folder_ids[0] = check_camel_folder_id(PLACER("Inbox", 5), cookie, secure)) == -1) {
30923082

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 }");
30943084
return false;
30953085
}
30963086

@@ -3188,8 +3178,7 @@ bool_t check_camel_basic_sthread(bool_t secure, stringer_t *errmsg) {
31883178
// Retrieve the folderID of Inbox and a messageID.
31893179
if ((folder_ids[0] = check_camel_folder_id(PLACER("Inbox", 5), cookie, secure)) == -1 ||
31903180
(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 }");
31933182
return false;
31943183
}
31953184

src/engine/controller/queue.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ void queue_signal(void) {
136136

137137
for (uint64_t i = 0; queue.workers && i < magma.system.worker_threads; i++) {
138138

139-
if (queue.workers + i && (ret = thread_signal(*(queue.workers + i), SIGALRM))) {
139+
// Don't bother logging errors if the process is already shutting down.
140+
if (queue.workers + i && (ret = thread_signal(*(queue.workers + i), SIGALRM)) && status()) {
140141
log_info("Unable to signal the worker thread. {ret = %i}", ret);
141142
}
142143

src/web/portal/endpoint.c

+42-8
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,8 @@ void portal_endpoint_alert_acknowledge(connection_t *con) {
458458
(int)st_length_get(con->http.session->user->username), st_char_get(con->http.session->user->username), err.text);
459459
portal_endpoint_error(con, 400, JSON_RPC_2_ERROR_SERVER_METHOD_PARAMS, "Invalid method parameters.");
460460
return;
461-
} else if (!json_is_array(alerts)) {
461+
}
462+
else if (!json_is_array(alerts)) {
462463
portal_endpoint_error(con, 400, JSON_RPC_2_ERROR_SERVER_METHOD_PARAMS, "Invalid method parameters.");
463464
return;
464465
}
@@ -597,7 +598,7 @@ void portal_endpoint_folders_add(connection_t *con) {
597598
return;
598599
}
599600
// Validate the request format and extract the submitted values.
600-
if ((count = json_object_size_d(con->http.portal.params)) && (count > 3 || count < 2)) {
601+
else if ((count = json_object_size_d(con->http.portal.params)) && (count > 3 || count < 2)) {
601602
log_pedantic("Received invalid portal folder add request parameters { user = %.*s, count = %u }",
602603
(int)st_length_get(con->http.session->user->username), st_char_get(con->http.session->user->username), (unsigned int) count);
603604
portal_endpoint_error(con, 400, JSON_RPC_2_ERROR_SERVER_METHOD_PARAMS, "Invalid method parameters.");
@@ -989,19 +990,42 @@ void portal_endpoint_folders_tags(connection_t *con) {
989990
*/
990991
void portal_endpoint_messages_list(connection_t *con) {
991992

992-
json_error_t err;;
993+
json_error_t err;
993994
json_t *tags, *list, *entry;
994995
inx_cursor_t *cursor;
995996
meta_message_t *active;
996-
uint64_t foldernum, count;
997+
uint64_t foldernum, count, current = 0, start = 0, limit = 0;
997998
stringer_t *header, *fields[8];
998999

1000+
// if ((count = json_object_size_d(con->http.portal.params)) && (count > 3 || count < 2)) {
1001+
// log_pedantic("Received invalid portal folder add request parameters { user = %.*s, count = %u }",
1002+
// (int)st_length_get(con->http.session->user->username), st_char_get(con->http.session->user->username), (unsigned int) count);
1003+
// portal_endpoint_error(con, 400, JSON_RPC_2_ERROR_SERVER_METHOD_PARAMS, "Invalid method parameters.");
1004+
// return;
1005+
// }
1006+
// else if ((count == 2 && json_unpack_ex_d(con->http.portal.params, &err, JSON_STRICT, "{s:s, s:s}", "context", &method, "name", &name)) ||
1007+
// (count == 3 && json_unpack_ex_d(con->http.portal.params, &err, JSON_STRICT, "{s:s, s:s, s:I}", "context", &method, "name", &name, "parentID", &parent))) {
1008+
// log_pedantic("Received invalid portal folder add request parameters { user = %.*s, errmsg = %s }",
1009+
// (int)st_length_get(con->http.session->user->username), st_char_get(con->http.session->user->username), err.text);
1010+
// portal_endpoint_error(con, 400, JSON_RPC_2_ERROR_SERVER_METHOD_PARAMS, "Invalid method parameters.");
1011+
// return;
1012+
// }
9991013
// Check the session state. Method has 1 parameter.
1000-
if (!portal_validate_request (con, PORTAL_ENDPOINT_ERROR_MESSAGES_LIST, "messages.list", true, 1)) {
1014+
if (!portal_validate_request (con, PORTAL_ENDPOINT_ERROR_MESSAGES_LIST, "messages.list", true, 0)) {
10011015
return;
10021016
}
10031017
// Validate the request format and extract the submitted values.
1004-
else if (json_unpack_ex_d(con->http.portal.params, &err, JSON_STRICT, "{s:I}", "folderID", &foldernum)) {
1018+
else if ((count = json_object_size_d(con->http.portal.params)) && (count < 1 || count > 3)) {
1019+
log_pedantic("Received invalid portal messages list request parameters { user = %.*s, count = %u }",
1020+
(int)st_length_get(con->http.session->user->username), st_char_get(con->http.session->user->username), (unsigned int) count);
1021+
portal_endpoint_error(con, 400, JSON_RPC_2_ERROR_SERVER_METHOD_PARAMS, "Invalid method parameters.");
1022+
return;
1023+
}
1024+
// Validate the request format and extract the submitted values.
1025+
else if ((count == 1 && json_unpack_ex_d(con->http.portal.params, &err, JSON_STRICT, "{s:I}", "folderID", &foldernum)) ||
1026+
(count == 2 && json_unpack_ex_d(con->http.portal.params, &err, JSON_STRICT, "{s:I, s:I}", "folderID", &foldernum, "start", &start) &&
1027+
json_unpack_ex_d(con->http.portal.params, &err, JSON_STRICT, "{s:I, s:I}", "folderID", &foldernum, "limit", &limit)) ||
1028+
(count == 3 && json_unpack_ex_d(con->http.portal.params, &err, JSON_STRICT, "{s:I, s:I, s:I}", "folderID", &foldernum, "start", &start, "limit", &limit))) {
10051029
log_pedantic("Received invalid portal messages list request parameters { user = %.*s, errmsg = %s }",
10061030
(int)st_length_get(con->http.session->user->username), st_char_get(con->http.session->user->username), err.text);
10071031
portal_endpoint_error(con, 400, JSON_RPC_2_ERROR_SERVER_METHOD_PARAMS, "Invalid method parameters.");
@@ -1018,9 +1042,16 @@ void portal_endpoint_messages_list(connection_t *con) {
10181042

10191043
if ((cursor = inx_cursor_alloc(con->http.session->user->messages))) {
10201044

1021-
while ((active = inx_cursor_value_next(cursor))) {
1045+
while ((active = inx_cursor_value_next(cursor)) && (limit == 0 || current < limit)) {
10221046

1023-
if (active->foldernum == foldernum && (header = mail_load_header(active, con->http.session->user, con->server, true))) {
1047+
// If a start value was provided, then skip the requested number of messagres before we start adding results
1048+
// to the response object.
1049+
if (active->foldernum == foldernum && start) {
1050+
start--;
1051+
}
1052+
1053+
// Otherwise add any messages in the matching folder, which can be loaded.
1054+
else if (active->foldernum == foldernum && (header = mail_load_header(active, con->http.session->user, con->server, true))) {
10241055

10251056
fields[0] = mail_header_fetch_cleaned(header, PLACER("From", 4));
10261057
fields[1] = mail_header_fetch_cleaned(header, PLACER("To", 2));
@@ -1064,6 +1095,9 @@ void portal_endpoint_messages_list(connection_t *con) {
10641095

10651096
// Release header string.
10661097
st_free(header);
1098+
1099+
// Track the number of messages that have been added.
1100+
current++;
10671101
}
10681102
}
10691103

web/doc/methods/messages.list.md

+8
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ List messages of the given folder.
66

77
- integer
88

9+
["start"] - *given to skip the specified number of messages in the folder, before constructing the response*
10+
11+
- integer
12+
13+
["limit"] - *stop adding messages to the response, when it reaches this number*
14+
15+
- integer
16+
917
### Response Params
1018

1119
"messageID"

0 commit comments

Comments
 (0)