2023-02-19 01:40:12 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use Illuminate\Support\Facades\Route;
|
|
|
|
use App\Http\Controllers\AuthController;
|
2023-02-23 17:34:32 +01:00
|
|
|
use App\Http\Controllers\UserController;
|
2023-03-15 23:09:02 +01:00
|
|
|
use App\Http\Controllers\ScheduleSlotsController;
|
2023-02-23 17:34:32 +01:00
|
|
|
use App\Http\Controllers\AvailabilityController;
|
2023-02-23 22:19:42 +01:00
|
|
|
use Illuminate\Http\Request;
|
|
|
|
use Illuminate\Support\Facades\Artisan;
|
2023-06-06 23:50:52 +02:00
|
|
|
use Telegram\Bot\Laravel\Http\Middleware\ValidateWebhook;
|
|
|
|
use Telegram\Bot\Laravel\Http\Controllers\WebhookController;
|
2023-02-19 01:40:12 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
| API Routes
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
| Here is where you can register API routes for your application. These
|
|
|
|
| routes are loaded by the RouteServiceProvider and all of them will
|
|
|
|
| be assigned to the "api" middleware group. Make something great!
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
Route::post('/register', [AuthController::class, 'register']);
|
|
|
|
Route::post('/login', [AuthController::class, 'login']);
|
|
|
|
|
2023-06-06 18:53:49 +02:00
|
|
|
Route::middleware('auth:web')->group( function () {
|
2023-02-23 00:23:56 +01:00
|
|
|
Route::get('/me', [AuthController::class, 'me']);
|
|
|
|
Route::post('/me', [AuthController::class, 'me']);
|
2023-06-06 18:53:49 +02:00
|
|
|
|
|
|
|
Route::post('/impersonate/{user}', [AuthController::class, 'impersonate']);
|
|
|
|
Route::post('/stop_impersonating', [AuthController::class, 'stopImpersonating']);
|
2023-02-23 00:23:56 +01:00
|
|
|
|
2023-02-23 17:34:32 +01:00
|
|
|
Route::get('/list', [UserController::class, 'index']);
|
|
|
|
|
2023-03-15 23:09:02 +01:00
|
|
|
Route::get('/schedules', [ScheduleSlotsController::class, 'index']);
|
|
|
|
Route::post('/schedules', [ScheduleSlotsController::class, 'store']);
|
|
|
|
|
2023-02-23 17:34:32 +01:00
|
|
|
Route::get('/availability', [AvailabilityController::class, 'get']);
|
|
|
|
Route::post('/availability', [AvailabilityController::class, 'updateAvailability']);
|
|
|
|
Route::post('/manual_mode', [AvailabilityController::class, 'updateAvailabilityManualMode']);
|
|
|
|
|
2023-02-23 00:23:56 +01:00
|
|
|
Route::post('/logout', [AuthController::class, 'logout']);
|
2023-02-19 01:40:12 +01:00
|
|
|
});
|
2023-02-23 22:19:42 +01:00
|
|
|
|
2023-02-23 23:19:39 +01:00
|
|
|
Route::get('/owner_image', function() {
|
|
|
|
return response()
|
|
|
|
->file(
|
|
|
|
resource_path('images') . DIRECTORY_SEPARATOR . config("features.owner_image"),
|
|
|
|
['Cache-control' => 'max-age=2678400']
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2023-02-23 22:19:42 +01:00
|
|
|
Route::post('/cron/execute', function(Request $request) {
|
|
|
|
//Go to app/Console/Kernel.php to view schedules
|
|
|
|
if(config('cron.external_cron_enabled') && $request->header('Cron') == config('cron.execution_code')) {
|
|
|
|
Artisan::call('schedule:run');
|
|
|
|
} else {
|
|
|
|
return response('Access Denied', 403);
|
|
|
|
}
|
|
|
|
});
|
2023-06-06 23:50:52 +02:00
|
|
|
|
|
|
|
//TODO: remove this and open issue on https://github.com/telegram-bot-sdk/laravel since named route not working
|
|
|
|
Route::group(['middleware' => ValidateWebhook::class], function (): void {
|
|
|
|
Route::post('/telegram/{bot}/webhook', Telegram\Bot\Laravel\Http\Controllers\WebhookController::class)->name('telegram.bot.webhook');
|
|
|
|
});
|