From d9d35c47a86aa83a6f122d70299f85a8e836524a Mon Sep 17 00:00:00 2001 From: Spirtix Date: Mon, 14 Apr 2025 12:06:37 +0200 Subject: [PATCH] autofill common payload instead of saving to db --- src/Services/MissionService.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Services/MissionService.cs b/src/Services/MissionService.cs index 2f26d30..a425425 100644 --- a/src/Services/MissionService.cs +++ b/src/Services/MissionService.cs @@ -219,8 +219,12 @@ public class MissionService { Schema.Task? t = mission.Tasks.Find(x => x.TaskID == task.Id); if (t != null) { - if (task.Completed) t.Completed = 1; - t.Payload = task.Payload; + if (task.Completed) { + t.Completed = 1; + t.Payload = task.Payload ?? "\r\n\r\n true\r\n"; + } else { + t.Payload = task.Payload; + } } } @@ -249,9 +253,14 @@ public class MissionService { } } - private void SetTaskProgressDB(int missionId, int taskId, int userId, bool completed, string xmlPayload) { + private void SetTaskProgressDB(int missionId, int taskId, int userId, bool completed, string? xmlPayload) { Model.TaskStatus? status = ctx.TaskStatuses.FirstOrDefault(task => task.Id == taskId && task.MissionId == missionId && task.VikingId == userId); + // Based on the observation that no payloads on completed missions are null + // This is the most common task payload, so if the mission is completed with this payload we can set the payload to null and let the server autofill + if (completed && xmlPayload == "\r\n\r\n true\r\n") + xmlPayload = null; + if (status is null) { status = new Model.TaskStatus { Id = taskId,