fix users without session cannot view shared videos
This commit is contained in:
parent
d6f2be85d2
commit
0f58a9fda4
1 changed files with 17 additions and 15 deletions
|
|
@ -65,24 +65,26 @@ export const videoRouter = createTRPCRouter({
|
||||||
throw new TRPCError({ code: "NOT_FOUND" });
|
throw new TRPCError({ code: "NOT_FOUND" });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!session || (video.userId !== session?.user.id && !video.sharing)) {
|
if (video.userId !== session?.user.id && !video.sharing) {
|
||||||
throw new TRPCError({ code: "FORBIDDEN" });
|
throw new TRPCError({ code: "FORBIDDEN" });
|
||||||
}
|
}
|
||||||
|
|
||||||
posthog.capture({
|
if (session) {
|
||||||
distinctId: session.user.id,
|
posthog.capture({
|
||||||
event: "viewing video",
|
distinctId: session.user.id,
|
||||||
properties: {
|
event: "viewing video",
|
||||||
videoId: video.id,
|
properties: {
|
||||||
videoCreatedAt: video.createdAt,
|
videoId: video.id,
|
||||||
videoUpdatedAt: video.updatedAt,
|
videoCreatedAt: video.createdAt,
|
||||||
videoUser: video.user.id,
|
videoUpdatedAt: video.updatedAt,
|
||||||
videoSharing: video.sharing,
|
videoUser: video.user.id,
|
||||||
videoDeleteAfterLinkExpires: video.delete_after_link_expires,
|
videoSharing: video.sharing,
|
||||||
videoShareLinkExpiresAt: video.shareLinkExpiresAt,
|
videoDeleteAfterLinkExpires: video.delete_after_link_expires,
|
||||||
},
|
videoShareLinkExpiresAt: video.shareLinkExpiresAt,
|
||||||
});
|
},
|
||||||
void posthog.shutdownAsync();
|
});
|
||||||
|
void posthog.shutdownAsync();
|
||||||
|
}
|
||||||
|
|
||||||
const getObjectCommand = new GetObjectCommand({
|
const getObjectCommand = new GetObjectCommand({
|
||||||
Bucket: env.AWS_BUCKET_NAME,
|
Bucket: env.AWS_BUCKET_NAME,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue