mirror of
https://github.com/discourse/discourse-ai.git
synced 2025-06-26 09:32:40 +00:00
FIX: add safe navigation to serializer include conditions (#1349)
In some rare cases a post can exist without a topic
This commit is contained in:
parent
296aa24df1
commit
de0625571b
@ -140,7 +140,8 @@ module DiscourseAi
|
||||
:topic_view,
|
||||
:is_bot_pm,
|
||||
include_condition: -> do
|
||||
object.personal_message && object.topic.custom_fields[TOPIC_AI_BOT_PM_FIELD]
|
||||
object.topic && object.personal_message &&
|
||||
object.topic.custom_fields[TOPIC_AI_BOT_PM_FIELD]
|
||||
end,
|
||||
) { true }
|
||||
|
||||
@ -148,7 +149,7 @@ module DiscourseAi
|
||||
:post,
|
||||
:llm_name,
|
||||
include_condition: -> do
|
||||
object.topic.private_message? && object.custom_fields[POST_AI_LLM_NAME_FIELD]
|
||||
object&.topic&.private_message? && object.custom_fields[POST_AI_LLM_NAME_FIELD]
|
||||
end,
|
||||
) { object.custom_fields[POST_AI_LLM_NAME_FIELD] }
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user