Add verification questions, claim flow and scam warnings

- post form: up to 3 verification questions (loss and found) and a
  "how not to get scammed" note; sent as verificationQuestions JSON
- feed card: "I found it" / "It's mine" instead of "Write" for posts with
  questions; phone shows "after check" until the author approves
- chat draft shows ClaimForm; VerificationPanel lets the author approve or
  reject answers and locks the claimant's input until approval, then offers
  the author's phone
- messages: claim answers card, verification system line, fraudSignal
  warnings for the recipient; ChatSafetyNotice with new-account mark
- tests, README

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
SlimusMinus
2026-11-11 01:04:55 +03:00
parent 133becd255
commit 3dd174afa5
20 changed files with 811 additions and 23 deletions

View File

@@ -78,6 +78,41 @@ export function useChats() {
return chat;
}, []);
/** Один чат: статус проверки ответов (verificationStatus, claimantId) и собеседник. */
const fetchChat = useCallback(async (chatId) => {
const res = await apiFetch(`${API_URL}/api/v1/chats/${chatId}`);
if (!res.ok) throw await readApiError(res);
return res.json();
}, []);
/**
* «Это моё»: ответы на контрольные вопросы находки. Бэкенд создаёт чат с
* ответами первым сообщением; писать дальше можно после подтверждения автором.
*/
const claimPost = useCallback(async (postId, answers, postInfo) => {
const res = await apiFetch(`${API_URL}/api/v1/posts/${encodeURIComponent(postId)}/claim`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ answers }),
});
// 429 — лимит заявок, 409 — уже отвечали, 400 — не все ответы
if (!res.ok) throw await readApiError(res);
const chat = await res.json();
cacheChatPost(chat, postInfo);
return chat;
}, []);
/** Автор находки подтверждает (approved) или отклоняет ответы; возвращает сообщение-решение. */
const decideVerification = useCallback(async (chatId, approved) => {
const res = await apiFetch(`${API_URL}/api/v1/chats/${chatId}/verification`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ approved }),
});
if (!res.ok) throw await readApiError(res);
return res.json();
}, []);
const fetchMessages = useCallback(async (chatId) => {
const res = await apiFetch(`${API_URL}/api/v1/chats/${chatId}/messages`);
// Без этой проверки 5xx с JSON-телом ошибки превращался в пустой список,
@@ -157,7 +192,7 @@ export function useChats() {
return {
chats, loading, error, fetchChats, findChat, startChat, fetchMessages, markAsRead,
sendPhotoMessage, sendVideoMessage, refreshAttachmentUrl,
sendPhotoMessage, sendVideoMessage, refreshAttachmentUrl, fetchChat, claimPost, decideVerification,
};
}