Skip to content

Commit

Permalink
api: ingest: direct base & playback (#2139)
Browse files Browse the repository at this point in the history
* api: ingest: direct base & playback

* fix

* fix

* implement for a specific hardcoded id for tests

* fix

* fix
  • Loading branch information
gioelecerati authored Apr 22, 2024
1 parent 4c4c9cc commit 29d55db
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 3 deletions.
11 changes: 9 additions & 2 deletions packages/api/src/controllers/playback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,16 @@ app.get("/:id", async (req, res) => {
res.status(501);
return res.json({ errors: ["Ingest not configured"] });
}
const ingest = ingests[0].base;

let ingest = ingests[0].base;
let { id } = req.params;

if (
(id === "1ba7nrr34rbjl4bb" || req.user?.directPlayback) &&
ingests[0].baseDirect
) {
ingest = ingests[0].baseDirect;
}

const withRecordings = req.query.recordings === "true";

const origin = req.headers["origin"] ?? "";
Expand Down
14 changes: 13 additions & 1 deletion packages/api/src/controllers/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ app.post("/", validatePost("user"), async (req, res) => {
res.json(user);
});

app.patch("/:id", authorizer({}), async (req, res) => {
app.patch("/:id/email", authorizer({}), async (req, res) => {
const { email } = req.body;
const userId = req.user.id;

Expand Down Expand Up @@ -731,6 +731,18 @@ app.patch(
}
);

app.patch("/:id", authorizer({ anyAdmin: true }), async (req, res) => {
const { id } = req.params;
const { directPlayback } = req.body;

if (directPlayback) {
await db.user.update(id, { directPlayback });
}

res.status(204);
res.end();
});

app.post("/token", validatePost("user"), async (req, res) => {
const user = await findUserByEmail(req.body.email);
const [hashedPassword] = await hash(req.body.password, user.salt);
Expand Down
3 changes: 3 additions & 0 deletions packages/api/src/schema/db-schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1178,6 +1178,9 @@ components:
newEmail:
type: string
description: temporary field for email change
directPlayback:
type: boolean
default: false
kind:
type: string
readOnly: true
Expand Down
2 changes: 2 additions & 0 deletions packages/api/src/test-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ params.ingest = [
{
ingest: "rtmp://test/live",
playback: "https://test/hls",
playbackDirect: "https://test/hls",
base: "https://test",
baseDirect: "https://test",
origin: "http://test",
},
];
Expand Down
2 changes: 2 additions & 0 deletions packages/api/src/types/common.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ export interface OrchestratorNodeAddress extends NodeAddress {
export interface Ingest {
origin?: string;
base?: string;
baseDirect?: string;
ingest: string;
playback: string;
playbackDirect?: string;
}

export interface Price {
Expand Down

0 comments on commit 29d55db

Please sign in to comment.