aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub/actor.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/activitypub/actor.ts')
-rw-r--r--server/lib/activitypub/actor.ts13
1 files changed, 12 insertions, 1 deletions
diff --git a/server/lib/activitypub/actor.ts b/server/lib/activitypub/actor.ts
index a3f379b76..f77df8b78 100644
--- a/server/lib/activitypub/actor.ts
+++ b/server/lib/activitypub/actor.ts
@@ -44,6 +44,7 @@ async function getOrCreateActorAndServerAndModel (
44) { 44) {
45 const actorUrl = getAPId(activityActor) 45 const actorUrl = getAPId(activityActor)
46 let created = false 46 let created = false
47 let accountPlaylistsUrl: string
47 48
48 let actor = await fetchActorByUrl(actorUrl, fetchType) 49 let actor = await fetchActorByUrl(actorUrl, fetchType)
49 // Orphan actor (not associated to an account of channel) so recreate it 50 // Orphan actor (not associated to an account of channel) so recreate it
@@ -70,7 +71,8 @@ async function getOrCreateActorAndServerAndModel (
70 71
71 try { 72 try {
72 // Don't recurse another time 73 // Don't recurse another time
73 ownerActor = await getOrCreateActorAndServerAndModel(accountAttributedTo.id, 'all', false) 74 const recurseIfNeeded = false
75 ownerActor = await getOrCreateActorAndServerAndModel(accountAttributedTo.id, 'all', recurseIfNeeded)
74 } catch (err) { 76 } catch (err) {
75 logger.error('Cannot get or create account attributed to video channel ' + actor.url) 77 logger.error('Cannot get or create account attributed to video channel ' + actor.url)
76 throw new Error(err) 78 throw new Error(err)
@@ -79,6 +81,7 @@ async function getOrCreateActorAndServerAndModel (
79 81
80 actor = await retryTransactionWrapper(saveActorAndServerAndModelIfNotExist, result, ownerActor) 82 actor = await retryTransactionWrapper(saveActorAndServerAndModelIfNotExist, result, ownerActor)
81 created = true 83 created = true
84 accountPlaylistsUrl = result.playlists
82 } 85 }
83 86
84 if (actor.Account) actor.Account.Actor = actor 87 if (actor.Account) actor.Account.Actor = actor
@@ -92,6 +95,12 @@ async function getOrCreateActorAndServerAndModel (
92 await JobQueue.Instance.createJob({ type: 'activitypub-http-fetcher', payload }) 95 await JobQueue.Instance.createJob({ type: 'activitypub-http-fetcher', payload })
93 } 96 }
94 97
98 // We created a new account: fetch the playlists
99 if (created === true && actor.Account && accountPlaylistsUrl) {
100 const payload = { uri: accountPlaylistsUrl, accountId: actor.Account.id, type: 'account-playlists' as 'account-playlists' }
101 await JobQueue.Instance.createJob({ type: 'activitypub-http-fetcher', payload })
102 }
103
95 return actorRefreshed 104 return actorRefreshed
96} 105}
97 106
@@ -342,6 +351,7 @@ type FetchRemoteActorResult = {
342 name: string 351 name: string
343 summary: string 352 summary: string
344 support?: string 353 support?: string
354 playlists?: string
345 avatarName?: string 355 avatarName?: string
346 attributedTo: ActivityPubAttributedTo[] 356 attributedTo: ActivityPubAttributedTo[]
347} 357}
@@ -398,6 +408,7 @@ async function fetchRemoteActor (actorUrl: string): Promise<{ statusCode?: numbe
398 avatarName, 408 avatarName,
399 summary: actorJSON.summary, 409 summary: actorJSON.summary,
400 support: actorJSON.support, 410 support: actorJSON.support,
411 playlists: actorJSON.playlists,
401 attributedTo: actorJSON.attributedTo 412 attributedTo: actorJSON.attributedTo
402 } 413 }
403 } 414 }