diff options
Diffstat (limited to 'server/lib/activitypub')
-rw-r--r-- | server/lib/activitypub/playlists/create-update.ts | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/server/lib/activitypub/playlists/create-update.ts b/server/lib/activitypub/playlists/create-update.ts index dd4316d54..37d748de4 100644 --- a/server/lib/activitypub/playlists/create-update.ts +++ b/server/lib/activitypub/playlists/create-update.ts | |||
@@ -6,7 +6,7 @@ import { updatePlaylistMiniatureFromUrl } from '@server/lib/thumbnail' | |||
6 | import { VideoPlaylistModel } from '@server/models/video/video-playlist' | 6 | import { VideoPlaylistModel } from '@server/models/video/video-playlist' |
7 | import { VideoPlaylistElementModel } from '@server/models/video/video-playlist-element' | 7 | import { VideoPlaylistElementModel } from '@server/models/video/video-playlist-element' |
8 | import { FilteredModelAttributes } from '@server/types' | 8 | import { FilteredModelAttributes } from '@server/types' |
9 | import { MAccountDefault, MAccountId, MVideoPlaylist, MVideoPlaylistFull } from '@server/types/models' | 9 | import { MAccountDefault, MAccountId, MThumbnail, MVideoPlaylist, MVideoPlaylistFull } from '@server/types/models' |
10 | import { AttributesOnly } from '@shared/core-utils' | 10 | import { AttributesOnly } from '@shared/core-utils' |
11 | import { PlaylistObject } from '@shared/models' | 11 | import { PlaylistObject } from '@shared/models' |
12 | import { getOrCreateAPActor } from '../actors' | 12 | import { getOrCreateAPActor } from '../actors' |
@@ -54,11 +54,7 @@ async function createOrUpdateVideoPlaylist (playlistObject: PlaylistObject, byAc | |||
54 | // Refetch playlist from DB since elements fetching could be long in time | 54 | // Refetch playlist from DB since elements fetching could be long in time |
55 | const playlist = await VideoPlaylistModel.loadWithAccountAndChannel(upsertPlaylist.id, null) | 55 | const playlist = await VideoPlaylistModel.loadWithAccountAndChannel(upsertPlaylist.id, null) |
56 | 56 | ||
57 | try { | 57 | await updatePlaylistThumbnail(playlistObject, playlist) |
58 | await updatePlaylistThumbnail(playlistObject, playlist) | ||
59 | } catch (err) { | ||
60 | logger.warn('Cannot update thumbnail of %s.', playlistObject.id, { err, ...lTags(playlistObject.id, playlist.uuid, playlist.url) }) | ||
61 | } | ||
62 | 58 | ||
63 | return rebuildVideoPlaylistElements(playlistElementUrls, playlist) | 59 | return rebuildVideoPlaylistElements(playlistElementUrls, playlist) |
64 | } | 60 | } |
@@ -98,8 +94,16 @@ async function fetchElementUrls (playlistObject: PlaylistObject) { | |||
98 | 94 | ||
99 | async function updatePlaylistThumbnail (playlistObject: PlaylistObject, playlist: MVideoPlaylistFull) { | 95 | async function updatePlaylistThumbnail (playlistObject: PlaylistObject, playlist: MVideoPlaylistFull) { |
100 | if (playlistObject.icon) { | 96 | if (playlistObject.icon) { |
101 | const thumbnailModel = await updatePlaylistMiniatureFromUrl({ downloadUrl: playlistObject.icon.url, playlist }) | 97 | let thumbnailModel: MThumbnail |
102 | await playlist.setAndSaveThumbnail(thumbnailModel, undefined) | 98 | |
99 | try { | ||
100 | thumbnailModel = await updatePlaylistMiniatureFromUrl({ downloadUrl: playlistObject.icon.url, playlist }) | ||
101 | await playlist.setAndSaveThumbnail(thumbnailModel, undefined) | ||
102 | } catch (err) { | ||
103 | logger.warn('Cannot set thumbnail of %s.', playlistObject.id, { err, ...lTags(playlistObject.id, playlist.uuid, playlist.url) }) | ||
104 | |||
105 | if (thumbnailModel) await thumbnailModel.removeThumbnail() | ||
106 | } | ||
103 | 107 | ||
104 | return | 108 | return |
105 | } | 109 | } |