server: implement the :after parameter for contacts

Parse the :after parameter as an iso-8601-like parameter, and use it for
limiting the amount of contacts.
This commit is contained in:
Dirk-Jan C. Binnema 2020-01-25 19:34:39 +02:00
parent f21ceea421
commit 0f81c86083
1 changed files with 3 additions and 2 deletions

View File

@ -428,7 +428,7 @@ each_contact_sexp (const char* full_address,
*/
static char*
contacts_to_sexp (const MuContacts *contacts, bool personal,
time_t last_seen, gint64 tstamp)
int64_t last_seen, gint64 tstamp)
{
g_return_val_if_fail (contacts, NULL);
@ -460,7 +460,8 @@ contacts_handler (Context& context, const Parameters& params)
const auto afterstr = get_string_or(params, "after");
const auto tstampstr = get_string_or(params, "tstamp");
const auto after = (time_t)g_ascii_strtoll (afterstr.c_str(), NULL, 10);
const auto after{afterstr.empty() ? 0 :
g_ascii_strtoll(date_to_time_t_string(afterstr, true).c_str(), {}, 10)};
const auto tstamp = g_ascii_strtoll (tstampstr.c_str(), NULL, 10);
const auto contacts{mu_store_contacts(context.store)};