messages implemented
This commit is contained in:
162
routes/api.php
162
routes/api.php
@@ -111,6 +111,9 @@ Route::middleware(['web', 'auth', 'admin.moderation'])->prefix('admin/uploads')-
|
||||
});
|
||||
|
||||
Route::middleware(['web', 'auth', 'admin.moderation'])->prefix('admin/reports')->name('api.admin.reports.')->group(function () {
|
||||
Route::get('queue', [\App\Http\Controllers\Api\Admin\ModerationReportQueueController::class, 'index'])
|
||||
->name('queue');
|
||||
|
||||
Route::get('similar-artworks', [\App\Http\Controllers\Api\Admin\SimilarArtworkReportController::class, 'index'])
|
||||
->name('similar-artworks');
|
||||
|
||||
@@ -166,6 +169,11 @@ Route::middleware(['web', 'throttle:60,1'])->prefix('tags')->name('api.tags.')->
|
||||
Route::get('popular', [\App\Http\Controllers\Api\TagController::class, 'popular'])->name('popular');
|
||||
});
|
||||
|
||||
// User/creator search (public, supports @mention prefix)
|
||||
Route::middleware(['web', 'throttle:60,1'])
|
||||
->get('search/users', \App\Http\Controllers\Api\Search\UserSearchController::class)
|
||||
->name('api.search.users');
|
||||
|
||||
Route::middleware(['web', 'auth', 'normalize.username'])->prefix('artworks')->name('api.artworks.tags.')->group(function () {
|
||||
Route::get('{id}/tags', [\App\Http\Controllers\Api\ArtworkTagController::class, 'index'])->whereNumber('id')->name('index');
|
||||
Route::post('{id}/tags', [\App\Http\Controllers\Api\ArtworkTagController::class, 'store'])->whereNumber('id')->name('store');
|
||||
@@ -183,6 +191,12 @@ Route::middleware(['web', 'auth', 'normalize.username', 'throttle:20,1'])
|
||||
Route::delete('{id}/award', [\App\Http\Controllers\Api\ArtworkAwardController::class, 'destroy']) ->whereNumber('id')->name('destroy');
|
||||
});
|
||||
|
||||
// ── Latest Comments feed ──────────────────────────────────────────────────────
|
||||
// GET /api/comments/latest?type=all|following|mine&page=N
|
||||
Route::middleware(['web', 'throttle:60,1'])
|
||||
->get('comments/latest', [\App\Http\Controllers\Api\LatestCommentsApiController::class, 'index'])
|
||||
->name('api.comments.latest');
|
||||
|
||||
Route::middleware(['web'])
|
||||
->prefix('artworks')
|
||||
->name('api.artworks.awards.show.')
|
||||
@@ -207,3 +221,151 @@ Route::middleware(['web', 'auth', 'normalize.username'])->group(function () {
|
||||
->whereNumber('id')
|
||||
->name('api.users.follow');
|
||||
});
|
||||
|
||||
// ── Comment CRUD ──────────────────────────────────────────────────────────────
|
||||
// GET /api/artworks/{id}/comments list comments (public)
|
||||
// POST /api/artworks/{id}/comments post a comment (auth)
|
||||
// PUT /api/artworks/{id}/comments/{commentId} edit own comment (auth)
|
||||
// DELETE /api/artworks/{id}/comments/{commentId} delete own/admin (auth)
|
||||
|
||||
Route::middleware(['web', 'throttle:60,1'])
|
||||
->get('artworks/{id}/comments', [\App\Http\Controllers\Api\ArtworkCommentController::class, 'index'])
|
||||
->whereNumber('id')
|
||||
->name('api.artworks.comments.index');
|
||||
|
||||
Route::middleware(['web', 'auth', 'normalize.username', 'throttle:30,1'])->group(function () {
|
||||
Route::post('artworks/{id}/comments', [\App\Http\Controllers\Api\ArtworkCommentController::class, 'store'])
|
||||
->whereNumber('id')
|
||||
->name('api.artworks.comments.store');
|
||||
|
||||
Route::put('artworks/{id}/comments/{commentId}', [\App\Http\Controllers\Api\ArtworkCommentController::class, 'update'])
|
||||
->whereNumber(['id', 'commentId'])
|
||||
->name('api.artworks.comments.update');
|
||||
|
||||
Route::delete('artworks/{id}/comments/{commentId}', [\App\Http\Controllers\Api\ArtworkCommentController::class, 'destroy'])
|
||||
->whereNumber(['id', 'commentId'])
|
||||
->name('api.artworks.comments.destroy');
|
||||
});
|
||||
|
||||
// ── Reactions ─────────────────────────────────────────────────────────────────
|
||||
// GET /api/artworks/{id}/reactions list artwork reaction totals (public)
|
||||
// POST /api/artworks/{id}/reactions toggle artwork reaction (auth)
|
||||
// GET /api/comments/{id}/reactions list comment reaction totals (public)
|
||||
// POST /api/comments/{id}/reactions toggle comment reaction (auth)
|
||||
|
||||
Route::middleware(['web', 'throttle:60,1'])->group(function () {
|
||||
Route::get('artworks/{id}/reactions', [\App\Http\Controllers\Api\ReactionController::class, 'artworkReactions'])
|
||||
->whereNumber('id')
|
||||
->name('api.artworks.reactions.index');
|
||||
|
||||
Route::get('comments/{id}/reactions', [\App\Http\Controllers\Api\ReactionController::class, 'commentReactions'])
|
||||
->whereNumber('id')
|
||||
->name('api.comments.reactions.index');
|
||||
});
|
||||
|
||||
Route::middleware(['web', 'auth', 'normalize.username', 'throttle:60,1'])->group(function () {
|
||||
Route::post('artworks/{id}/reactions', [\App\Http\Controllers\Api\ReactionController::class, 'toggleArtworkReaction'])
|
||||
->whereNumber('id')
|
||||
->name('api.artworks.reactions.toggle');
|
||||
|
||||
Route::post('comments/{id}/reactions', [\App\Http\Controllers\Api\ReactionController::class, 'toggleCommentReaction'])
|
||||
->whereNumber('id')
|
||||
->name('api.comments.reactions.toggle');
|
||||
});
|
||||
|
||||
// ── Follow system ─────────────────────────────────────────────────────────────
|
||||
// POST /api/user/{username}/follow → follow a user
|
||||
// DELETE /api/user/{username}/follow → unfollow a user
|
||||
// GET /api/user/{username}/followers → paginated followers (public)
|
||||
// GET /api/user/{username}/following → paginated following (public)
|
||||
Route::middleware(['web', 'throttle:60,1'])
|
||||
->prefix('user')
|
||||
->name('api.user.follow.')
|
||||
->group(function () {
|
||||
// Public: list followers / following
|
||||
Route::get('{username}/followers', [\App\Http\Controllers\Api\FollowController::class, 'followers'])
|
||||
->where('username', '[A-Za-z0-9_-]{3,20}')
|
||||
->name('followers');
|
||||
|
||||
Route::get('{username}/following', [\App\Http\Controllers\Api\FollowController::class, 'following'])
|
||||
->where('username', '[A-Za-z0-9_-]{3,20}')
|
||||
->name('following');
|
||||
|
||||
// Auth-required: follow / unfollow
|
||||
Route::middleware(['auth', 'normalize.username'])->group(function () {
|
||||
Route::post('{username}/follow', [\App\Http\Controllers\Api\FollowController::class, 'follow'])
|
||||
->where('username', '[A-Za-z0-9_-]{3,20}')
|
||||
->name('follow');
|
||||
|
||||
Route::delete('{username}/follow', [\App\Http\Controllers\Api\FollowController::class, 'unfollow'])
|
||||
->where('username', '[A-Za-z0-9_-]{3,20}')
|
||||
->name('unfollow');
|
||||
});
|
||||
});
|
||||
|
||||
// ── Messaging ────────────────────────────────────────────────────────────────
|
||||
// GET /api/messages/conversations → list conversations
|
||||
// POST /api/messages/conversation → create conversation
|
||||
// GET /api/messages/conversation/{id} → show conversation
|
||||
// GET /api/messages/{conversation_id} → paginated messages
|
||||
// POST /api/messages/{conversation_id} → send message
|
||||
// POST /api/messages/{conversation_id}/read → mark as read
|
||||
// POST /api/messages/{conversation_id}/archive → toggle archive
|
||||
// POST /api/messages/{conversation_id}/mute → toggle mute
|
||||
// DELETE /api/messages/{conversation_id}/leave → leave conversation
|
||||
// POST /api/messages/{conversation_id}/add-user → add user (admin)
|
||||
// DELETE /api/messages/{conversation_id}/remove-user → remove user (admin)
|
||||
// POST /api/messages/{conversation_id}/rename → rename group (admin)
|
||||
// POST /api/messages/{conversation_id}/{message_id}/react → add reaction
|
||||
// DELETE /api/messages/{conversation_id}/{message_id}/react → remove reaction
|
||||
// DELETE /api/messages/message/{message_id} → soft-delete message
|
||||
Route::middleware(['web', 'auth', 'normalize.username', 'throttle:60,1'])
|
||||
->prefix('messages')
|
||||
->name('api.messages.')
|
||||
->group(function () {
|
||||
Route::get('settings', [\App\Http\Controllers\Api\Messaging\MessagingSettingsController::class, 'show'])->name('settings.show');
|
||||
Route::patch('settings', [\App\Http\Controllers\Api\Messaging\MessagingSettingsController::class, 'update'])->name('settings.update');
|
||||
|
||||
Route::get('conversations', [\App\Http\Controllers\Api\Messaging\ConversationController::class, 'index'])->name('conversations.index');
|
||||
Route::post('conversation', [\App\Http\Controllers\Api\Messaging\ConversationController::class, 'store'])->middleware('throttle:messages-send')->name('conversations.store');
|
||||
Route::get('conversation/{id}', [\App\Http\Controllers\Api\Messaging\ConversationController::class, 'show'])->whereNumber('id')->name('conversations.show');
|
||||
|
||||
Route::post('{conversation_id}/read', [\App\Http\Controllers\Api\Messaging\ConversationController::class, 'markRead'])->whereNumber('conversation_id')->name('read');
|
||||
Route::post('{conversation_id}/archive', [\App\Http\Controllers\Api\Messaging\ConversationController::class, 'archive'])->whereNumber('conversation_id')->name('archive');
|
||||
Route::post('{conversation_id}/mute', [\App\Http\Controllers\Api\Messaging\ConversationController::class, 'mute'])->whereNumber('conversation_id')->name('mute');
|
||||
Route::post('{conversation_id}/pin', [\App\Http\Controllers\Api\Messaging\ConversationController::class, 'pin'])->whereNumber('conversation_id')->name('pin');
|
||||
Route::post('{conversation_id}/unpin', [\App\Http\Controllers\Api\Messaging\ConversationController::class, 'unpin'])->whereNumber('conversation_id')->name('unpin');
|
||||
Route::delete('{conversation_id}/leave', [\App\Http\Controllers\Api\Messaging\ConversationController::class, 'leave'])->whereNumber('conversation_id')->name('leave');
|
||||
Route::post('{conversation_id}/add-user', [\App\Http\Controllers\Api\Messaging\ConversationController::class, 'addUser'])->whereNumber('conversation_id')->name('add-user');
|
||||
Route::delete('{conversation_id}/remove-user', [\App\Http\Controllers\Api\Messaging\ConversationController::class, 'removeUser'])->whereNumber('conversation_id')->name('remove-user');
|
||||
Route::post('{conversation_id}/rename', [\App\Http\Controllers\Api\Messaging\ConversationController::class, 'rename'])->whereNumber('conversation_id')->name('rename');
|
||||
|
||||
Route::get('search', [\App\Http\Controllers\Api\Messaging\MessageSearchController::class, 'index'])->name('search.index');
|
||||
Route::post('search/rebuild', [\App\Http\Controllers\Api\Messaging\MessageSearchController::class, 'rebuild'])->name('search.rebuild');
|
||||
|
||||
Route::get('{conversation_id}', [\App\Http\Controllers\Api\Messaging\MessageController::class, 'index'])->whereNumber('conversation_id')->name('messages.index');
|
||||
Route::post('{conversation_id}', [\App\Http\Controllers\Api\Messaging\MessageController::class, 'store'])->middleware('throttle:messages-send')->whereNumber('conversation_id')->name('messages.store');
|
||||
|
||||
Route::post('{conversation_id}/typing', [\App\Http\Controllers\Api\Messaging\TypingController::class, 'start'])->whereNumber('conversation_id')->name('typing.start');
|
||||
Route::post('{conversation_id}/typing/stop', [\App\Http\Controllers\Api\Messaging\TypingController::class, 'stop'])->whereNumber('conversation_id')->name('typing.stop');
|
||||
Route::get('{conversation_id}/typing', [\App\Http\Controllers\Api\Messaging\TypingController::class, 'index'])->whereNumber('conversation_id')->name('typing.index');
|
||||
|
||||
Route::post('{conversation_id}/{message_id}/react', [\App\Http\Controllers\Api\Messaging\MessageController::class, 'react'])->whereNumber(['conversation_id', 'message_id'])->name('react');
|
||||
Route::delete('{conversation_id}/{message_id}/react', [\App\Http\Controllers\Api\Messaging\MessageController::class, 'unreact'])->whereNumber(['conversation_id', 'message_id'])->name('unreact');
|
||||
|
||||
Route::post('{message_id}/reactions', [\App\Http\Controllers\Api\Messaging\MessageController::class, 'reactByMessage'])
|
||||
->middleware('throttle:messages-react')
|
||||
->whereNumber('message_id')
|
||||
->name('messages.reactions.toggle');
|
||||
Route::delete('{message_id}/reactions', [\App\Http\Controllers\Api\Messaging\MessageController::class, 'unreactByMessage'])
|
||||
->middleware('throttle:messages-react')
|
||||
->whereNumber('message_id')
|
||||
->name('messages.reactions.delete');
|
||||
|
||||
Route::patch('message/{message_id}', [\App\Http\Controllers\Api\Messaging\MessageController::class, 'update'])->whereNumber('message_id')->name('messages.update');
|
||||
Route::delete('message/{message_id}', [\App\Http\Controllers\Api\Messaging\MessageController::class, 'destroy'])->whereNumber('message_id')->name('messages.destroy');
|
||||
});
|
||||
|
||||
Route::middleware(['web', 'auth', 'normalize.username', 'throttle:60,1'])
|
||||
->post('reports', [\App\Http\Controllers\Api\ReportController::class, 'store'])
|
||||
->name('api.reports.store');
|
||||
|
||||
Reference in New Issue
Block a user