fix(chat): keep rectification sessions findable and keep the delivery card
Rectification answers now advance chat_sessions.updated_at (BUG-704). A ?c= id missing from the loaded page is fetched before anyone may call it deleted (BUG-705). The range card no longer has a post-card tie-break button; live questions leave the card visible with adopt locked (BUG-706/708). Spoken copy bans 相对支持度 (BUG-709). Task docs assigned 700-704; qizheng already took 700-703.
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
-- BUG-704: rectification activity must advance chat_sessions.updated_at the
|
||||
-- same way append_consultation_question does. Open / GET / metadata PATCH
|
||||
-- still must not bump it (BUG-553).
|
||||
|
||||
begin;
|
||||
|
||||
do $migration$
|
||||
begin
|
||||
if current_user <> 'schema_owner' then
|
||||
raise exception 'rectification_touch_chat_session_requires_schema_owner'
|
||||
using errcode = '42501';
|
||||
end if;
|
||||
end
|
||||
$migration$;
|
||||
|
||||
create or replace function public.touch_chat_session_from_rectification_case()
|
||||
returns trigger
|
||||
language plpgsql
|
||||
security definer
|
||||
set search_path = ''
|
||||
as $$
|
||||
begin
|
||||
if tg_op = 'UPDATE'
|
||||
and new.last_activity_at is not distinct from old.last_activity_at then
|
||||
return new;
|
||||
end if;
|
||||
update public.chat_sessions
|
||||
set updated_at = new.last_activity_at
|
||||
where id = new.session_id
|
||||
and user_id = new.user_id
|
||||
and session_type = 'birth_time_rectification'
|
||||
and updated_at is distinct from new.last_activity_at
|
||||
and updated_at < new.last_activity_at;
|
||||
return new;
|
||||
end;
|
||||
$$;
|
||||
|
||||
drop trigger if exists agentic_rectification_cases_touch_chat_session
|
||||
on public.agentic_rectification_cases;
|
||||
|
||||
create trigger agentic_rectification_cases_touch_chat_session
|
||||
after update of last_activity_at on public.agentic_rectification_cases
|
||||
for each row
|
||||
execute function public.touch_chat_session_from_rectification_case();
|
||||
|
||||
revoke all on function public.touch_chat_session_from_rectification_case()
|
||||
from public, anon, authenticated;
|
||||
grant execute on function public.touch_chat_session_from_rectification_case()
|
||||
to schema_owner;
|
||||
|
||||
commit;
|
||||
Reference in New Issue
Block a user