Skip to content

Commit 71d439a

Browse files
committed
fix: record activity if applicable instead of throwing
1 parent 1dd11d2 commit 71d439a

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

apps/api/src/trpc.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,16 @@ const logActivityMiddleware = middleware(async (opts) => {
5757
if (type !== undefined) {
5858
// const rawInput = opts.getRawInput() as { id: number }
5959
const resultData = result.data as { id?: string }
60-
logger.verbose(`Recording activity ${opts.path} of type ${type}`)
6160
const subjectId = type === 'CREATE' ? resultData?.id : '9999'
62-
if (!subjectId) throw new TRPCError({ code: 'INTERNAL_SERVER_ERROR', message: 'No subjectId found' })
63-
await logActivity({
64-
subjectId,
65-
subjectType: subject || 'NO_SUBJECT',
66-
causerId: opts.ctx.authenticated ? opts.ctx.accountId : undefined,
67-
type,
68-
})
61+
if (subjectId) {
62+
logger.verbose(`Recording activity ${opts.path} of type ${type}`)
63+
await logActivity({
64+
subjectId,
65+
subjectType: subject || 'NO_SUBJECT',
66+
causerId: opts.ctx.authenticated ? opts.ctx.accountId : undefined,
67+
type,
68+
})
69+
}
6970
}
7071
}
7172

0 commit comments

Comments
 (0)