Skip to main content

handle_task_query

Function handle_task_query 

Source
pub async fn handle_task_query<B: TasksBackend>(
    backend: &B,
    caller: &B::CallerCtx,
    args: Value,
    using: &[String],
) -> Result<HandlerOutput, JmapError>
Expand description

Handle a Task/query method call (draft-tasks-06 §4.13).

args is the RFC 8620 §5.5 /query request shape (accountId, optional filter, optional sort, optional position, optional anchor, optional anchorOffset, optional limit, optional calculateTotal); the returned Value is the §5.5 /query response shape (accountId, queryState, canCalculateChanges, position, ids, optional total).

The Task/query arguments of jmapio/jmap #456, as on CalendarEvent/query (draft-ietf-jmap-calendars-34 §5.11):

  • expandRecurrences: Boolean (default false). “If true, the filter MUST be just a FilterCondition (not a FilterOperator) and MUST include both a “before” and “after” property; otherwise, the server MUST reject the call with an invalidArguments error.“ A window longer than TasksLimits::max_expanded_query_duration_seconds (maxExpandedQueryDuration, draft-tasks-06 §1.6.2) is the expandDurationTooLarge method error, checked here and again by the backend.
  • timeZone: TimeZoneId (default "Etc/UTC"), the zone for the after / before conditions and for floating tasks. A value that is neither a string nor null is invalidArguments.

Both reach TasksBackend::query_tasks as a TaskQueryArgs. The backend may also return cannotCalculateOccurrences.

using is the request’s capability list (pass jmap_server::CallContext::using); without urn:ietf:params:jmap:metadata a draft-ietf-jmap-metadata-05 §3.6 filter condition is unsupportedFilter (-05 §3).

Returns (response_args, extra_invocations). The extra list is always empty.

§Errors

Returns a method-level JmapError:

  • invalidArguments when accountId is missing or not a valid Id, or when filter, sort, position, anchor, anchorOffset or limit is malformed, timeZone is not a string, or expandRecurrences is set without a filter condition that has both before and after;
  • accountNotFound when the backend does not know accountId;
  • unsupportedFilter when the filter does not decode as a Task filter or uses a metadata condition without urn:ietf:params:jmap:metadata in using;
  • unsupportedSort when sort names a property that is not supported;
  • expandDurationTooLarge when expandRecurrences spans more than the account’s maxExpandedQueryDuration;
  • serverFail when the backend fails, or any other RFC 8620 §5.5 error the backend returns, such as anchorNotFound.