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.ts19
1 files changed, 10 insertions, 9 deletions
diff --git a/server/lib/activitypub/actor.ts b/server/lib/activitypub/actor.ts
index c3de4bdce..ff0a291e8 100644
--- a/server/lib/activitypub/actor.ts
+++ b/server/lib/activitypub/actor.ts
@@ -11,7 +11,7 @@ import { ActorModel } from '../../models/activitypub/actor'
11import { ServerModel } from '../../models/server/server' 11import { ServerModel } from '../../models/server/server'
12import { VideoChannelModel } from '../../models/video/video-channel' 12import { VideoChannelModel } from '../../models/video/video-channel'
13 13
14 // Set account keys, this could be long so process after the account creation and do not block the client 14// Set account keys, this could be long so process after the account creation and do not block the client
15function setAsyncActorKeys (actor: ActorModel) { 15function setAsyncActorKeys (actor: ActorModel) {
16 return createPrivateAndPublicKeys() 16 return createPrivateAndPublicKeys()
17 .then(({ publicKey, privateKey }) => { 17 .then(({ publicKey, privateKey }) => {
@@ -107,7 +107,7 @@ function saveActorAndServerAndModelIfNotExist (
107 107
108type FetchRemoteActorResult = { 108type FetchRemoteActorResult = {
109 actor: ActorModel 109 actor: ActorModel
110 preferredUsername: string 110 name: string
111 summary: string 111 summary: string
112 attributedTo: ActivityPubAttributedTo[] 112 attributedTo: ActivityPubAttributedTo[]
113} 113}
@@ -142,8 +142,8 @@ async function fetchRemoteActor (actorUrl: string): Promise<FetchRemoteActorResu
142 const actor = new ActorModel({ 142 const actor = new ActorModel({
143 type: actorJSON.type, 143 type: actorJSON.type,
144 uuid: actorJSON.uuid, 144 uuid: actorJSON.uuid,
145 name: actorJSON.name, 145 preferredUsername: actorJSON.preferredUsername,
146 url: actorJSON.url, 146 url: actorJSON.id,
147 publicKey: actorJSON.publicKey.publicKeyPem, 147 publicKey: actorJSON.publicKey.publicKeyPem,
148 privateKey: null, 148 privateKey: null,
149 followersCount: followersCount, 149 followersCount: followersCount,
@@ -155,19 +155,20 @@ async function fetchRemoteActor (actorUrl: string): Promise<FetchRemoteActorResu
155 followingUrl: actorJSON.following 155 followingUrl: actorJSON.following
156 }) 156 })
157 157
158 const name = actorJSON.name || actorJSON.preferredUsername
158 return { 159 return {
159 actor, 160 actor,
160 preferredUsername: actorJSON.preferredUsername, 161 name,
161 summary: actorJSON.summary, 162 summary: actorJSON.summary,
162 attributedTo: actorJSON.attributedTo 163 attributedTo: actorJSON.attributedTo
163 } 164 }
164} 165}
165 166
166function buildActorInstance (type: ActivityPubActorType, url: string, name: string, uuid?: string) { 167function buildActorInstance (type: ActivityPubActorType, url: string, preferredUsername: string, uuid?: string) {
167 return new ActorModel({ 168 return new ActorModel({
168 type, 169 type,
169 url, 170 url,
170 name, 171 preferredUsername,
171 uuid, 172 uuid,
172 publicKey: null, 173 publicKey: null,
173 privateKey: null, 174 privateKey: null,
@@ -210,7 +211,7 @@ async function fetchActorTotalItems (url: string) {
210 211
211function saveAccount (actor: ActorModel, result: FetchRemoteActorResult, t: Transaction) { 212function saveAccount (actor: ActorModel, result: FetchRemoteActorResult, t: Transaction) {
212 const account = new AccountModel({ 213 const account = new AccountModel({
213 name: result.preferredUsername, 214 name: result.name,
214 actorId: actor.id 215 actorId: actor.id
215 }) 216 })
216 217
@@ -219,7 +220,7 @@ function saveAccount (actor: ActorModel, result: FetchRemoteActorResult, t: Tran
219 220
220async function saveVideoChannel (actor: ActorModel, result: FetchRemoteActorResult, ownerActor: ActorModel, t: Transaction) { 221async function saveVideoChannel (actor: ActorModel, result: FetchRemoteActorResult, ownerActor: ActorModel, t: Transaction) {
221 const videoChannel = new VideoChannelModel({ 222 const videoChannel = new VideoChannelModel({
222 name: result.preferredUsername, 223 name: result.name,
223 description: result.summary, 224 description: result.summary,
224 actorId: actor.id, 225 actorId: actor.id,
225 accountId: ownerActor.Account.id 226 accountId: ownerActor.Account.id