<?php

// FileServerController
use App\Http\Controllers\WebhookController;

Route::name('fs.')->controller(\App\Http\Controllers\FileServerController::class)->group(function () {
    Route::post('/fs/upload-chunk/{section}', 'uploadChunk' )->name('uploadchunk')
        ->where([ 'section' => 'translations|romhacks|homebrew|utilities|documents|lua-scripts|tutorials' ])
        ->middleware('xf.auth:romhackplaza.canSubmitEntry');
    ;

    Route::get( '/fs/download/{entry_id}/{file:file_uuid}', 'download' )->name('download')
        ->where(['entry_id' => '[0-9]+']);
});

// WebhookController
Route::name('webhook.')->controller(WebhookController::class)->group(function () {
    Route::post('/webhook/xenforo-new-post', 'XenForoNewPost' )->name('xenforo_new_post');
});

// TemporaryFileController
Route::name('tempfile.')->controller(\App\Http\Controllers\TemporaryFileController::class)->group(function () {
    Route::post('/tempfile/upload', 'upload' )->name('upload')
        ->middleware(['xf.auth']);
});

// DynamicLoadController
Route::get( '/dynamic/hovercard/{user_id}', [ \App\Http\Controllers\DynamicLoadController::class, 'hovercard' ] )
    ->where(['user_id' => '[0-9]+'])
    ->name('dynamic.hovercard')
    ->middleware('throttle:60,1')
;
Route::get('/dynamic/activity/feed', [ \App\Http\Controllers\DynamicLoadController::class, 'activityFeed' ] )
    ->name('dynamic.activity.feed')
    ->middleware('throttle:60,1')
;
Route::middleware('xf.auth')->controller(\App\Http\Controllers\DynamicLoadController::class)->name('dynamic.')->prefix('/dynamic/')->group(function(){
    Route::get('/notifications', 'getNotifications' )->name('notifications');
    Route::post('/notifications/mark-all-read', 'markAllRead' )->name('markallread');
    Route::get('/conversations', 'getConversations' )->name('conversations');
});

// EntryFeaturedRequestController
Route::middleware('xf.auth')->name('featured.')->controller(\App\Http\Controllers\EntryFeaturedRequestController::class)->group(function(){
   Route::post('/entry/{entry:id}/featured', 'featuredRequest' )->name('request')->where(['entry' => '[0-9]+']);
});
