diff options
Diffstat (limited to 'server/lib')
-rw-r--r-- | server/lib/activitypub/send/index.ts | 2 | ||||
-rw-r--r-- | server/lib/activitypub/send/send-reject.ts | 44 | ||||
-rw-r--r-- | server/lib/hls.ts | 3 |
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 @@ | |||
1 | export * from './send-accept' | 1 | export * from './send-accept' |
2 | export * from './send-accept' | ||
2 | export * from './send-announce' | 3 | export * from './send-announce' |
3 | export * from './send-create' | 4 | export * from './send-create' |
4 | export * from './send-delete' | 5 | export * from './send-delete' |
5 | export * from './send-follow' | 6 | export * from './send-follow' |
6 | export * from './send-like' | 7 | export * from './send-like' |
8 | export * from './send-reject' | ||
7 | export * from './send-undo' | 9 | export * from './send-undo' |
8 | export * from './send-update' | 10 | export * 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 @@ | |||
1 | import { ActivityFollow, ActivityReject } from '../../../../shared/models/activitypub' | ||
2 | import { ActorModel } from '../../../models/activitypub/actor' | ||
3 | import { ActorFollowModel } from '../../../models/activitypub/actor-follow' | ||
4 | import { getActorFollowAcceptActivityPubUrl, getActorFollowActivityPubUrl } from '../url' | ||
5 | import { unicastTo } from './utils' | ||
6 | import { buildFollowActivity } from './send-follow' | ||
7 | import { logger } from '../../../helpers/logger' | ||
8 | |||
9 | async 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 | |||
31 | export { | ||
32 | sendReject | ||
33 | } | ||
34 | |||
35 | // --------------------------------------------------------------------------- | ||
36 | |||
37 | function 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 @@ | |||
1 | import { VideoModel } from '../models/video/video' | 1 | import { VideoModel } from '../models/video/video' |
2 | import { basename, dirname, join } from 'path' | 2 | import { basename, dirname, join } from 'path' |
3 | import { CONFIG, HLS_STREAMING_PLAYLIST_DIRECTORY, sequelizeTypescript } from '../initializers' | 3 | import { CONFIG, HLS_STREAMING_PLAYLIST_DIRECTORY, P2P_MEDIA_LOADER_PEER_VERSION, sequelizeTypescript } from '../initializers' |
4 | import { close, ensureDir, move, open, outputJSON, pathExists, read, readFile, remove, writeFile } from 'fs-extra' | 4 | import { close, ensureDir, move, open, outputJSON, pathExists, read, readFile, remove, writeFile } from 'fs-extra' |
5 | import { getVideoFileSize } from '../helpers/ffmpeg-utils' | 5 | import { getVideoFileSize } from '../helpers/ffmpeg-utils' |
6 | import { sha256 } from '../helpers/core-utils' | 6 | import { 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 | } |