import { MiddlewareRequest } from "../middleware";
import { IAuthMiddlewareParams } from "../middleware/auth";
import { Request } from "@autoplex/webserver";

export class RequestMovieRequest<T extends IAuthMiddlewareParams> extends Request<T>
{
	/**
	 * Ensure the user is able to request movies
	 */
	public async isAuthorized(request: MiddlewareRequest<T>) {
		let user = request.middlewareParams.auth.user;
		let quota = await user.availableQuota();
		return quota === null || quota > 0;
	}
}
