Skip to content

Commit

Permalink
api: Allow isMobile to be specified as an int (0 or 1... or 2!) (#2172)
Browse files Browse the repository at this point in the history
* api: Allow isMobile to be specified as an int (0 or 1)

* api: Allow 2 as well
  • Loading branch information
victorges authored May 9, 2024
1 parent 0f29a49 commit ba56dd4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
8 changes: 5 additions & 3 deletions packages/api/src/controllers/stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1067,7 +1067,10 @@ const testCreatorIds: string[] = [
];

// TODO: Remove this logic once Trovo starts sending correct profiles to the /pull API. Maybe never :(
function fixTrovoProfiles(profiles: Profile[], isMobile: boolean) {
function fixedTrovoProfiles({
profiles,
pull: { isMobile },
}: NewStreamPayload) {
return profiles?.map((p) => ({
...p,
fps: isMobile && p.fps ? 0 : p.fps,
Expand All @@ -1093,8 +1096,7 @@ app.put(
const payload: Partial<DBStream> & NewStreamPayload = {
...rawPayload,
profiles:
fixTrovoProfiles(rawPayload.profiles, rawPayload.pull.isMobile) ||
req.config.defaultStreamProfiles,
fixedTrovoProfiles(rawPayload) || req.config.defaultStreamProfiles,
creatorId: mapInputCreatorId(rawPayload.creatorId),
};

Expand Down
10 changes: 9 additions & 1 deletion packages/api/src/schema/api-schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,15 @@ components:
example:
Authorization: "Bearer 123"
isMobile:
type: boolean
type:
- boolean
- integer
enum:
- false
- true
- 0
- 1
- 2
description: |-
If true, the stream will be pulled from a mobile source.
default: false
Expand Down

0 comments on commit ba56dd4

Please sign in to comment.