aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib')
-rw-r--r--server/lib/activitypub/send/index.ts2
-rw-r--r--server/lib/activitypub/send/send-reject.ts44
-rw-r--r--server/lib/hls.ts3
3 files changed, 48 insertions, 1 deletions
diff --git a/server/lib/activitypub/send/index.ts b/server/lib/activitypub/send/index.ts
index 79ba6c7fe..028936810 100644
--- a/server/lib/activitypub/send/index.ts
+++ b/server/lib/activitypub/send/index.ts
@@ -1,8 +1,10 @@
1export * from './send-accept' 1export * from './send-accept'
2export * from './send-accept'
2export * from './send-announce' 3export * from './send-announce'
3export * from './send-create' 4export * from './send-create'
4export * from './send-delete' 5export * from './send-delete'
5export * from './send-follow' 6export * from './send-follow'
6export * from './send-like' 7export * from './send-like'
8export * from './send-reject'
7export * from './send-undo' 9export * from './send-undo'
8export * from './send-update' 10export * from './send-update'
diff --git a/server/lib/activitypub/send/send-reject.ts b/server/lib/activitypub/send/send-reject.ts
new file mode 100644
index 000000000..db8c2d86d
--- /dev/null
+++ b/server/lib/activitypub/send/send-reject.ts
@@ -0,0 +1,44 @@
1import { ActivityFollow, ActivityReject } from '../../../../shared/models/activitypub'
2import { ActorModel } from '../../../models/activitypub/actor'
3import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
4import { getActorFollowAcceptActivityPubUrl, getActorFollowActivityPubUrl } from '../url'
5import { unicastTo } from './utils'
6import { buildFollowActivity } from './send-follow'
7import { logger } from '../../../helpers/logger'
8
9async function sendReject (actorFollow: ActorFollowModel) {
10 const follower = actorFollow.ActorFollower
11 const me = actorFollow.ActorFollowing
12
13 if (!follower.serverId) { // This should never happen
14 logger.warn('Do not sending reject to local follower.')
15 return
16 }
17
18 logger.info('Creating job to reject follower %s.', follower.url)
19
20 const followUrl = getActorFollowActivityPubUrl(actorFollow)
21 const followData = buildFollowActivity(followUrl, follower, me)
22
23 const url = getActorFollowAcceptActivityPubUrl(actorFollow)
24 const data = buildRejectActivity(url, me, followData)
25
26 return unicastTo(data, me, follower.inboxUrl)
27}
28
29// ---------------------------------------------------------------------------
30
31export {
32 sendReject
33}
34
35// ---------------------------------------------------------------------------
36
37function buildRejectActivity (url: string, byActor: ActorModel, followActivityData: ActivityFollow): ActivityReject {
38 return {
39 type: 'Reject',
40 id: url,
41 actor: byActor.url,
42 object: followActivityData
43 }
44}
diff --git a/server/lib/hls.ts b/server/lib/hls.ts
index 5a7d61dee..c0fc4961a 100644
--- a/server/lib/hls.ts
+++ b/server/lib/hls.ts
@@ -1,6 +1,6 @@
1import { VideoModel } from '../models/video/video' 1import { VideoModel } from '../models/video/video'
2import { basename, dirname, join } from 'path' 2import { basename, dirname, join } from 'path'
3import { CONFIG, HLS_STREAMING_PLAYLIST_DIRECTORY, sequelizeTypescript } from '../initializers' 3import { CONFIG, HLS_STREAMING_PLAYLIST_DIRECTORY, P2P_MEDIA_LOADER_PEER_VERSION, sequelizeTypescript } from '../initializers'
4import { close, ensureDir, move, open, outputJSON, pathExists, read, readFile, remove, writeFile } from 'fs-extra' 4import { close, ensureDir, move, open, outputJSON, pathExists, read, readFile, remove, writeFile } from 'fs-extra'
5import { getVideoFileSize } from '../helpers/ffmpeg-utils' 5import { getVideoFileSize } from '../helpers/ffmpeg-utils'
6import { sha256 } from '../helpers/core-utils' 6import { sha256 } from '../helpers/core-utils'
@@ -20,6 +20,7 @@ async function updateStreamingPlaylistsInfohashesIfNeeded () {
20 const videoFiles = await VideoFileModel.listByStreamingPlaylist(playlist.id, t) 20 const videoFiles = await VideoFileModel.listByStreamingPlaylist(playlist.id, t)
21 21
22 playlist.p2pMediaLoaderInfohashes = await VideoStreamingPlaylistModel.buildP2PMediaLoaderInfoHashes(playlist.playlistUrl, videoFiles) 22 playlist.p2pMediaLoaderInfohashes = await VideoStreamingPlaylistModel.buildP2PMediaLoaderInfoHashes(playlist.playlistUrl, videoFiles)
23 playlist.p2pMediaLoaderPeerVersion = P2P_MEDIA_LOADER_PEER_VERSION
23 await playlist.save({ transaction: t }) 24 await playlist.save({ transaction: t })
24 }) 25 })
25 } 26 }