From 4d029ef8ec3d5274eeaa3ee6d808eb7035e7faef Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 20 Jul 2021 14:15:15 +0200 Subject: Add ability for instances to follow any actor --- server/lib/activitypub/crawl.ts | 3 ++- server/lib/activitypub/follow.ts | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) (limited to 'server/lib/activitypub') diff --git a/server/lib/activitypub/crawl.ts b/server/lib/activitypub/crawl.ts index cd117f571..28ff5225a 100644 --- a/server/lib/activitypub/crawl.ts +++ b/server/lib/activitypub/crawl.ts @@ -1,3 +1,4 @@ +import { retryTransactionWrapper } from '@server/helpers/database-utils' import * as Bluebird from 'bluebird' import { URL } from 'url' import { ActivityPubOrderedCollection } from '../../../shared/models/activitypub' @@ -51,7 +52,7 @@ async function crawlCollectionPage (argUrl: string, handler: HandlerFunction } } - if (cleaner) await cleaner(startDate) + if (cleaner) await retryTransactionWrapper(cleaner, startDate) } export { diff --git a/server/lib/activitypub/follow.ts b/server/lib/activitypub/follow.ts index c1bd667e0..741b54df5 100644 --- a/server/lib/activitypub/follow.ts +++ b/server/lib/activitypub/follow.ts @@ -31,6 +31,21 @@ async function autoFollowBackIfNeeded (actorFollow: MActorFollowActors, transact } } +// If we only have an host, use a default account handle +function getRemoteNameAndHost (handleOrHost: string) { + let name = SERVER_ACTOR_NAME + let host = handleOrHost + + const splitted = handleOrHost.split('@') + if (splitted.length === 2) { + name = splitted[0] + host = splitted[1] + } + + return { name, host } +} + export { - autoFollowBackIfNeeded + autoFollowBackIfNeeded, + getRemoteNameAndHost } -- cgit v1.2.3