diff options
Diffstat (limited to 'server/lib/activitypub/playlists/refresh.ts')
-rw-r--r-- | server/lib/activitypub/playlists/refresh.ts | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/server/lib/activitypub/playlists/refresh.ts b/server/lib/activitypub/playlists/refresh.ts index 6f3a6be37..ef3cb3fe4 100644 --- a/server/lib/activitypub/playlists/refresh.ts +++ b/server/lib/activitypub/playlists/refresh.ts | |||
@@ -1,10 +1,17 @@ | |||
1 | import { logger, loggerTagsFactory } from '@server/helpers/logger' | 1 | import { logger, loggerTagsFactory } from '@server/helpers/logger' |
2 | import { PeerTubeRequestError } from '@server/helpers/requests' | 2 | import { PeerTubeRequestError } from '@server/helpers/requests' |
3 | import { MVideoPlaylistOwner } from '@server/types/models' | 3 | import { JobQueue } from '@server/lib/job-queue' |
4 | import { MVideoPlaylist, MVideoPlaylistOwner } from '@server/types/models' | ||
4 | import { HttpStatusCode } from '@shared/core-utils' | 5 | import { HttpStatusCode } from '@shared/core-utils' |
5 | import { createOrUpdateVideoPlaylist } from './create-update' | 6 | import { createOrUpdateVideoPlaylist } from './create-update' |
6 | import { fetchRemoteVideoPlaylist } from './shared' | 7 | import { fetchRemoteVideoPlaylist } from './shared' |
7 | 8 | ||
9 | function scheduleRefreshIfNeeded (playlist: MVideoPlaylist) { | ||
10 | if (!playlist.isOutdated()) return | ||
11 | |||
12 | JobQueue.Instance.createJob({ type: 'activitypub-refresher', payload: { type: 'video-playlist', url: playlist.url } }) | ||
13 | } | ||
14 | |||
8 | async function refreshVideoPlaylistIfNeeded (videoPlaylist: MVideoPlaylistOwner): Promise<MVideoPlaylistOwner> { | 15 | async function refreshVideoPlaylistIfNeeded (videoPlaylist: MVideoPlaylistOwner): Promise<MVideoPlaylistOwner> { |
9 | if (!videoPlaylist.isOutdated()) return videoPlaylist | 16 | if (!videoPlaylist.isOutdated()) return videoPlaylist |
10 | 17 | ||
@@ -22,8 +29,7 @@ async function refreshVideoPlaylistIfNeeded (videoPlaylist: MVideoPlaylistOwner) | |||
22 | return videoPlaylist | 29 | return videoPlaylist |
23 | } | 30 | } |
24 | 31 | ||
25 | const byAccount = videoPlaylist.OwnerAccount | 32 | await createOrUpdateVideoPlaylist(playlistObject) |
26 | await createOrUpdateVideoPlaylist(playlistObject, byAccount, playlistObject.to) | ||
27 | 33 | ||
28 | return videoPlaylist | 34 | return videoPlaylist |
29 | } catch (err) { | 35 | } catch (err) { |
@@ -42,5 +48,6 @@ async function refreshVideoPlaylistIfNeeded (videoPlaylist: MVideoPlaylistOwner) | |||
42 | } | 48 | } |
43 | 49 | ||
44 | export { | 50 | export { |
51 | scheduleRefreshIfNeeded, | ||
45 | refreshVideoPlaylistIfNeeded | 52 | refreshVideoPlaylistIfNeeded |
46 | } | 53 | } |