[jsonapi] items/add?expression can take 'limit' param

This commit is contained in:
whatdoineed2do/Ray 2020-05-09 20:04:27 +01:00
parent c5fe0d217b
commit 69c56f5971

View File

@ -2287,7 +2287,7 @@ queue_tracks_add_byuris(const char *param, int pos, int *total_count)
}
static int
queue_tracks_add_byexpression(const char *param, int pos, int *total_count)
queue_tracks_add_byexpression(const char *param, int pos, int limit, int *total_count)
{
char *expression;
struct smartpl smartpl_expression;
@ -2310,7 +2310,7 @@ queue_tracks_add_byexpression(const char *param, int pos, int *total_count)
query_params.filter = strdup(smartpl_expression.query_where);
query_params.order = safe_strdup(smartpl_expression.order);
query_params.limit = smartpl_expression.limit;
query_params.limit = limit > 0 ? limit : smartpl_expression.limit;
free_smartpl(&smartpl_expression, 1);
player_get_status(&status);
@ -2333,6 +2333,7 @@ jsonapi_reply_queue_tracks_add(struct httpd_request *hreq)
const char *param_expression;
const char *param;
int pos = -1;
int limit = -1;
bool shuffle;
int total_count = 0;
json_object *reply;
@ -2384,7 +2385,11 @@ jsonapi_reply_queue_tracks_add(struct httpd_request *hreq)
}
else
{
ret = queue_tracks_add_byexpression(param_expression, pos, &total_count);
// This overrides the value specified in query
param = evhttp_find_header(hreq->query, "limit");
if (param)
safe_atoi32(param, &limit);
ret = queue_tracks_add_byexpression(param_expression, pos, limit, &total_count);
}
if (ret == 0)