1
This commit is contained in:
@@ -1572,7 +1572,34 @@ fn delete_custom_world_agent_session_tx(
|
||||
.filter(|row| row.owner_user_id == input.owner_user_id)
|
||||
.ok_or_else(|| "custom_world_agent_session 不存在".to_string())?;
|
||||
if session.stage == RpgAgentStage::Published {
|
||||
return Err("已发布 RPG 作品请通过 profile 删除".to_string());
|
||||
let published_profile = ctx
|
||||
.db
|
||||
.custom_world_profile()
|
||||
.iter()
|
||||
.find(|row| {
|
||||
row.owner_user_id == input.owner_user_id
|
||||
&& row.source_agent_session_id.as_deref() == Some(input.session_id.as_str())
|
||||
&& row.deleted_at.is_none()
|
||||
})
|
||||
.ok_or_else(|| "已发布 RPG 作品缺少关联 profile,无法删除".to_string())?;
|
||||
|
||||
// 作品卡可能只携带源 Agent sessionId。这里把“按 session 删除已发布作品”收敛为
|
||||
// profile 软删除,避免前端误入草稿删除接口时把业务分支放大成上游 502。
|
||||
delete_custom_world_profile_record(
|
||||
ctx,
|
||||
CustomWorldProfileDeleteInput {
|
||||
profile_id: published_profile.profile_id,
|
||||
owner_user_id: input.owner_user_id.clone(),
|
||||
deleted_at_micros: ctx.timestamp.to_micros_since_unix_epoch(),
|
||||
},
|
||||
)?;
|
||||
|
||||
return list_custom_world_work_snapshots(
|
||||
ctx,
|
||||
CustomWorldWorksListInput {
|
||||
owner_user_id: input.owner_user_id,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// 删除纯 Agent 草稿时同步清理消息、操作与草稿卡,避免作品列表消失后残留孤儿数据。
|
||||
|
||||
Reference in New Issue
Block a user