Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
emranemran committed Mar 18, 2024
1 parent 91f0dfa commit 3b586d2
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions packages/api/src/controllers/stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ app.get("/sessions/:parentId", authorizer({}), async (req, res) => {
!stream ||
stream.deleted ||
(stream.userId !== req.user.id && !req.isUIAdmin) ||
stream.projectId !== req.project.id
stream.projectId !== req.project?.id
) {
res.status(404);
return res.json({ errors: ["not found"] });
Expand Down Expand Up @@ -709,7 +709,7 @@ app.get("/:id", authorizer({}), async (req, res) => {
if (
!stream ||
((stream.userId !== req.user.id || stream.deleted) && !req.user.admin) ||
stream.projectId !== req.project.id
stream.projectId !== req.project?.id
) {
// do not reveal that stream exists
res.status(404);
Expand Down Expand Up @@ -753,7 +753,7 @@ app.get("/playback/:playbackId", authorizer({}), async (req, res) => {
if (
!stream ||
((stream.userId !== req.user.id || stream.deleted) && !req.user.admin) ||
stream.projectId !== req.project.id
stream.projectId !== req.project?.id
) {
res.status(404);
return res.json({ errors: ["not found"] });
Expand Down Expand Up @@ -834,7 +834,7 @@ app.post(
!stream ||
((stream.userId !== req.user.id || stream.deleted) &&
!(req.user.admin && !stream.deleted)) ||
stream.projectId !== req.project.id
stream.projectId !== req.project?.id
) {
// do not reveal that stream exists
res.status(404);
Expand Down Expand Up @@ -1227,7 +1227,7 @@ app.post("/:id/heartbeat", authorizer({ anyAdmin: true }), async (req, res) => {
if (
!stream ||
(stream.deleted && !req.user.admin) ||
stream.projectId !== req.project.id
stream.projectId !== req.project?.id
) {
res.status(404);
return res.json({ errors: ["not found"] });
Expand All @@ -1251,7 +1251,7 @@ app.put(
if (
!stream ||
(stream.deleted && !req.user.admin) ||
stream.projectId !== req.project.id
stream.projectId !== req.project?.id
) {
res.status(404);
return res.json({ errors: ["not found"] });
Expand Down Expand Up @@ -1561,7 +1561,7 @@ app.post(

const stream = await db.stream.get(req.params.id);

if (!stream || stream.deleted || stream.projectId !== req.project.id) {
if (!stream || stream.deleted || stream.projectId !== req.project?.id) {
res.status(404);
return res.json({ errors: ["stream not found"] });
}
Expand Down Expand Up @@ -1650,7 +1650,7 @@ app.patch(

const exists = stream && !stream.deleted;
const hasAccess = stream?.userId === req.user.id || req.isUIAdmin;
if (!exists || !hasAccess || stream.projectId !== req.project.id) {
if (!exists || !hasAccess || stream.projectId !== req.project?.id) {
res.status(404);
return res.json({ errors: ["not found"] });
}
Expand Down Expand Up @@ -1729,7 +1729,7 @@ app.patch(
app.patch("/:id/record", authorizer({}), async (req, res) => {
const { id } = req.params;
const stream = await db.stream.get(id);
if (!stream || stream.deleted || stream.projectId !== req.project.id) {
if (!stream || stream.deleted || stream.projectId !== req.project?.id) {
res.status(404);
return res.json({ errors: ["not found"] });
}
Expand Down Expand Up @@ -1763,7 +1763,7 @@ app.delete("/:id", authorizer({}), async (req, res) => {
!stream ||
stream.deleted ||
(stream.userId !== req.user.id && !req.user.admin) ||
stream.projectId !== req.project.id
stream.projectId !== req.project?.id
) {
res.status(404);
return res.json({ errors: ["not found"] });
Expand Down Expand Up @@ -1828,7 +1828,7 @@ app.get("/:id/info", authorizer({}), async (req, res) => {
if (
!stream ||
(!req.user.admin && (stream.deleted || stream.userId !== req.user.id)) ||
stream.projectId !== req.project.id
stream.projectId !== req.project?.id
) {
res.status(404);
return res.json({
Expand Down Expand Up @@ -1868,7 +1868,7 @@ app.get("/:id/config", authorizer({ anyAdmin: true }), async (req, res) => {
!stream ||
stream.deleted ||
stream.suspended ||
stream.projectId !== req.project.id
stream.projectId !== req.project?.id
) {
res.status(404);
return res.json({
Expand Down Expand Up @@ -1904,7 +1904,7 @@ app.patch("/:id/suspended", authorizer({}), async (req, res) => {
if (
!stream ||
(!req.user.admin && (stream.deleted || stream.userId !== req.user.id)) ||
stream.projectId !== req.project.id
stream.projectId !== req.project?.id
) {
res.status(404);
return res.json({ errors: ["not found"] });
Expand All @@ -1928,7 +1928,7 @@ app.post(
if (
!stream ||
(!req.user.admin && (stream.deleted || stream.userId !== req.user.id)) ||
stream.projectId !== req.project.id
stream.projectId !== req.project?.id
) {
res.status(404);
return res.json({ errors: ["not found"] });
Expand All @@ -1952,7 +1952,7 @@ app.delete("/:id/terminate", authorizer({}), async (req, res) => {
if (
!stream ||
(!req.user.admin && (stream.deleted || stream.userId !== req.user.id)) ||
stream.projectId !== req.project.id
stream.projectId !== req.project?.id
) {
res.status(404);
return res.json({ errors: ["not found"] });
Expand Down

0 comments on commit 3b586d2

Please sign in to comment.