Часть технических описаний пока доступна на английском языке.

Обновить личные отметки сообщений

POST https://z.u1v.ru/api/v1/messages/flags

Добавить или удалить личные флаги сообщений, например read и starred, для набора ID сообщений.

См. также метод изменения флагов для диапазона сообщений в narrow.

Примеры запросов

#!/usr/bin/env python3

import pero

# Pass the path to your perorc file here.
client = pero.Client(config_file="~/.perorc")

# Add the "read" flag to messages, given the messages' IDs.
request = {
    "messages": message_ids,
    "op": "add",
    "flag": "read",
}
result = client.update_message_flags(request)
# Remove the "starred" flag from messages, given the messages' IDs.
request = {
    "messages": message_ids,
    "op": "remove",
    "flag": "starred",
}
result = client.update_message_flags(request)
print(result)

Дополнительные примеры и документация доступны здесь.

const zulipInit = require("zulip-js");

// Pass the path to your perorc file here.
const config = { zuliprc: "perorc" };

(async () => {
    const client = await zulipInit(config);

    // Add the "read" flag to the messages with IDs in "message_ids"
    const addflag = {
        messages: message_ids,
        flag: "read",
    };
    console.log(await client.messages.flags.add(addflag));

    // Remove the "starred" flag from the messages with IDs in "message_ids"
    const removeflag = {
        messages: message_ids,
        flag: "starred",
    };
    console.log(await client.messages.flags.remove(removeflag));
})();

Параметр -u задаёт учётные данные для HTTP-аутентификации Basic. Как получить их для пользователя или бота, описано в разделе о заголовке Authorization.

curl -sSX POST https://z.u1v.ru/api/v1/messages/flags \
    -u EMAIL_ADDRESS:API_KEY \
    --data-urlencode 'messages=[4, 8, 15]' \
    --data-urlencode op=add \
    --data-urlencode flag=read

Параметры

messages (integer)[] обязательно

Пример: [4, 8, 15]

Массив с ID целевых сообщений.


op string обязательно

Пример: "add"

Следует ли добавить флаг (add) или удалить его (remove).

Допустимые значения: "add", "remove".


flag string обязательно

Пример: "read"

Флаг, который нужно добавить или удалить.


Available flags

Flag Purpose
read Whether the user has read the message. Messages start out unread (except for messages the user themself sent using a non-API client) and can later be marked as read.
starred Whether the user has starred this message.
collapsed Whether the user has collapsed this message.
hide_link_previews Whether the user has hidden auto-generated link previews on this message. Can be set on any message, regardless of whether it currently has a link preview.

Changes: New in Zulip 13.0 (feature level 510).
mentioned Whether the current user was mentioned by this message, either directly or via a user group. Cannot be changed by the user directly, but can change if the message is edited to add/remove a mention of the current user.
stream_wildcard_mentioned Whether this message contained a channel wildcard mention (like @**all**). Cannot be changed by the user directly, but can change if the message is edited to add/remove a channel wildcard mention.

Changes: New in Zulip 8.0 (feature level 224).
topic_wildcard_mentioned Whether this message contained a topic wildcard mention (@**topic**). Cannot be changed by the user directly, but can change if the message is edited to add/remove a topic wildcard mention.

Changes: New in Zulip 8.0 (feature level 224).
has_alert_word Whether the message contains any of the current user's configured alert words. Cannot be changed by the user directly, but can change if the message is edited to add/remove one of the current user's alert words.
historical Is true for messages that the user did not receive at the time they were sent but later was added to the user's history (e.g. because they starred or reacted to a message sent to a public channel before they subscribed to that channel). Cannot be changed by the user directly.
wildcard_mentioned Whether this message contained either a channel wildcard mention (like @**all**) or a topic wildcard mention (@**topic**). Cannot be changed by the user directly, but can change if the message is edited to add/remove a channel and/or topic wildcard mention.

Changes: Deprecated in Zulip 8.0 (feature level 224), in favor of the stream_wildcard_mentioned and topic_wildcard_mentioned flags. The wildcard_mentioned flag exists for backwards compatibility with older clients and equals stream_wildcard_mentioned || topic_wildcard_mentioned. Clients supporting older server versions should treat this field as a previous name for the stream_wildcard_mentioned flag as topic wildcard mentions were not available prior to this feature level.

Ответ

Возвращаемые поля

  • messages: (integer)[]

    Массив ID изменённых сообщений.

  • ignored_because_not_subscribed_channels: (integer)[]

    Присутствует только для флага read и операции remove.

    Все непрочитанные сообщения каналов должны относиться к каналам, на которые пользователь подписан. Поле содержит список каналов, сообщения которых не были отмечены как непрочитанные, поскольку пользователь на эти каналы не подписан.

    Изменения: Добавлено в Zulip 10.0 (уровень возможностей 355).

Примеры ответов

Изменения: Начиная с Zulip 7.0 (уровень возможностей 167), успешный JSON-ответ содержит массив ignored_parameters_unsupported, если запрос включает параметры, которые метод не поддерживает.

Пример успешного JSON-ответа:

{
    "ignored_because_not_subscribed_channels": [
        12,
        13,
        9
    ],
    "messages": [
        4,
        18,
        15
    ],
    "msg": "",
    "result": "success"
}