From c46edbc2f6ca310b2f0331f979ac6caf27f6eb92 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 22 Nov 2017 11:27:40 +0100 Subject: Fetch outbox to grab old activities tests --- server/controllers/activitypub/client.ts | 4 ++-- server/controllers/activitypub/outbox.ts | 2 +- server/controllers/api/server/follows.ts | 13 +++++-------- 3 files changed, 8 insertions(+), 11 deletions(-) (limited to 'server/controllers') diff --git a/server/controllers/activitypub/client.ts b/server/controllers/activitypub/client.ts index 24c8665a5..eee89e2fd 100644 --- a/server/controllers/activitypub/client.ts +++ b/server/controllers/activitypub/client.ts @@ -56,7 +56,7 @@ async function accountController (req: express.Request, res: express.Response, n async function accountFollowersController (req: express.Request, res: express.Response, next: express.NextFunction) { const account: AccountInstance = res.locals.account - const page = req.params.page || 1 + const page = req.query.page || 1 const { start, count } = pageToStartAndCount(page, ACTIVITY_PUB.COLLECTION_ITEMS_PER_PAGE) const result = await db.AccountFollow.listAcceptedFollowerUrlsForApi([ account.id ], start, count) @@ -68,7 +68,7 @@ async function accountFollowersController (req: express.Request, res: express.Re async function accountFollowingController (req: express.Request, res: express.Response, next: express.NextFunction) { const account: AccountInstance = res.locals.account - const page = req.params.page || 1 + const page = req.query.page || 1 const { start, count } = pageToStartAndCount(page, ACTIVITY_PUB.COLLECTION_ITEMS_PER_PAGE) const result = await db.AccountFollow.listAcceptedFollowingUrlsForApi([ account.id ], start, count) diff --git a/server/controllers/activitypub/outbox.ts b/server/controllers/activitypub/outbox.ts index 1a74bde33..74d399763 100644 --- a/server/controllers/activitypub/outbox.ts +++ b/server/controllers/activitypub/outbox.ts @@ -28,7 +28,7 @@ export { async function outboxController (req: express.Request, res: express.Response, next: express.NextFunction) { const account: AccountInstance = res.locals.account - const page = req.params.page || 1 + const page = req.query.page || 1 const { start, count } = pageToStartAndCount(page, ACTIVITY_PUB.COLLECTION_ITEMS_PER_PAGE) const data = await db.Video.listAllAndSharedByAccountForOutbox(account.id, start, count) diff --git a/server/controllers/api/server/follows.ts b/server/controllers/api/server/follows.ts index 4b54afc8d..391f8bdca 100644 --- a/server/controllers/api/server/follows.ts +++ b/server/controllers/api/server/follows.ts @@ -1,11 +1,15 @@ import * as express from 'express' import { UserRight } from '../../../../shared/models/users/user-right.enum' import { getFormattedObjects } from '../../../helpers' +import { retryTransactionWrapper } from '../../../helpers/database-utils' import { logger } from '../../../helpers/logger' import { getServerAccount } from '../../../helpers/utils' import { getAccountFromWebfinger } from '../../../helpers/webfinger' import { SERVER_ACCOUNT_NAME } from '../../../initializers/constants' import { database as db } from '../../../initializers/database' +import { saveAccountAndServerIfNotExist } from '../../../lib/activitypub/account' +import { sendUndoFollow } from '../../../lib/activitypub/send/send-undo' +import { sendFollow } from '../../../lib/index' import { asyncMiddleware, paginationValidator, removeFollowingValidator, setFollowersSort, setPagination } from '../../../middlewares' import { authenticate } from '../../../middlewares/oauth' import { setBodyHostsPort } from '../../../middlewares/servers' @@ -13,13 +17,8 @@ import { setFollowingSort } from '../../../middlewares/sort' import { ensureUserHasRight } from '../../../middlewares/user-right' import { followValidator } from '../../../middlewares/validators/follows' import { followersSortValidator, followingSortValidator } from '../../../middlewares/validators/sort' -import { AccountFollowInstance } from '../../../models/index' -import { sendFollow } from '../../../lib/index' -import { sendUndoFollow } from '../../../lib/activitypub/send/send-undo' import { AccountInstance } from '../../../models/account/account-interface' -import { retryTransactionWrapper } from '../../../helpers/database-utils' -import { saveAccountAndServerIfNotExist } from '../../../lib/activitypub/account' -import { addFetchOutboxJob } from '../../../lib/activitypub/fetch' +import { AccountFollowInstance } from '../../../models/index' const serverFollowsRouter = express.Router() @@ -137,8 +136,6 @@ async function follow (fromAccount: AccountInstance, targetAccount: AccountInsta if (accountFollow.state === 'pending') { await sendFollow(accountFollow, t) } - - await addFetchOutboxJob(targetAccount, t) }) } catch (err) { // Reset target account -- cgit v1.2.3