feat: port private messaging (私信) from upstream
- Add conversations/messages tables to schema.sql (upstream missed them) - API: GET/POST /api/conversations, GET/POST /api/conversations/[id]/messages, PUT /api/messages/[id]/read - Chat UI: conversation list modal, chat window with 3s polling, unread badge - Navbar message entry opens DM list; user profile has 发私信 button - Access control: only conversation participants (403 otherwise)
This commit is contained in:
1 parent
5ef8d4b1ff
commit
300ad5959c
11 files changed
+522
-3
No files matched your search
+13
@@ -102,6 +102,19 @@ export const API = {
|
||||
logEvent(action) {
|
||||
return apiFetch('/event-logs', { method: 'POST', body: JSON.stringify({ action }) }).catch(() => {});
|
||||
},
|
||||
|
||||
// 私信
|
||||
getConversations() { return apiFetch('/conversations'); },
|
||||
getOrCreateConversation(other_user_id) {
|
||||
return apiFetch('/conversations', { method: 'POST', body: JSON.stringify({ other_user_id }) });
|
||||
},
|
||||
getMessages(conversationId) { return apiFetch('/conversations/' + conversationId + '/messages'); },
|
||||
sendMessage(conversationId, content) {
|
||||
return apiFetch('/conversations/' + conversationId + '/messages', { method: 'POST', body: JSON.stringify({ content }) });
|
||||
},
|
||||
markMessageRead(messageId) {
|
||||
return apiFetch('/messages/' + messageId + '/read', { method: 'PUT' });
|
||||
},
|
||||
};
|
||||
|
||||
// 图片上传 (multipart)
|
||||
|
||||
Reference in new issue
Block a user