diff --git a/app/Http/Controllers/MessagesController.php b/app/Http/Controllers/MessagesController.php new file mode 100644 index 0000000..00af02e --- /dev/null +++ b/app/Http/Controllers/MessagesController.php @@ -0,0 +1,21 @@ + $threadId, + ]); + } +} diff --git a/app/Http/Controllers/ThreadController.php b/app/Http/Controllers/ThreadController.php new file mode 100644 index 0000000..d047a12 --- /dev/null +++ b/app/Http/Controllers/ThreadController.php @@ -0,0 +1,72 @@ +with(['messages' => fn ($query) => $query->orderByDesc('timestamp')->limit(1)]) + ->orderByDesc('last_activity_at') + ->get() + ->map(function (DirectThread $thread) { + $last = $thread->messages->first(); + + return [ + 'thread_id' => $thread->thread_id, + 'thread_title' => $thread->thread_title, + 'is_group' => $thread->is_group, + 'participants' => $thread->participants, + 'last_activity_at' => $thread->last_activity_at, + 'muted' => $thread->muted, + 'last_message' => $last ? [ + 'username' => $last->username, + 'text' => $last->text, + 'item_type' => $last->item_type, + 'timestamp' => $last->timestamp, + ] : null, + ]; + }); + + return response()->json($threads); + } + + public function show(string $threadId): JsonResponse + { + $thread = DirectThread::findOrFail($threadId); + + $messages = $thread->messages() + ->orderBy('timestamp') + ->get() + ->map(fn (DirectMessage $message) => [ + 'id' => $message->id, + 'user_id' => $message->user_id, + 'username' => $message->username, + 'full_name' => $message->full_name, + 'item_type' => $message->item_type, + 'text' => $message->text, + 'timestamp' => $message->timestamp, + 'shared_url' => $message->shared_url, + 'shared_preview_image' => $message->shared_preview_image, + 'shared_title' => $message->shared_title, + 'shared_caption' => $message->shared_caption, + 'reactions' => $message->reactions, + 'replied_to_id' => $message->replied_to_id, + 'replied_to_text' => $message->replied_to_text, + ]); + + return response()->json([ + 'thread_id' => $thread->thread_id, + 'thread_title' => $thread->thread_title, + 'is_group' => $thread->is_group, + 'participants' => $thread->participants, + 'muted' => $thread->muted, + 'messages' => $messages, + ]); + } +} diff --git a/resources/js/components/dredge/MainHeader.vue b/resources/js/components/dredge/MainHeader.vue index 1bacb54..5615d3a 100644 --- a/resources/js/components/dredge/MainHeader.vue +++ b/resources/js/components/dredge/MainHeader.vue @@ -1,15 +1,21 @@ - + - DredgeGram + + + DredgeGram + + - + - + diff --git a/resources/js/pages/Messages/Index.vue b/resources/js/pages/Messages/Index.vue new file mode 100644 index 0000000..148d51e --- /dev/null +++ b/resources/js/pages/Messages/Index.vue @@ -0,0 +1,146 @@ + + + + + Messages + + Loading your messages… + {{ error }} + No conversations yet. + + + + + {{ threadName(thread) }} + {{ previewText(thread) }} + + + + + + + diff --git a/resources/js/pages/Messages/Show.vue b/resources/js/pages/Messages/Show.vue new file mode 100644 index 0000000..2a2e910 --- /dev/null +++ b/resources/js/pages/Messages/Show.vue @@ -0,0 +1,267 @@ + + + + + + + + + {{ threadName }} + + + Loading conversation… + {{ error }} + + + + + + + + {{ message.replied_to_text }} + + + {{ message.text }} + + + + + + {{ message.shared_title }} + + + {{ message.shared_caption }} + + + + + + {{ systemLabel(message) }} + + + + + {{ reaction.emoji }} + + + + + + + + + diff --git a/resources/js/types/dredge.types.ts b/resources/js/types/dredge.types.ts index 1df20f4..6a6edf7 100644 --- a/resources/js/types/dredge.types.ts +++ b/resources/js/types/dredge.types.ts @@ -48,3 +48,58 @@ export interface StoryDetail { start_index: number; items: StoryItem[]; } + +export interface ThreadParticipant { + user_id: string; + username: string; + full_name: string | null; + profile_pic_url: string | null; + interop_messaging_user_fbid: string; +} + +export interface ThreadSummary { + thread_id: string; + thread_title: string | null; + is_group: boolean; + participants: ThreadParticipant[]; + last_activity_at: number | null; + muted: boolean | null; + last_message: { + username: string | null; + text: string | null; + item_type: string | null; + timestamp: number | null; + } | null; +} + +export interface ThreadReaction { + emoji: string | null; + sender_fbid: string | null; + username: string | null; +} + +export interface ThreadMessage { + id: string; + user_id: string | null; + username: string | null; + full_name: string | null; + item_type: string | null; + text: string | null; + timestamp: number | null; + shared_url: string | null; + shared_preview_image: string | null; + shared_title: string | null; + shared_caption: string | null; + reactions: ThreadReaction[] | null; + replied_to_id: string | null; + replied_to_text: string | null; +} + +export interface ThreadDetail { + thread_id: string; + thread_title: string | null; + is_group: boolean; + participants: ThreadParticipant[]; + muted: boolean | null; + messages: ThreadMessage[]; +} diff --git a/routes/api.php b/routes/api.php index 7321fe6..ececfb9 100644 --- a/routes/api.php +++ b/routes/api.php @@ -1,6 +1,7 @@ 'Home', ])->name('home'); +Route::get('/messages', [MessagesController::class, 'index'])->name('messages.index'); +Route::get('/messages/{threadId}', [MessagesController::class, 'show'])->name('messages.show'); + Route::get('/image-proxy', [ImageProxyController::class, 'show'])->name('image-proxy');
Loading your messages…
{{ error }}
No conversations yet.
Loading conversation…
+ {{ message.replied_to_text }} +
{{ message.text }}
+ {{ systemLabel(message) }} +