diff --git a/client/src/app/shared/shared-instance/instance-features-table.component.html b/client/src/app/shared/shared-instance/instance-features-table.component.html
index 37f53b7c6..4c355c392 100644
--- a/client/src/app/shared/shared-instance/instance-features-table.component.html
+++ b/client/src/app/shared/shared-instance/instance-features-table.component.html
@@ -9,9 +9,9 @@
-
- Default NSFW/sensitive videos policy
- can be redefined by the users
+ |
+ Default NSFW/sensitive videos policy
+ can be redefined by the users
|
{{ buildNSFWLabel() }} |
diff --git a/packages/models/src/activitypub/objects/common-objects.ts b/packages/models/src/activitypub/objects/common-objects.ts
index a332c26f3..df5dcb56f 100644
--- a/packages/models/src/activitypub/objects/common-objects.ts
+++ b/packages/models/src/activitypub/objects/common-objects.ts
@@ -16,7 +16,7 @@ export interface ActivityIconObject {
export type ActivityVideoUrlObject = {
type: 'Link'
- mediaType: 'video/mp4' | 'video/webm' | 'video/ogg'
+ mediaType: 'video/mp4' | 'video/webm' | 'video/ogg' | 'audio/mp4'
href: string
height: number
size: number
diff --git a/server/server/helpers/custom-validators/activitypub/videos.ts b/server/server/helpers/custom-validators/activitypub/videos.ts
index b7298c474..7ef9723ca 100644
--- a/server/server/helpers/custom-validators/activitypub/videos.ts
+++ b/server/server/helpers/custom-validators/activitypub/videos.ts
@@ -8,7 +8,7 @@ import {
VideoState
} from '@peertube/peertube-models'
import { logger } from '@server/helpers/logger.js'
-import { ACTIVITY_PUB, CONSTRAINTS_FIELDS } from '../../../initializers/constants.js'
+import { CONSTRAINTS_FIELDS, MIMETYPES } from '../../../initializers/constants.js'
import { peertubeTruncate } from '../../core-utils.js'
import { isArray, isBooleanValid, isDateValid, isUUIDValid } from '../misc.js'
import { isLiveLatencyModeValid } from '../video-lives.js'
@@ -91,7 +91,7 @@ function isRemoteVideoUrlValid (url: any) {
return url.type === 'Link' &&
// Video file link
(
- ACTIVITY_PUB.URL_MIME_TYPES.VIDEO.includes(url.mediaType) &&
+ MIMETYPES.AP_VIDEO.MIMETYPE_EXT[url.mediaType] &&
isActivityPubUrlValid(url.href) &&
validator.default.isInt(url.height + '', { min: 0 }) &&
validator.default.isInt(url.size + '', { min: 0 }) &&
@@ -99,13 +99,13 @@ function isRemoteVideoUrlValid (url: any) {
) ||
// Torrent link
(
- ACTIVITY_PUB.URL_MIME_TYPES.TORRENT.includes(url.mediaType) &&
+ MIMETYPES.AP_TORRENT.MIMETYPE_EXT[url.mediaType] &&
isActivityPubUrlValid(url.href) &&
validator.default.isInt(url.height + '', { min: 0 })
) ||
// Magnet link
(
- ACTIVITY_PUB.URL_MIME_TYPES.MAGNET.includes(url.mediaType) &&
+ MIMETYPES.AP_MAGNET.MIMETYPE_EXT[url.mediaType] &&
validator.default.isLength(url.href, { min: 5 }) &&
validator.default.isInt(url.height + '', { min: 0 })
) ||
diff --git a/server/server/initializers/constants.ts b/server/server/initializers/constants.ts
index 121433caf..4c58c19c8 100644
--- a/server/server/initializers/constants.ts
+++ b/server/server/initializers/constants.ts
@@ -672,8 +672,27 @@ const MIMETYPES = {
MIMETYPE_EXT: {
'application/vnd.apple.mpegurl': '.m3u8'
}
+ },
+ AP_VIDEO: {
+ MIMETYPE_EXT: {
+ 'video/mp4': '.mp4',
+ 'video/ogg': '.ogv',
+ 'video/webm': '.webm',
+ 'audio/mp4': '.mp4'
+ }
+ },
+ AP_TORRENT: {
+ MIMETYPE_EXT: {
+ 'application/x-bittorrent': '.torrent'
+ }
+ },
+ AP_MAGNET: {
+ MIMETYPE_EXT: {
+ 'application/x-bittorrent;x-scheme-handler/magnet': '.magnet'
+ }
}
}
+
MIMETYPES.AUDIO.EXT_MIMETYPE = invert(MIMETYPES.AUDIO.MIMETYPE_EXT)
MIMETYPES.IMAGE.EXT_MIMETYPE = invert(MIMETYPES.IMAGE.MIMETYPE_EXT)
MIMETYPES.VIDEO_CAPTIONS.EXT_MIMETYPE = invert(MIMETYPES.VIDEO_CAPTIONS.MIMETYPE_EXT)
@@ -707,11 +726,6 @@ const ACTIVITY_PUB = {
PUBLIC: 'https://www.w3.org/ns/activitystreams#Public',
COLLECTION_ITEMS_PER_PAGE: 10,
FETCH_PAGE_LIMIT: 2000,
- URL_MIME_TYPES: {
- VIDEO: [] as string[],
- TORRENT: [ 'application/x-bittorrent' ],
- MAGNET: [ 'application/x-bittorrent;x-scheme-handler/magnet' ]
- },
MAX_RECURSION_COMMENTS: 100,
ACTOR_REFRESH_INTERVAL: 3600 * 24 * 1000 * 2, // 2 days
VIDEO_REFRESH_INTERVAL: 3600 * 24 * 1000 * 2, // 2 days
@@ -1313,8 +1327,6 @@ function updateWebserverConfig () {
MIMETYPES.VIDEO.MIMETYPE_EXT = buildVideoMimetypeExt()
MIMETYPES.VIDEO.MIMETYPES_REGEX = buildMimetypesRegex(MIMETYPES.VIDEO.MIMETYPE_EXT)
- ACTIVITY_PUB.URL_MIME_TYPES.VIDEO = Object.keys(MIMETYPES.VIDEO.MIMETYPE_EXT)
-
MIMETYPES.VIDEO.EXT_MIMETYPE = buildVideoExtMimetype(MIMETYPES.VIDEO.MIMETYPE_EXT)
CONSTRAINTS_FIELDS.VIDEOS.EXTNAME = Object.keys(MIMETYPES.VIDEO.EXT_MIMETYPE)
diff --git a/server/server/lib/activitypub/videos/shared/object-to-model-attributes.ts b/server/server/lib/activitypub/videos/shared/object-to-model-attributes.ts
index c0a945331..9657bd172 100644
--- a/server/server/lib/activitypub/videos/shared/object-to-model-attributes.ts
+++ b/server/server/lib/activitypub/videos/shared/object-to-model-attributes.ts
@@ -264,9 +264,7 @@ export {
// ---------------------------------------------------------------------------
function isAPVideoUrlObject (url: any): url is ActivityVideoUrlObject {
- const urlMediaType = url.mediaType
-
- return MIMETYPES.VIDEO.MIMETYPE_EXT[urlMediaType] && urlMediaType.startsWith('video/')
+ return !!MIMETYPES.AP_VIDEO.MIMETYPE_EXT[url.mediaType]
}
function isAPStreamingPlaylistUrlObject (url: any): url is ActivityPlaylistUrlObject {
diff --git a/server/server/models/video/formatter/video-activity-pub-format.ts b/server/server/models/video/formatter/video-activity-pub-format.ts
index 7beec741a..691948a47 100644
--- a/server/server/models/video/formatter/video-activity-pub-format.ts
+++ b/server/server/models/video/formatter/video-activity-pub-format.ts
@@ -181,7 +181,8 @@ function buildVideoFileUrls (options: {
.sort(sortByResolutionDesc)
for (const file of sortedFiles) {
- const mimeType = getVideoFileMimeType(file.extname, file.isAudio())
+ // FIXME: Replace false by file.isAudio(), federation breaking change correctly handled in 6.0
+ const mimeType = getVideoFileMimeType(file.extname, false)
urls.push({
type: 'Link',