From 0f9bd2fa782f2f8f757abd63a6ec9066f015e47e Mon Sep 17 00:00:00 2001 From: hz Date: Sat, 11 Jul 2026 03:16:11 -0500 Subject: [PATCH] Harden media and follow-up handling --- api/QuestionsApi/Services/QuestionMediaStore.cs | 10 ++++++++-- api/QuestionsApi/Services/QuestionStore.cs | 2 ++ scripts/ui/question_player.gd | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/api/QuestionsApi/Services/QuestionMediaStore.cs b/api/QuestionsApi/Services/QuestionMediaStore.cs index 05dab59..cd3598f 100644 --- a/api/QuestionsApi/Services/QuestionMediaStore.cs +++ b/api/QuestionsApi/Services/QuestionMediaStore.cs @@ -1,4 +1,5 @@ using MongoDB.Driver; +using MongoDB.Bson; using QuestionsApi.Models; namespace QuestionsApi.Services; @@ -29,6 +30,11 @@ public class QuestionMediaStore return asset; } - public async Task GetAsync(string id) => - await _col.Find(asset => asset.Id == id).FirstOrDefaultAsync(); + public async Task GetAsync(string id) + { + if (!ObjectId.TryParse(id, out _)) + return null; + + return await _col.Find(asset => asset.Id == id).FirstOrDefaultAsync(); + } } diff --git a/api/QuestionsApi/Services/QuestionStore.cs b/api/QuestionsApi/Services/QuestionStore.cs index 16857be..f10aafe 100644 --- a/api/QuestionsApi/Services/QuestionStore.cs +++ b/api/QuestionsApi/Services/QuestionStore.cs @@ -1,4 +1,5 @@ using MongoDB.Driver; +using MongoDB.Bson; using QuestionsApi.Models; namespace QuestionsApi.Services; @@ -102,6 +103,7 @@ public class QuestionStore } else { + question.Id = ObjectId.GenerateNewId().ToString(); question.CreatedUtc = DateTime.UtcNow; } diff --git a/scripts/ui/question_player.gd b/scripts/ui/question_player.gd index 130f192..9d6bae7 100644 --- a/scripts/ui/question_player.gd +++ b/scripts/ui/question_player.gd @@ -1053,7 +1053,7 @@ func _choice_row_size(_index: int, choice_id: String, has_visible_followup: bool if followup_states.has(choice_id): var state: Dictionary = followup_states[choice_id] if bool(state.get("collapsed", false)): - return Vector2(0, 110) + return Vector2(0, 136) return Vector2(0, 300)