(inviteId: string)
| 164 | |
| 165 | // eslint-disable-next-line authz/require-auth-wrapper -- runs pre-org-membership; uses getAuthenticatedUser() directly since the invitee is not yet a member |
| 166 | export const getInviteInfo = async (inviteId: string) => sew(async () => { |
| 167 | const authResult = await getAuthenticatedUser(); |
| 168 | if (!authResult) { |
| 169 | return notAuthenticated(); |
| 170 | } |
| 171 | |
| 172 | const { user } = authResult; |
| 173 | |
| 174 | const invite = await __unsafePrisma.invite.findUnique({ |
| 175 | where: { |
| 176 | id: inviteId, |
| 177 | }, |
| 178 | include: { |
| 179 | org: true, |
| 180 | host: true, |
| 181 | } |
| 182 | }); |
| 183 | |
| 184 | if (!invite) { |
| 185 | return notFound(); |
| 186 | } |
| 187 | |
| 188 | if (invite.recipientEmail !== user.email) { |
| 189 | return notFound(); |
| 190 | } |
| 191 | |
| 192 | return { |
| 193 | id: invite.id, |
| 194 | orgName: invite.org.name, |
| 195 | orgImageUrl: invite.org.imageUrl ?? undefined, |
| 196 | host: { |
| 197 | name: invite.host.name ?? undefined, |
| 198 | email: invite.host.email, |
| 199 | avatarUrl: invite.host.image ?? undefined, |
| 200 | }, |
| 201 | recipient: { |
| 202 | name: user.name ?? undefined, |
| 203 | email: user.email, |
| 204 | } |
| 205 | }; |
| 206 | }); |
no test coverage detected