Nachrichten-Plugin 1.0.0: Direktnachrichten, Gruppen, Anhänge, GIFs, Emojis
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
commit
2844452002
55 changed files with 5448 additions and 0 deletions
40
resources/js/lib/api.js
Normal file
40
resources/js/lib/api.js
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
import { http } from '@inhaus/ui';
|
||||
|
||||
/** JSON-Schnittstelle der Chat-Oberfläche (routes/web.php, Präfix /chat/api) */
|
||||
const base = '/chat/api';
|
||||
|
||||
export const api = {
|
||||
conversations: () => http.get(`${base}/gespraeche`),
|
||||
direct: (userId) => http.post(`${base}/direkt`, { user_id: userId }),
|
||||
createGroup: (name, members) => http.post(`${base}/gruppen`, { name, members }),
|
||||
updateConversation: (id, data) => http.put(`${base}/gespraeche/${id}`, data),
|
||||
leave: (id) => http.delete(`${base}/gespraeche/${id}`),
|
||||
addMembers: (id, members) => http.post(`${base}/gespraeche/${id}/mitglieder`, { members }),
|
||||
removeMember: (id, userId) => http.delete(`${base}/gespraeche/${id}/mitglieder/${userId}`),
|
||||
setAdmin: (id, userId, admin) => http.put(`${base}/gespraeche/${id}/mitglieder/${userId}`, { admin }),
|
||||
|
||||
messages: (id, before) => http.get(`${base}/gespraeche/${id}/nachrichten${before ? `?vor=${before}` : ''}`),
|
||||
send(id, { body, gifUrl, replyTo, files }) {
|
||||
const data = new FormData();
|
||||
if (body) data.append('body', body);
|
||||
if (gifUrl) data.append('gif_url', gifUrl);
|
||||
if (replyTo) data.append('reply_to', replyTo);
|
||||
(files ?? []).forEach((file) => data.append('files[]', file));
|
||||
|
||||
return http.post(`${base}/gespraeche/${id}/nachrichten`, data);
|
||||
},
|
||||
edit: (messageId, body) => http.put(`${base}/nachrichten/${messageId}`, { body }),
|
||||
remove: (messageId) => http.delete(`${base}/nachrichten/${messageId}`),
|
||||
react: (messageId, emoji) => http.post(`${base}/nachrichten/${messageId}/reaktion`, { emoji }),
|
||||
read: (id, messageId) => http.post(`${base}/gespraeche/${id}/gelesen`, { message_id: messageId }),
|
||||
typing: (id) => http.post(`${base}/gespraeche/${id}/tippt`),
|
||||
updates: (params) => http.get(`${base}/neues?${new URLSearchParams(Object.entries(params).filter(([, v]) => v !== null && v !== undefined))}`),
|
||||
unread: () => http.get(`${base}/ungelesen`),
|
||||
gifs: (q) => http.get(`${base}/gifs?q=${encodeURIComponent(q ?? '')}`),
|
||||
people: (q) => http.get(`/personen/suche?q=${encodeURIComponent(q)}`),
|
||||
};
|
||||
|
||||
/** Ungelesene an das Symbol in der Kopfzeile melden */
|
||||
export function announceUnread(count) {
|
||||
window.dispatchEvent(new CustomEvent('inhaus-chat:unread', { detail: count }));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue