diff options
author | Chocobozzz <me@florianbigard.com> | 2018-08-21 16:18:59 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-08-27 09:41:54 +0200 |
commit | 22a16e36f6526887ed8f5e5d3c9f9e5da0b4a8cd (patch) | |
tree | 93c53e0619f966bd9ff1bb698c411277a9447a41 /server | |
parent | 99492dbc0d87ef54d0dab7d8d44f8d0de5722bdd (diff) | |
download | PeerTube-22a16e36f6526887ed8f5e5d3c9f9e5da0b4a8cd.tar.gz PeerTube-22a16e36f6526887ed8f5e5d3c9f9e5da0b4a8cd.tar.zst PeerTube-22a16e36f6526887ed8f5e5d3c9f9e5da0b4a8cd.zip |
Add local user subscriptions
Diffstat (limited to 'server')
-rw-r--r-- | server/lib/job-queue/handlers/activitypub-follow.ts | 15 | ||||
-rw-r--r-- | server/models/activitypub/actor-follow.ts | 9 |
2 files changed, 17 insertions, 7 deletions
diff --git a/server/lib/job-queue/handlers/activitypub-follow.ts b/server/lib/job-queue/handlers/activitypub-follow.ts index 282dde268..36d0f237b 100644 --- a/server/lib/job-queue/handlers/activitypub-follow.ts +++ b/server/lib/job-queue/handlers/activitypub-follow.ts | |||
@@ -1,7 +1,6 @@ | |||
1 | import * as Bull from 'bull' | 1 | import * as Bull from 'bull' |
2 | import { logger } from '../../../helpers/logger' | 2 | import { logger } from '../../../helpers/logger' |
3 | import { getServerActor } from '../../../helpers/utils' | 3 | import { CONFIG, REMOTE_SCHEME, sequelizeTypescript } from '../../../initializers' |
4 | import { REMOTE_SCHEME, sequelizeTypescript } from '../../../initializers' | ||
5 | import { sendFollow } from '../../activitypub/send' | 4 | import { sendFollow } from '../../activitypub/send' |
6 | import { sanitizeHost } from '../../../helpers/core-utils' | 5 | import { sanitizeHost } from '../../../helpers/core-utils' |
7 | import { loadActorUrlOrGetFromWebfinger } from '../../../helpers/webfinger' | 6 | import { loadActorUrlOrGetFromWebfinger } from '../../../helpers/webfinger' |
@@ -22,10 +21,14 @@ async function processActivityPubFollow (job: Bull.Job) { | |||
22 | 21 | ||
23 | logger.info('Processing ActivityPub follow in job %d.', job.id) | 22 | logger.info('Processing ActivityPub follow in job %d.', job.id) |
24 | 23 | ||
25 | const sanitizedHost = sanitizeHost(host, REMOTE_SCHEME.HTTP) | 24 | let targetActor: ActorModel |
26 | 25 | if (!host || host === CONFIG.WEBSERVER.HOST) { | |
27 | const actorUrl = await loadActorUrlOrGetFromWebfinger(payload.name + '@' + sanitizedHost) | 26 | targetActor = await ActorModel.loadLocalByName(payload.name) |
28 | const targetActor = await getOrCreateActorAndServerAndModel(actorUrl) | 27 | } else { |
28 | const sanitizedHost = sanitizeHost(host, REMOTE_SCHEME.HTTP) | ||
29 | const actorUrl = await loadActorUrlOrGetFromWebfinger(payload.name + '@' + sanitizedHost) | ||
30 | targetActor = await getOrCreateActorAndServerAndModel(actorUrl) | ||
31 | } | ||
29 | 32 | ||
30 | const fromActor = await ActorModel.load(payload.followerActorId) | 33 | const fromActor = await ActorModel.load(payload.followerActorId) |
31 | 34 | ||
diff --git a/server/models/activitypub/actor-follow.ts b/server/models/activitypub/actor-follow.ts index 20d3aa5fc..b2d7ace66 100644 --- a/server/models/activitypub/actor-follow.ts +++ b/server/models/activitypub/actor-follow.ts | |||
@@ -29,6 +29,7 @@ import { getSort } from '../utils' | |||
29 | import { ActorModel } from './actor' | 29 | import { ActorModel } from './actor' |
30 | import { VideoChannelModel } from '../video/video-channel' | 30 | import { VideoChannelModel } from '../video/video-channel' |
31 | import { IIncludeOptions } from '../../../node_modules/sequelize-typescript/lib/interfaces/IIncludeOptions' | 31 | import { IIncludeOptions } from '../../../node_modules/sequelize-typescript/lib/interfaces/IIncludeOptions' |
32 | import { AccountModel } from '../account/account' | ||
32 | 33 | ||
33 | @Table({ | 34 | @Table({ |
34 | tableName: 'actorFollow', | 35 | tableName: 'actorFollow', |
@@ -262,7 +263,13 @@ export class ActorFollowModel extends Model<ActorFollowModel> { | |||
262 | include: [ | 263 | include: [ |
263 | { | 264 | { |
264 | model: VideoChannelModel, | 265 | model: VideoChannelModel, |
265 | required: true | 266 | required: true, |
267 | include: [ | ||
268 | { | ||
269 | model: AccountModel, | ||
270 | required: true | ||
271 | } | ||
272 | ] | ||
266 | } | 273 | } |
267 | ] | 274 | ] |
268 | } | 275 | } |