aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib')
-rw-r--r--server/lib/activitypub/actor.ts27
1 files changed, 15 insertions, 12 deletions
diff --git a/server/lib/activitypub/actor.ts b/server/lib/activitypub/actor.ts
index 3f6edc070..8c5c618fc 100644
--- a/server/lib/activitypub/actor.ts
+++ b/server/lib/activitypub/actor.ts
@@ -35,6 +35,7 @@ import {
35 MActorId, 35 MActorId,
36 MChannel 36 MChannel
37} from '../../typings/models' 37} from '../../typings/models'
38import { extname } from 'path'
38 39
39// Set account keys, this could be long so process after the account creation and do not block the client 40// Set account keys, this could be long so process after the account creation and do not block the client
40function setAsyncActorKeys <T extends MActor> (actor: T) { 41function setAsyncActorKeys <T extends MActor> (actor: T) {
@@ -215,19 +216,21 @@ async function fetchActorTotalItems (url: string) {
215} 216}
216 217
217function getAvatarInfoIfExists (actorJSON: ActivityPubActor) { 218function getAvatarInfoIfExists (actorJSON: ActivityPubActor) {
218 if ( 219 const mimetypes = MIMETYPES.IMAGE
219 actorJSON.icon && actorJSON.icon.type === 'Image' && MIMETYPES.IMAGE.MIMETYPE_EXT[actorJSON.icon.mediaType] !== undefined && 220 const icon = actorJSON.icon
220 isActivityPubUrlValid(actorJSON.icon.url) 221
221 ) { 222 if (!icon || icon.type !== 'Image' || !isActivityPubUrlValid(icon.url)) return undefined
222 const extension = MIMETYPES.IMAGE.MIMETYPE_EXT[actorJSON.icon.mediaType] 223
223 224 const extension = icon.mediaType
224 return { 225 ? mimetypes.MIMETYPE_EXT[icon.mediaType]
225 name: uuidv4() + extension, 226 : extname(icon.url)
226 fileUrl: actorJSON.icon.url
227 }
228 }
229 227
230 return undefined 228 if (!extension) return undefined
229
230 return {
231 name: uuidv4() + extension,
232 fileUrl: icon.url
233 }
231} 234}
232 235
233async function addFetchOutboxJob (actor: Pick<ActorModel, 'id' | 'outboxUrl'>) { 236async function addFetchOutboxJob (actor: Pick<ActorModel, 'id' | 'outboxUrl'>) {