From 4b0d1786ddd4569b3cef4191ccabf1a1d129f35b Mon Sep 17 00:00:00 2001 From: Zaid Humaimidi Date: Mon, 28 Aug 2023 18:19:23 -0700 Subject: [PATCH] Strip extraneous properties from task objects --- ui/store.ts | 11 +++++++---- ui/task-queue.ts | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/ui/store.ts b/ui/store.ts index 8d51040..8c977ce 100644 --- a/ui/store.ts +++ b/ui/store.ts @@ -21,7 +21,7 @@ import m from "mithril"; import { stringify } from "../lib/common/expression/parser"; import { or, and, evaluate } from "../lib/common/expression/util"; import memoize from "../lib/common/memoize"; -import { QueryOptions, Expression } from "../lib/types"; +import { QueryOptions, Expression, Task } from "../lib/types"; import * as notifications from "./notifications"; import { configSnapshot, genieacsVersion } from "./config"; import { QueueTask } from "./task-queue"; @@ -60,7 +60,6 @@ const resources: Resources = {}; for (const r of [ "devices", "faults", - "files", "presets", "provisions", "virtualParameters", @@ -596,15 +595,19 @@ export function postTasks( deviceId: string, tasks: QueueTask[] ): Promise { + const tasks2: Task[] = []; for (const t of tasks) { t.status = "pending"; - t.device = deviceId; + const t2 = Object.assign({}, t); + delete t2.device; + delete t2.status; + tasks2.push(t2); } return xhrRequest({ method: "POST", url: `api/devices/${encodeURIComponent(deviceId)}/tasks`, - body: tasks, + body: tasks2, extract: (xhr) => { if (xhr.status === 403) throw new Error("Not authorized"); if (!xhr.status) throw new Error("Server is unreachable"); diff --git a/ui/task-queue.ts b/ui/task-queue.ts index 6fd4447..da0423c 100644 --- a/ui/task-queue.ts +++ b/ui/task-queue.ts @@ -98,7 +98,7 @@ export function commit( _tasks: QueueTask[] ) => void ): Promise { - const devices: { [deviceId: string]: any[] } = {}; + const devices: { [deviceId: string]: QueueTask[] } = {}; if (!canQueue(tasks)) return Promise.reject(new Error("Too many tasks in queue"));