From b2daa2a8e7f77ef943d7fb2abbb560493065d406 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B0=D1=80=D1=81=D0=B8=D1=8F=20=D0=96=D0=B0=D0=BD?= =?UTF-8?q?=D0=BD=D0=B0?= Date: Wed, 18 Nov 2026 15:49:47 +0300 Subject: [PATCH 1/3] docs: expand comment.giveForObj reference --- docs/dev/api.md | 95 ++++++++++++++++++- .../current/dev/api.md | 95 ++++++++++++++++++- 2 files changed, 180 insertions(+), 10 deletions(-) diff --git a/docs/dev/api.md b/docs/dev/api.md index fa9a9d7..64b98fb 100644 --- a/docs/dev/api.md +++ b/docs/dev/api.md @@ -85,15 +85,100 @@ API errors are returned as JSON with a top-level `code` field and HTTP status `2 ### comment.giveForObj -Returns comment tree by photo number. +Returns the comment tree for a photo or news item. Top-level comments are returned in `comments`; replies are nested in the parent comment's `comments` array. -Parameter | Mandatory | Type | Description | ---- | --- | --- | --- | -cid | ✓ | int | unique photo number | +Parameter | Mandatory | Type | Default | Description | +--- | --- | --- | --- | --- | +cid | ✓ | int | | unique object number | +type | | string | `photo` | object type: `photo` or `news` | +showDel | | bool | `false` | include deleted comments when the authenticated user has permission to view them | **Query example:** -`https://api.pastvu.com/api2?method=comment.giveForObj¶ms={"cid":23314}` +`https://api.pastvu.com/api2?method=comment.giveForObj¶ms={"cid":539434}` + +**Response example (shortened):** + +```json +{ + "result": { + "comments": [ + { + "cid": 1324546, + "user": "user1", + "stamp": 1488382828246, + "txt": "Вероятно, снимок сделан с территории Кремля...", + "s": 5, + "type": 1, + "level": 0, + "comments": [ + { + "cid": 1324559, + "user": "user2", + "stamp": 1488384195442, + "txt": "Спасибо, поправлено.", + "parent": 1324546, + "level": 1, + "s": 5, + "type": 1, + "latest": true + } + ] + } + ], + "countTotal": 2, + "users": { + "user1": { + "disp": "User One", + "login": "user1", + "ranks": ["mec_gold", "adviser"], + "online": false + }, + "user2": { + "avatar": "/_a/h/user2.png", + "disp": "User Two", + "login": "user2", + "ranks": [], + "online": false + } + }, + "latestCid": 1324559, + "cid": 539434 + }, + "rid": "request-id" +} +``` + +**Key response fields:** + +Field | Type | Description | +--- | --- | --- | +`result.cid` | int | requested object number | +`result.comments` | array | top-level comments; replies are nested recursively in `comments` | +`result.comments[].cid` | int | unique comment number | +`result.comments[].user` | string | comment author's login; corresponding profile data is in `result.users` | +`result.comments[].stamp` | int | comment creation time as a Unix timestamp in milliseconds | +`result.comments[].txt` | string | comment text as HTML | +`result.comments[].parent` | int | parent comment number; included for replies | +`result.comments[].level` | int | nesting level, starting with `0` for a top-level comment | +`result.comments[].comments` | array | direct replies to the comment | +`result.comments[].latest` | bool | whether this is the newest comment in the tree | +`result.countTotal` | int | total number of non-deleted comments, including nested replies | +`result.users` | object | comment authors keyed by login; omitted when the object has no comments | +`result.latestCid` | int | number of the newest comment, or `0` when there are no comments | +`rid` | string | request identifier used for diagnostics | + +Authenticated responses also include `countNew`, `countDel`, `canModerate`, and `canReply`. Individual comments can include permission and unread-status fields. + +**Errors:** + +Code | When returned | +--- | --- | +`BAD_PARAMS` | `cid` is missing, is `0`, or cannot be converted to a number | +`NO_SUCH_PHOTO` | a photo does not exist or is not available to the current user | +`COMMENT_NO_OBJECT` | a news item does not exist or is not available to the current user | + +API errors are returned as JSON with a top-level `code` field and HTTP status `200 OK`. Check `code` rather than relying on the HTTP status alone. ### photo.giveNearestPhotos diff --git a/i18n/ru/docusaurus-plugin-content-docs/current/dev/api.md b/i18n/ru/docusaurus-plugin-content-docs/current/dev/api.md index 070c2be..03a4719 100644 --- a/i18n/ru/docusaurus-plugin-content-docs/current/dev/api.md +++ b/i18n/ru/docusaurus-plugin-content-docs/current/dev/api.md @@ -85,15 +85,100 @@ cid | ✓ | int | уникальный номер снимка | ### comment.giveForObj -Возвращает дерево комментариев по номеру фотографии. +Возвращает дерево комментариев к фотографии или новости. Комментарии верхнего уровня находятся в массиве `comments`, а ответы — в массиве `comments` родительского комментария. -Параметр | Обязательный | Тип | Описание | ---- | --- | --- | --- | -cid | ✓ | int | уникальный номер снимка | +Параметр | Обязательный | Тип | По умолчанию | Описание | +--- | --- | --- | --- | --- | +cid | ✓ | int | | уникальный номер объекта | +type | | string | `photo` | тип объекта: `photo` или `news` | +showDel | | bool | `false` | включать удалённые комментарии, если у авторизованного пользователя есть право их просматривать | **Пример запроса:** -`https://api.pastvu.com/api2?method=comment.giveForObj¶ms={"cid":23314}` +`https://api.pastvu.com/api2?method=comment.giveForObj¶ms={"cid":539434}` + +**Сокращённый пример ответа:** + +```json +{ + "result": { + "comments": [ + { + "cid": 1324546, + "user": "user1", + "stamp": 1488382828246, + "txt": "Вероятно, снимок сделан с территории Кремля...", + "s": 5, + "type": 1, + "level": 0, + "comments": [ + { + "cid": 1324559, + "user": "user2", + "stamp": 1488384195442, + "txt": "Спасибо, поправлено.", + "parent": 1324546, + "level": 1, + "s": 5, + "type": 1, + "latest": true + } + ] + } + ], + "countTotal": 2, + "users": { + "user1": { + "disp": "User One", + "login": "user1", + "ranks": ["mec_gold", "adviser"], + "online": false + }, + "user2": { + "avatar": "/_a/h/user2.png", + "disp": "User Two", + "login": "user2", + "ranks": [], + "online": false + } + }, + "latestCid": 1324559, + "cid": 539434 + }, + "rid": "request-id" +} +``` + +**Основные поля ответа:** + +Поле | Тип | Описание | +--- | --- | --- | +`result.cid` | int | номер запрошенного объекта | +`result.comments` | array | комментарии верхнего уровня; ответы рекурсивно вложены в массивы `comments` | +`result.comments[].cid` | int | уникальный номер комментария | +`result.comments[].user` | string | логин автора комментария; данные профиля находятся в `result.users` | +`result.comments[].stamp` | int | время создания комментария в виде Unix timestamp в миллисекундах | +`result.comments[].txt` | string | текст комментария в формате HTML | +`result.comments[].parent` | int | номер родительского комментария; возвращается для ответов | +`result.comments[].level` | int | уровень вложенности; для комментария верхнего уровня равен `0` | +`result.comments[].comments` | array | непосредственные ответы на комментарий | +`result.comments[].latest` | bool | признак самого нового комментария в дереве | +`result.countTotal` | int | общее количество комментариев без удалённых, включая вложенные ответы | +`result.users` | object | авторы комментариев с логинами в качестве ключей; отсутствует, если комментариев нет | +`result.latestCid` | int | номер самого нового комментария или `0`, если комментариев нет | +`rid` | string | идентификатор запроса для диагностики | + +Для авторизованных запросов в ответ также входят поля `countNew`, `countDel`, `canModerate` и `canReply`. У отдельных комментариев могут появляться поля с правами пользователя и признаком непрочитанного комментария. + +**Ошибки:** + +Код | Когда возвращается | +--- | --- | +`BAD_PARAMS` | `cid` не указан, равен `0` или не преобразуется в число | +`NO_SUCH_PHOTO` | фотография не существует или недоступна текущему пользователю | +`COMMENT_NO_OBJECT` | новость не существует или недоступна текущему пользователю | + +Ошибки API возвращаются в JSON с полем `code` на верхнем уровне и HTTP-статусом `200 OK`. Проверяйте `code` в ответе, а не только HTTP-статус. ### photo.giveNearestPhotos From a2e2e0ae9e1524248c582775756b766769c82156 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B0=D1=80=D1=81=D0=B8=D1=8F=20=D0=96=D0=B0=D0=BD?= =?UTF-8?q?=D0=BD=D0=B0?= Date: Wed, 18 Nov 2026 18:12:50 +0300 Subject: [PATCH 2/3] docs: clarify comment.giveForObj response variants --- docs/dev/api.md | 16 ++++++++++++---- .../current/dev/api.md | 16 ++++++++++++---- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/docs/dev/api.md b/docs/dev/api.md index 64b98fb..a5be72a 100644 --- a/docs/dev/api.md +++ b/docs/dev/api.md @@ -158,18 +158,26 @@ Field | Type | Description | `result.comments[].cid` | int | unique comment number | `result.comments[].user` | string | comment author's login; corresponding profile data is in `result.users` | `result.comments[].stamp` | int | comment creation time as a Unix timestamp in milliseconds | -`result.comments[].txt` | string | comment text as HTML | +`result.comments[].txt` | string | comment text as HTML; omitted for a deleted-comment placeholder | `result.comments[].parent` | int | parent comment number; included for replies | `result.comments[].level` | int | nesting level, starting with `0` for a top-level comment | -`result.comments[].comments` | array | direct replies to the comment | +`result.comments[].comments` | array | direct replies to the comment; omitted for a deleted-comment placeholder | +`result.comments[].del` | bool | `true` for a deleted-comment placeholder returned with `showDel` | `result.comments[].latest` | bool | whether this is the newest comment in the tree | `result.countTotal` | int | total number of non-deleted comments, including nested replies | -`result.users` | object | comment authors keyed by login; omitted when the object has no comments | -`result.latestCid` | int | number of the newest comment, or `0` when there are no comments | +`result.users` | object | comment authors keyed by login | +`result.latestCid` | int | number of the newest comment | `rid` | string | request identifier used for diagnostics | Authenticated responses also include `countNew`, `countDel`, `canModerate`, and `canReply`. Individual comments can include permission and unread-status fields. +With `showDel: true`, an eligible deleted comment is returned as a placeholder with `del: true`. Its `txt` and nested `comments` fields are omitted. + +When no comments match, the empty response depends on authentication: + +- an anonymous response omits `users` and includes `latestCid: 0`; +- an authenticated response includes `users: {}` and omits `latestCid`. + **Errors:** Code | When returned | diff --git a/i18n/ru/docusaurus-plugin-content-docs/current/dev/api.md b/i18n/ru/docusaurus-plugin-content-docs/current/dev/api.md index 03a4719..404ac6e 100644 --- a/i18n/ru/docusaurus-plugin-content-docs/current/dev/api.md +++ b/i18n/ru/docusaurus-plugin-content-docs/current/dev/api.md @@ -158,18 +158,26 @@ showDel | | bool | `false` | включать удалённые коммент `result.comments[].cid` | int | уникальный номер комментария | `result.comments[].user` | string | логин автора комментария; данные профиля находятся в `result.users` | `result.comments[].stamp` | int | время создания комментария в виде Unix timestamp в миллисекундах | -`result.comments[].txt` | string | текст комментария в формате HTML | +`result.comments[].txt` | string | текст комментария в формате HTML; отсутствует у заглушки удалённого комментария | `result.comments[].parent` | int | номер родительского комментария; возвращается для ответов | `result.comments[].level` | int | уровень вложенности; для комментария верхнего уровня равен `0` | -`result.comments[].comments` | array | непосредственные ответы на комментарий | +`result.comments[].comments` | array | непосредственные ответы на комментарий; отсутствуют у заглушки удалённого комментария | +`result.comments[].del` | bool | значение `true` у заглушки удалённого комментария, возвращённой с `showDel` | `result.comments[].latest` | bool | признак самого нового комментария в дереве | `result.countTotal` | int | общее количество комментариев без удалённых, включая вложенные ответы | -`result.users` | object | авторы комментариев с логинами в качестве ключей; отсутствует, если комментариев нет | -`result.latestCid` | int | номер самого нового комментария или `0`, если комментариев нет | +`result.users` | object | авторы комментариев с логинами в качестве ключей | +`result.latestCid` | int | номер самого нового комментария | `rid` | string | идентификатор запроса для диагностики | Для авторизованных запросов в ответ также входят поля `countNew`, `countDel`, `canModerate` и `canReply`. У отдельных комментариев могут появляться поля с правами пользователя и признаком непрочитанного комментария. +При `showDel: true` доступный удалённый комментарий возвращается как заглушка с `del: true`. Поля `txt` и вложенный массив `comments` у неё отсутствуют. + +Если подходящих комментариев нет, состав пустого ответа зависит от авторизации: + +- в анонимном ответе нет поля `users`, а `latestCid` равен `0`; +- в авторизованном ответе есть `users: {}`, но нет поля `latestCid`. + **Ошибки:** Код | Когда возвращается | From 37127a85c6645f67639bc276134f8ebb1630bcbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B0=D1=80=D1=81=D0=B8=D1=8F=20=D0=96=D0=B0=D0=BD?= =?UTF-8?q?=D0=BD=D0=B0?= Date: Wed, 18 Nov 2026 18:20:20 +0300 Subject: [PATCH 3/3] docs: document comment read side effects --- docs/dev/api.md | 6 +++++- i18n/ru/docusaurus-plugin-content-docs/current/dev/api.md | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/docs/dev/api.md b/docs/dev/api.md index a5be72a..d3ccf8d 100644 --- a/docs/dev/api.md +++ b/docs/dev/api.md @@ -93,6 +93,8 @@ cid | ✓ | int | | unique object number | type | | string | `photo` | object type: `photo` or `news` | showDel | | bool | `false` | include deleted comments when the authenticated user has permission to view them | +Only the exact value `news` selects a news item. If `type` is omitted or has any other value, the method handles `cid` as a photo number. `showDel` has no effect on anonymous requests. + **Query example:** `https://api.pastvu.com/api2?method=comment.giveForObj¶ms={"cid":539434}` @@ -169,7 +171,9 @@ Field | Type | Description | `result.latestCid` | int | number of the newest comment | `rid` | string | request identifier used for diagnostics | -Authenticated responses also include `countNew`, `countDel`, `canModerate`, and `canReply`. Individual comments can include permission and unread-status fields. +Authenticated responses also include `countNew`, `countDel`, and `canReply`. `canModerate` is `true` for a moderator of the object and is otherwise omitted. Individual comments can include permission and unread-status fields. + +An authenticated request records the current time as the user's last comment view, resets the new-comment counter, and can clear a scheduled comment notification for the object. With `showDel: true`, an eligible deleted comment is returned as a placeholder with `del: true`. Its `txt` and nested `comments` fields are omitted. diff --git a/i18n/ru/docusaurus-plugin-content-docs/current/dev/api.md b/i18n/ru/docusaurus-plugin-content-docs/current/dev/api.md index 404ac6e..d4d2b99 100644 --- a/i18n/ru/docusaurus-plugin-content-docs/current/dev/api.md +++ b/i18n/ru/docusaurus-plugin-content-docs/current/dev/api.md @@ -93,6 +93,8 @@ cid | ✓ | int | | уникальный номер объекта | type | | string | `photo` | тип объекта: `photo` или `news` | showDel | | bool | `false` | включать удалённые комментарии, если у авторизованного пользователя есть право их просматривать | +Только точное значение `news` выбирает новость. Если `type` не указан или содержит другое значение, метод обрабатывает `cid` как номер фотографии. Параметр `showDel` не влияет на анонимные запросы. + **Пример запроса:** `https://api.pastvu.com/api2?method=comment.giveForObj¶ms={"cid":539434}` @@ -169,7 +171,9 @@ showDel | | bool | `false` | включать удалённые коммент `result.latestCid` | int | номер самого нового комментария | `rid` | string | идентификатор запроса для диагностики | -Для авторизованных запросов в ответ также входят поля `countNew`, `countDel`, `canModerate` и `canReply`. У отдельных комментариев могут появляться поля с правами пользователя и признаком непрочитанного комментария. +Для авторизованных запросов в ответ также входят поля `countNew`, `countDel` и `canReply`. Поле `canModerate` равно `true` для модератора объекта, а в остальных случаях отсутствует. У отдельных комментариев могут появляться поля с правами пользователя и признаком непрочитанного комментария. + +Авторизованный запрос записывает текущее время как время последнего просмотра комментариев, сбрасывает счётчик новых комментариев и может удалить запланированное уведомление о комментариях к объекту. При `showDel: true` доступный удалённый комментарий возвращается как заглушка с `del: true`. Поля `txt` и вложенный массив `comments` у неё отсутствуют.