For many common narrows (e.g. a topic), clients can write an efficient
client-side check to determine whether a newly arrived message belongs
in the view.
This endpoint is designed to allow clients to handle more complex narrows
for which the client does not (or in the case of full-text search, cannot)
implement this check.
The format of the match_subject and match_content objects is designed
to match those returned by the GET /messages
endpoint, so that a client can splice these fields into a message object
received from GET /events and end up with an
extended message object identical to how a GET /messages
request for the current narrow would have returned the message.
Usage examples
Python
curl
#!/usr/bin/env python3importzulip# Pass the path to your zuliprc file here.client=zulip.Client(config_file="~/zuliprc")# Check which messages within an array match a narrow.request={"msg_ids":msg_ids,"narrow":[{"operator":"has","operand":"link"}],}result=client.call_endpoint(url="messages/matches_narrow",method="GET",request=request)print(result)
A structure defining the narrow to check against. See how to
construct a narrow.
Changes: In Zulip 7.0 (feature level 177), narrows gained support
for three new filters related to direct messages: is:dm, dm and
dm-including; replacing and deprecating is:private, pm-with and
group-pm-with respectively.
Response
Return values
messages: object
A dictionary with a key for each queried message that matches the narrow,
with message IDs as keys and search rendering data as values.
message_id: object
The ID of the message that matches the narrow. No record will be returned
for queried messages that do not match the narrow.
match_content: string
HTML content of a queried message that matches the narrow. If the
narrow is a search narrow, <span class="highlight"> elements
will be included, wrapping the matches for the search keywords.
match_subject: string
HTML-escaped topic of a queried message that matches the narrow. If the
narrow is a search narrow, <span class="highlight"> elements
will be included wrapping the matches for the search keywords.
Example response(s)
Changes: As of Zulip 7.0 (feature level 167), if any
parameters sent in the request are not supported by this
endpoint, a successful JSON response will include an
ignored_parameters_unsupported array.