Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

api: stream: allow name update #2323

Merged
merged 4 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions packages/api/src/controllers/stream.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1240,6 +1240,15 @@ describe("controllers/stream", () => {
});
});

it("should allow patch of name", async () => {
const res = await client.patch(patchPath, {
name: "new name",
});
expect(res.status).toBe(204);
gioelecerati marked this conversation as resolved.
Show resolved Hide resolved
let s = await db.stream.get(stream.id);
expect(s.name).toBe("new name");
});

it("should allow patch of playbackPolicy", async () => {
const res = await client.patch(patchPath, {
playbackPolicy: {
Expand All @@ -1257,15 +1266,6 @@ describe("controllers/stream", () => {
expect(res.status).toBe(400);
});

it("should disallow additional fields", async () => {
const res = await client.patch(patchPath, {
name: "the stream name is immutable",
});
expect(res.status).toBe(422);
const json = await res.json();
expect(json.errors[0]).toContain("additionalProperties");
});

it("should disallow adding recordingSpec without record=true", async () => {
const res = await client.patch(patchPath, {
recordingSpec: { profiles: [{ bitrate: 1600000 }] },
Expand Down Expand Up @@ -1309,6 +1309,7 @@ describe("controllers/stream", () => {
multistream: { targets: { profile: "a", id: "b" } },
});
await testTypeErr({ multistream: { targets: [{ profile: 123 }] } });
await testTypeErr({ name: 123 });
});

it("should validate url format", async () => {
Expand Down
2 changes: 2 additions & 0 deletions packages/api/src/controllers/stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1961,6 +1961,7 @@ app.patch(
creatorId,
profiles,
recordingSpec,
name,
} = payload;
if (record != undefined && stream.isActive && stream.record != record) {
res.status(400);
Expand All @@ -1977,6 +1978,7 @@ app.patch(

let patch: StreamPatchPayload & Partial<DBStream> = {
record,
name,
profiles,
suspended,
creatorId: mapInputCreatorId(creatorId),
Expand Down
2 changes: 2 additions & 0 deletions packages/api/src/schema/api-schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,8 @@ components:
$ref: "#/components/schemas/new-stream-payload/properties/recordingSpec"
userTags:
$ref: "#/components/schemas/stream/properties/userTags"
name:
$ref: "#/components/schemas/stream/properties/name"
target-add-payload:
type: object
additionalProperties: false
Expand Down
Loading