Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check video rights before providing AP information
- Loading branch information
1 parent
b8635c2
commit afb2827
Showing
31 changed files
with
247 additions
and
226 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,28 @@ | ||
import { Response } from 'express' | ||
import { forceNumber } from '@peertube/peertube-core-utils' | ||
import { VideoPrivacy, VideoPrivacyType, VideoState, VideoStateType } from '@peertube/peertube-models' | ||
import { VideoPrivacy } from '@peertube/peertube-models' | ||
import { CONFIG } from '@server/initializers/config.js' | ||
import { isStreamingPlaylist, MStreamingPlaylistVideo, MVideo } from '@server/types/models/index.js' | ||
import { Response } from 'express' | ||
|
||
function getVideoWithAttributes (res: Response) { | ||
export function getVideoWithAttributes (res: Response) { | ||
return res.locals.videoAPI || res.locals.videoAll || res.locals.onlyVideo | ||
} | ||
|
||
function extractVideo (videoOrPlaylist: MVideo | MStreamingPlaylistVideo) { | ||
export function extractVideo (videoOrPlaylist: MVideo | MStreamingPlaylistVideo) { | ||
return isStreamingPlaylist(videoOrPlaylist) | ||
? videoOrPlaylist.Video | ||
: videoOrPlaylist | ||
} | ||
|
||
function isPrivacyForFederation (privacy: VideoPrivacyType) { | ||
const castedPrivacy = forceNumber(privacy) | ||
|
||
return castedPrivacy === VideoPrivacy.PUBLIC || | ||
(CONFIG.FEDERATION.VIDEOS.FEDERATE_UNLISTED === true && castedPrivacy === VideoPrivacy.UNLISTED) | ||
} | ||
|
||
function isStateForFederation (state: VideoStateType) { | ||
const castedState = forceNumber(state) | ||
|
||
return castedState === VideoState.PUBLISHED || castedState === VideoState.WAITING_FOR_LIVE || castedState === VideoState.LIVE_ENDED | ||
} | ||
|
||
function getPrivaciesForFederation () { | ||
export function getPrivaciesForFederation () { | ||
return (CONFIG.FEDERATION.VIDEOS.FEDERATE_UNLISTED === true) | ||
? [ { privacy: VideoPrivacy.PUBLIC }, { privacy: VideoPrivacy.UNLISTED } ] | ||
: [ { privacy: VideoPrivacy.PUBLIC } ] | ||
} | ||
|
||
function getExtFromMimetype (mimeTypes: { [id: string]: string | string[] }, mimeType: string) { | ||
export function getExtFromMimetype (mimeTypes: { [id: string]: string | string[] }, mimeType: string) { | ||
const value = mimeTypes[mimeType] | ||
|
||
if (Array.isArray(value)) return value[0] | ||
|
||
return value | ||
} | ||
|
||
export { | ||
getVideoWithAttributes, | ||
extractVideo, | ||
getExtFromMimetype, | ||
isStateForFederation, | ||
isPrivacyForFederation, | ||
getPrivaciesForFederation | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.