@@ -3,7 +3,7 @@ import { cookies } from "next/headers";
33import { z } from "zod" ;
44import { blob , user } from "@/drizzle/schema" ;
55import type { User } from "@/drizzle/types" ;
6- import { opsUser } from "@/ops/drizzle/schema" ;
6+ import { opsOrganization , opsUser } from "@/ops/drizzle/schema" ;
77import { getOpsDatabase } from "@/ops/useOps" ;
88import { createTRPCRouter , protectedProcedure } from "../init" ;
99
@@ -32,27 +32,42 @@ export const settingsRouter = createTRPCRouter({
3232 maxAge : 60 * 60 * 24 * 365 ,
3333 } ) ;
3434
35- // Update main user database
3635 await ctx . db
3736 . update ( user )
3837 . set ( { timeZone : input , lastActiveAt : new Date ( ) } )
3938 . where ( eq ( user . id , ctx . userId ) )
4039 . execute ( ) ;
4140
42- // Also update ops user database for email scheduling
4341 try {
4442 const opsDb = await getOpsDatabase ( ) ;
43+
4544 await opsDb
4645 . update ( opsUser )
47- . set ( { timeZone : input , lastActiveAt : new Date ( ) } )
46+ . set ( {
47+ timeZone : input ,
48+ lastActiveAt : new Date ( ) ,
49+ markedForDeletionAt : null ,
50+ finalWarningAt : null ,
51+ } )
4852 . where ( eq ( opsUser . id , ctx . userId ) )
4953 . execute ( ) ;
54+
55+ if ( ctx . orgId ) {
56+ await opsDb
57+ . update ( opsOrganization )
58+ . set ( {
59+ lastActiveAt : new Date ( ) ,
60+ markedForDeletionAt : null ,
61+ finalWarningAt : null ,
62+ } )
63+ . where ( eq ( opsUser . id , ctx . orgId ) )
64+ . execute ( ) ;
65+ }
5066 } catch ( error ) {
5167 console . error (
5268 "[Settings] Error updating timezone in ops database:" ,
5369 error ,
5470 ) ;
55- // Don't throw error to avoid blocking the main update
5671 }
5772 } ) ,
5873 getTimezone : protectedProcedure . output ( z . string ( ) ) . query ( async ( ) => {
0 commit comments