X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Flib%2Factivitypub%2Factor.ts;h=04296864b96c88038ed4726ca166679a10558550;hb=c5407d7046168abb4098df1408e7aa84519cb61a;hp=e0cb986bdf20e40173a35f00e103aed2cf512062;hpb=57cfff78858b2360d9e038e2a504b761cb51da47;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/lib/activitypub/actor.ts b/server/lib/activitypub/actor.ts index e0cb986bd..04296864b 100644 --- a/server/lib/activitypub/actor.ts +++ b/server/lib/activitypub/actor.ts @@ -5,7 +5,7 @@ import * as uuidv4 from 'uuid/v4' import { ActivityPubActor, ActivityPubActorType } from '../../../shared/models/activitypub' import { ActivityPubAttributedTo } from '../../../shared/models/activitypub/objects' import { checkUrlsSameHost, getAPId } from '../../helpers/activitypub' -import { isActorObjectValid, normalizeActor } from '../../helpers/custom-validators/activitypub/actor' +import { sanitizeAndCheckActorObject } from '../../helpers/custom-validators/activitypub/actor' import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' import { retryTransactionWrapper, updateInstanceWithAnother } from '../../helpers/database-utils' import { logger } from '../../helpers/logger' @@ -195,7 +195,7 @@ async function fetchAvatarIfExists (actorJSON: ActivityPubActor) { return undefined } -async function addFetchOutboxJob (actor: ActorModel) { +async function addFetchOutboxJob (actor: Pick) { // Don't fetch ourselves const serverActor = await getServerActor() if (serverActor.id === actor.id) { @@ -254,14 +254,14 @@ async function refreshActorIfNeeded ( await actor.save({ transaction: t }) if (actor.Account) { - actor.Account.set('name', result.name) - actor.Account.set('description', result.summary) + actor.Account.name = result.name + actor.Account.description = result.summary await actor.Account.save({ transaction: t }) } else if (actor.VideoChannel) { - actor.VideoChannel.set('name', result.name) - actor.VideoChannel.set('description', result.summary) - actor.VideoChannel.set('support', result.support) + actor.VideoChannel.name = result.name + actor.VideoChannel.description = result.summary + actor.VideoChannel.support = result.support await actor.VideoChannel.save({ transaction: t }) } @@ -369,10 +369,9 @@ async function fetchRemoteActor (actorUrl: string): Promise<{ statusCode?: numbe logger.info('Fetching remote actor %s.', actorUrl) const requestResult = await doRequest(options) - normalizeActor(requestResult.body) - const actorJSON = requestResult.body - if (isActorObjectValid(actorJSON) === false) { + + if (sanitizeAndCheckActorObject(actorJSON) === false) { logger.debug('Remote actor JSON is not valid.', { actorJSON }) return { result: undefined, statusCode: requestResult.response.statusCode } }