Skip to main content

handle_message_query

Function handle_message_query 

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

Handle a Message/query method call (draft-atwood-jmap-chat-00 §Message).

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

Unknown filter clauses and sort properties are refused with unsupportedFilter / unsupportedSort (RFC 8620 §5.5).

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). A JMAP Search where (crate-jmap docs/specs/jmap-search.md) needs urn:ietf:params:jmap:search in using and "Message" in ChatSettings::search_capability, else unsupportedFilter; it is checked with jmap_search::check_where_filter and makes canCalculateChanges false. It does not lift the chatId / hasMention: true rule.

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;
  • accountNotFound when the backend does not know accountId;
  • unsupportedFilter when the filter does not decode as a Message filter, or holds a draft-ietf-jmap-metadata-05 §3.6 condition without urn:ietf:params:jmap:metadata in using;
  • unsupportedFilter, too, when the filter is not a single condition with chatId or hasMention: true, sets text, or sets threadRootId without thread support, or when a JMAP Search where is refused; a malformed where is invalidArguments and one nested too deep queryTooComplex (jmap_search::check_where_filter);
  • unsupportedSort when sort names a property this server does not define;
  • anchorNotFound when anchor is not in the results;
  • serverFail when the backend fails, or any other RFC 8620 §5.5 error the backend returns.