33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
|
|
import { RequestHandler, RequestType } from "../../RequestHandler";
|
||
|
|
import { FastifyRequest, FastifyReply } from 'fastify';
|
||
|
|
import { UserIsLoggedIn } from "../../requirements/user/UserIsLoggedIn";
|
||
|
|
import { UserCanUseApp } from "./UserCanUseApp";
|
||
|
|
import { FilesSync } from "../../../files/FilesSync";
|
||
|
|
import { Files } from "../../../files/Files";
|
||
|
|
|
||
|
|
|
||
|
|
export class AppsDeleteTaskHandler extends RequestHandler
|
||
|
|
{
|
||
|
|
static url = "/apps/delete-task";
|
||
|
|
constructor()
|
||
|
|
{
|
||
|
|
super( RequestType.POST, AppsDeleteTaskHandler.url, [ new UserIsLoggedIn(), new UserCanUseApp() ] );
|
||
|
|
}
|
||
|
|
|
||
|
|
async _handle( request:FastifyRequest, reply:FastifyReply )
|
||
|
|
{
|
||
|
|
let requestBody = request.body;
|
||
|
|
let appData = requestBody as { taskID: string, appID:string };
|
||
|
|
|
||
|
|
let user = await this.getUser();
|
||
|
|
|
||
|
|
let taskRemoved = this.ums.scheduler.cancelUserAppTask( appData.taskID, user.id, appData.appID );
|
||
|
|
|
||
|
|
if ( taskRemoved )
|
||
|
|
{
|
||
|
|
return this.sendInfo( "Task deleted: " + appData.appID + " " + appData.taskID );
|
||
|
|
}
|
||
|
|
|
||
|
|
return this.sendError( "Task not found: " + appData.appID + " " + appData.taskID );
|
||
|
|
}
|
||
|
|
}
|