diff options
author | Levi Bard <taktaktaktaktaktaktaktaktaktak@gmail.com> | 2020-06-03 09:42:07 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-03 09:42:07 +0200 |
commit | 3092e9bbb05fe292fd13bc685b89069c3dda55d9 (patch) | |
tree | 42b9d04dd7749e835e09cb912677aaad21333a5d /server/models | |
parent | 78646451c9896db3c2239270cd7e100305749f41 (diff) | |
download | PeerTube-3092e9bbb05fe292fd13bc685b89069c3dda55d9.tar.gz PeerTube-3092e9bbb05fe292fd13bc685b89069c3dda55d9.tar.zst PeerTube-3092e9bbb05fe292fd13bc685b89069c3dda55d9.zip |
Make federation of unlisted videos an instance-level server preference (#2802)
* Add preference for federating unlisted videos
* Connect unlisted video federation with new preference
* Apply pull request feedback
* Fix lint issues
* Remove preference for federating unlisted videos from web admin interface
Diffstat (limited to 'server/models')
-rw-r--r-- | server/models/video/video.ts | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/server/models/video/video.ts b/server/models/video/video.ts index f5194e259..02a4c851c 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts | |||
@@ -126,6 +126,7 @@ import { ModelCache } from '@server/models/model-cache' | |||
126 | import { buildListQuery, BuildVideosQueryOptions, wrapForAPIResults } from './video-query-builder' | 126 | import { buildListQuery, BuildVideosQueryOptions, wrapForAPIResults } from './video-query-builder' |
127 | import { buildNSFWFilter } from '@server/helpers/express-utils' | 127 | import { buildNSFWFilter } from '@server/helpers/express-utils' |
128 | import { getServerActor } from '@server/models/application/application' | 128 | import { getServerActor } from '@server/models/application/application' |
129 | import { getPrivaciesForFederation, isPrivacyForFederation } from "@server/helpers/video" | ||
129 | 130 | ||
130 | export enum ScopeNames { | 131 | export enum ScopeNames { |
131 | AVAILABLE_FOR_LIST_IDS = 'AVAILABLE_FOR_LIST_IDS', | 132 | AVAILABLE_FOR_LIST_IDS = 'AVAILABLE_FOR_LIST_IDS', |
@@ -864,10 +865,7 @@ export class VideoModel extends Model<VideoModel> { | |||
864 | id: { | 865 | id: { |
865 | [Op.in]: Sequelize.literal('(' + rawQuery + ')') | 866 | [Op.in]: Sequelize.literal('(' + rawQuery + ')') |
866 | }, | 867 | }, |
867 | [Op.or]: [ | 868 | [Op.or]: getPrivaciesForFederation() |
868 | { privacy: VideoPrivacy.PUBLIC }, | ||
869 | { privacy: VideoPrivacy.UNLISTED } | ||
870 | ] | ||
871 | }, | 869 | }, |
872 | include: [ | 870 | include: [ |
873 | { | 871 | { |
@@ -1582,12 +1580,6 @@ export class VideoModel extends Model<VideoModel> { | |||
1582 | return videos | 1580 | return videos |
1583 | } | 1581 | } |
1584 | 1582 | ||
1585 | private static isPrivacyForFederation (privacy: VideoPrivacy) { | ||
1586 | const castedPrivacy = parseInt(privacy + '', 10) | ||
1587 | |||
1588 | return castedPrivacy === VideoPrivacy.PUBLIC || castedPrivacy === VideoPrivacy.UNLISTED | ||
1589 | } | ||
1590 | |||
1591 | static getCategoryLabel (id: number) { | 1583 | static getCategoryLabel (id: number) { |
1592 | return VIDEO_CATEGORIES[id] || 'Misc' | 1584 | return VIDEO_CATEGORIES[id] || 'Misc' |
1593 | } | 1585 | } |
@@ -1813,11 +1805,11 @@ export class VideoModel extends Model<VideoModel> { | |||
1813 | } | 1805 | } |
1814 | 1806 | ||
1815 | hasPrivacyForFederation () { | 1807 | hasPrivacyForFederation () { |
1816 | return VideoModel.isPrivacyForFederation(this.privacy) | 1808 | return isPrivacyForFederation(this.privacy) |
1817 | } | 1809 | } |
1818 | 1810 | ||
1819 | isNewVideo (newPrivacy: VideoPrivacy) { | 1811 | isNewVideo (newPrivacy: VideoPrivacy) { |
1820 | return this.hasPrivacyForFederation() === false && VideoModel.isPrivacyForFederation(newPrivacy) === true | 1812 | return this.hasPrivacyForFederation() === false && isPrivacyForFederation(newPrivacy) === true |
1821 | } | 1813 | } |
1822 | 1814 | ||
1823 | setAsRefreshed () { | 1815 | setAsRefreshed () { |