({ path: filePath, repo: repoName, ref }: FileSourceRequest, { source }: { source?: string } = {})
| 101 | }); |
| 102 | |
| 103 | export const getFileSource = async ({ path: filePath, repo: repoName, ref }: FileSourceRequest, { source }: { source?: string } = {}): Promise<FileSourceResponse | ServiceError> => sew(() => withOptionalAuth(async ({ org, prisma, user }) => { |
| 104 | if (user) { |
| 105 | const resolvedSource = source ?? (await headers()).get('X-Sourcebot-Client-Source') ?? undefined; |
| 106 | await createAudit({ |
| 107 | action: 'user.fetched_file_source', |
| 108 | actor: { id: user.id, type: 'user' }, |
| 109 | target: { id: org.id.toString(), type: 'org' }, |
| 110 | orgId: org.id, |
| 111 | metadata: { source: resolvedSource }, |
| 112 | }); |
| 113 | } |
| 114 | |
| 115 | return getFileSourceForRepo({ path: filePath, repo: repoName, ref }, { org, prisma }); |
| 116 | })); |
no test coverage detected