diff options
Diffstat (limited to 'server/lib/activitypub/actors/get.ts')
-rw-r--r-- | server/lib/activitypub/actors/get.ts | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/server/lib/activitypub/actors/get.ts b/server/lib/activitypub/actors/get.ts index 8681ea02a..4200ddb4d 100644 --- a/server/lib/activitypub/actors/get.ts +++ b/server/lib/activitypub/actors/get.ts | |||
@@ -68,9 +68,28 @@ async function getOrCreateAPActor ( | |||
68 | return actorRefreshed | 68 | return actorRefreshed |
69 | } | 69 | } |
70 | 70 | ||
71 | function getOrCreateAPOwner (actorObject: ActivityPubActor, actorUrl: string) { | ||
72 | const accountAttributedTo = actorObject.attributedTo.find(a => a.type === 'Person') | ||
73 | if (!accountAttributedTo) throw new Error('Cannot find account attributed to video channel ' + actorUrl) | ||
74 | |||
75 | if (checkUrlsSameHost(accountAttributedTo.id, actorUrl) !== true) { | ||
76 | throw new Error(`Account attributed to ${accountAttributedTo.id} does not have the same host than actor url ${actorUrl}`) | ||
77 | } | ||
78 | |||
79 | try { | ||
80 | // Don't recurse another time | ||
81 | const recurseIfNeeded = false | ||
82 | return getOrCreateAPActor(accountAttributedTo.id, 'all', recurseIfNeeded) | ||
83 | } catch (err) { | ||
84 | logger.error('Cannot get or create account attributed to video channel ' + actorUrl) | ||
85 | throw new Error(err) | ||
86 | } | ||
87 | } | ||
88 | |||
71 | // --------------------------------------------------------------------------- | 89 | // --------------------------------------------------------------------------- |
72 | 90 | ||
73 | export { | 91 | export { |
92 | getOrCreateAPOwner, | ||
74 | getOrCreateAPActor | 93 | getOrCreateAPActor |
75 | } | 94 | } |
76 | 95 | ||
@@ -88,24 +107,6 @@ async function loadActorFromDB (actorUrl: string, fetchType: ActorLoadByUrlType) | |||
88 | return actor | 107 | return actor |
89 | } | 108 | } |
90 | 109 | ||
91 | function getOrCreateAPOwner (actorObject: ActivityPubActor, actorUrl: string) { | ||
92 | const accountAttributedTo = actorObject.attributedTo.find(a => a.type === 'Person') | ||
93 | if (!accountAttributedTo) throw new Error('Cannot find account attributed to video channel ' + actorUrl) | ||
94 | |||
95 | if (checkUrlsSameHost(accountAttributedTo.id, actorUrl) !== true) { | ||
96 | throw new Error(`Account attributed to ${accountAttributedTo.id} does not have the same host than actor url ${actorUrl}`) | ||
97 | } | ||
98 | |||
99 | try { | ||
100 | // Don't recurse another time | ||
101 | const recurseIfNeeded = false | ||
102 | return getOrCreateAPActor(accountAttributedTo.id, 'all', recurseIfNeeded) | ||
103 | } catch (err) { | ||
104 | logger.error('Cannot get or create account attributed to video channel ' + actorUrl) | ||
105 | throw new Error(err) | ||
106 | } | ||
107 | } | ||
108 | |||
109 | async function scheduleOutboxFetchIfNeeded (actor: MActor, created: boolean, refreshed: boolean, updateCollections: boolean) { | 110 | async function scheduleOutboxFetchIfNeeded (actor: MActor, created: boolean, refreshed: boolean, updateCollections: boolean) { |
110 | if ((created === true || refreshed === true) && updateCollections === true) { | 111 | if ((created === true || refreshed === true) && updateCollections === true) { |
111 | const payload = { uri: actor.outboxUrl, type: 'activity' as 'activity' } | 112 | const payload = { uri: actor.outboxUrl, type: 'activity' as 'activity' } |