diff --git a/ci/apiv2/test_task.py b/ci/apiv2/test_task.py index 09c99f6d3..61b9fc0f2 100644 --- a/ci/apiv2/test_task.py +++ b/ci/apiv2/test_task.py @@ -1,4 +1,4 @@ -from hashtopolis import Task +from hashtopolis import Task, TaskWrapper from utils import BaseTest @@ -75,3 +75,15 @@ def test_task_with_file(self): task = self.create_task(hashlist, extra_payload=extra_payload) obj = Task.objects.get(pk=task.id, expand='files') self.assertListEqual([x.id for x in files], [x.id for x in obj.files_set]) + + def test_task_update_priority(self): + task = self.create_test_object() + obj = TaskWrapper.objects.get(pk=task.taskWrapperId) + self.assertEqual(task.priority, obj.priority) + + new_priority = task.priority + 1234 + task.priority = new_priority + task.save() + + obj = TaskWrapper.objects.get(pk=task.taskWrapperId) + self.assertEqual(new_priority, obj.priority) \ No newline at end of file diff --git a/src/inc/apiv2/model/tasks.routes.php b/src/inc/apiv2/model/tasks.routes.php index 24f7986cd..8199d6cf2 100644 --- a/src/inc/apiv2/model/tasks.routes.php +++ b/src/inc/apiv2/model/tasks.routes.php @@ -104,6 +104,13 @@ public function updateObject(object $object, $data, $processed = []): void { TaskUtils::archiveTask($object->getId(), $this->getCurrentUser()); } + /* Update connected TaskWrapper priority as well */ + $key = Task::PRIORITY; + if (array_key_exists($key, $data)) { + array_push($processed, $key); + TaskUtils::updatePriority($object->getId(), $data[Task::PRIORITY], $this->getCurrentUser()); + } + parent::updateObject($object, $data, $processed); } }