check validity of stream before returning

This commit is contained in:
mrjvs
2023-10-26 21:07:11 +02:00
parent 9d204c381f
commit bec7c07881
3 changed files with 25 additions and 1 deletions

View File

@@ -8,6 +8,7 @@ import { Stream } from '@/providers/streams';
import { ScrapeContext } from '@/utils/context';
import { NotFoundError } from '@/utils/errors';
import { reorderOnIdList } from '@/utils/list';
import { isValidStream } from '@/utils/valid';
export type RunOutput = {
sourceId: string;
@@ -79,6 +80,9 @@ export async function runAllProviders(list: ProviderList, ops: ProviderRunnerOpt
...contextBase,
media: ops.media,
});
if (!isValidStream(output?.stream)) {
throw new NotFoundError('stream is incomplete');
}
if (output?.stream && !flagsAllowedInFeatures(ops.features, output.stream.flags)) {
throw new NotFoundError("stream doesn't satisfy target feature flags");
}