diff options
author | Chocobozzz <me@florianbigard.com> | 2021-02-26 14:22:25 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-02-26 14:22:25 +0100 |
commit | 8795d6f254bd8f88c385bf77b82cc6f177c94df9 (patch) | |
tree | 88f8f4fced9e0c12db5b43dcac6e44bd94eb8b1a /server/lib/job-queue | |
parent | 92315d979c3f424d81f8fca3c8831d81e4e2a6d6 (diff) | |
download | PeerTube-8795d6f254bd8f88c385bf77b82cc6f177c94df9.tar.gz PeerTube-8795d6f254bd8f88c385bf77b82cc6f177c94df9.tar.zst PeerTube-8795d6f254bd8f88c385bf77b82cc6f177c94df9.zip |
Fix broken local actors
Some channels can't federate because they don't have public/private
keys, maybe because the generation failed for various reasons
Diffstat (limited to 'server/lib/job-queue')
-rw-r--r-- | server/lib/job-queue/handlers/actor-keys.ts | 20 | ||||
-rw-r--r-- | server/lib/job-queue/job-queue.ts | 5 |
2 files changed, 25 insertions, 0 deletions
diff --git a/server/lib/job-queue/handlers/actor-keys.ts b/server/lib/job-queue/handlers/actor-keys.ts new file mode 100644 index 000000000..8da549640 --- /dev/null +++ b/server/lib/job-queue/handlers/actor-keys.ts | |||
@@ -0,0 +1,20 @@ | |||
1 | import * as Bull from 'bull' | ||
2 | import { generateAndSaveActorKeys } from '@server/lib/activitypub/actor' | ||
3 | import { ActorModel } from '@server/models/activitypub/actor' | ||
4 | import { ActorKeysPayload } from '@shared/models' | ||
5 | import { logger } from '../../../helpers/logger' | ||
6 | |||
7 | async function processActorKeys (job: Bull.Job) { | ||
8 | const payload = job.data as ActorKeysPayload | ||
9 | logger.info('Processing email in job %d.', job.id) | ||
10 | |||
11 | const actor = await ActorModel.load(payload.actorId) | ||
12 | |||
13 | await generateAndSaveActorKeys(actor) | ||
14 | } | ||
15 | |||
16 | // --------------------------------------------------------------------------- | ||
17 | |||
18 | export { | ||
19 | processActorKeys | ||
20 | } | ||
diff --git a/server/lib/job-queue/job-queue.ts b/server/lib/job-queue/job-queue.ts index 72fed6072..efda2e038 100644 --- a/server/lib/job-queue/job-queue.ts +++ b/server/lib/job-queue/job-queue.ts | |||
@@ -7,6 +7,7 @@ import { | |||
7 | ActivitypubHttpBroadcastPayload, | 7 | ActivitypubHttpBroadcastPayload, |
8 | ActivitypubHttpFetcherPayload, | 8 | ActivitypubHttpFetcherPayload, |
9 | ActivitypubHttpUnicastPayload, | 9 | ActivitypubHttpUnicastPayload, |
10 | ActorKeysPayload, | ||
10 | EmailPayload, | 11 | EmailPayload, |
11 | JobState, | 12 | JobState, |
12 | JobType, | 13 | JobType, |
@@ -25,6 +26,7 @@ import { processActivityPubHttpBroadcast } from './handlers/activitypub-http-bro | |||
25 | import { processActivityPubHttpFetcher } from './handlers/activitypub-http-fetcher' | 26 | import { processActivityPubHttpFetcher } from './handlers/activitypub-http-fetcher' |
26 | import { processActivityPubHttpUnicast } from './handlers/activitypub-http-unicast' | 27 | import { processActivityPubHttpUnicast } from './handlers/activitypub-http-unicast' |
27 | import { refreshAPObject } from './handlers/activitypub-refresher' | 28 | import { refreshAPObject } from './handlers/activitypub-refresher' |
29 | import { processActorKeys } from './handlers/actor-keys' | ||
28 | import { processEmail } from './handlers/email' | 30 | import { processEmail } from './handlers/email' |
29 | import { processVideoFileImport } from './handlers/video-file-import' | 31 | import { processVideoFileImport } from './handlers/video-file-import' |
30 | import { processVideoImport } from './handlers/video-import' | 32 | import { processVideoImport } from './handlers/video-import' |
@@ -44,6 +46,7 @@ type CreateJobArgument = | |||
44 | { type: 'activitypub-refresher', payload: RefreshPayload } | | 46 | { type: 'activitypub-refresher', payload: RefreshPayload } | |
45 | { type: 'videos-views', payload: {} } | | 47 | { type: 'videos-views', payload: {} } | |
46 | { type: 'video-live-ending', payload: VideoLiveEndingPayload } | | 48 | { type: 'video-live-ending', payload: VideoLiveEndingPayload } | |
49 | { type: 'actor-keys', payload: ActorKeysPayload } | | ||
47 | { type: 'video-redundancy', payload: VideoRedundancyPayload } | 50 | { type: 'video-redundancy', payload: VideoRedundancyPayload } |
48 | 51 | ||
49 | type CreateJobOptions = { | 52 | type CreateJobOptions = { |
@@ -63,6 +66,7 @@ const handlers: { [id in JobType]: (job: Bull.Job) => Promise<any> } = { | |||
63 | 'videos-views': processVideosViews, | 66 | 'videos-views': processVideosViews, |
64 | 'activitypub-refresher': refreshAPObject, | 67 | 'activitypub-refresher': refreshAPObject, |
65 | 'video-live-ending': processVideoLiveEnding, | 68 | 'video-live-ending': processVideoLiveEnding, |
69 | 'actor-keys': processActorKeys, | ||
66 | 'video-redundancy': processVideoRedundancy | 70 | 'video-redundancy': processVideoRedundancy |
67 | } | 71 | } |
68 | 72 | ||
@@ -78,6 +82,7 @@ const jobTypes: JobType[] = [ | |||
78 | 'videos-views', | 82 | 'videos-views', |
79 | 'activitypub-refresher', | 83 | 'activitypub-refresher', |
80 | 'video-redundancy', | 84 | 'video-redundancy', |
85 | 'actor-keys', | ||
81 | 'video-live-ending' | 86 | 'video-live-ending' |
82 | ] | 87 | ] |
83 | 88 | ||