diff options
author | Chocobozzz <me@florianbigard.com> | 2018-08-21 10:34:18 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-08-27 09:41:54 +0200 |
commit | 99492dbc0d87ef54d0dab7d8d44f8d0de5722bdd (patch) | |
tree | e442f6cdf0cb622cb78f64d0d9de23bfb6deb951 /server/models/activitypub/actor-follow.ts | |
parent | 8a19bee1a1ee39f973bb37429e4f73c3f2873cdb (diff) | |
download | PeerTube-99492dbc0d87ef54d0dab7d8d44f8d0de5722bdd.tar.gz PeerTube-99492dbc0d87ef54d0dab7d8d44f8d0de5722bdd.tar.zst PeerTube-99492dbc0d87ef54d0dab7d8d44f8d0de5722bdd.zip |
Add get subscription endpoint
Diffstat (limited to 'server/models/activitypub/actor-follow.ts')
-rw-r--r-- | server/models/activitypub/actor-follow.ts | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/server/models/activitypub/actor-follow.ts b/server/models/activitypub/actor-follow.ts index 90a8ac43c..20d3aa5fc 100644 --- a/server/models/activitypub/actor-follow.ts +++ b/server/models/activitypub/actor-follow.ts | |||
@@ -28,6 +28,7 @@ import { ServerModel } from '../server/server' | |||
28 | import { getSort } from '../utils' | 28 | 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 | 32 | ||
32 | @Table({ | 33 | @Table({ |
33 | tableName: 'actorFollow', | 34 | tableName: 'actorFollow', |
@@ -166,28 +167,30 @@ export class ActorFollowModel extends Model<ActorFollowModel> { | |||
166 | } | 167 | } |
167 | 168 | ||
168 | static loadByActorAndTargetNameAndHost (actorId: number, targetName: string, targetHost: string, t?: Sequelize.Transaction) { | 169 | static loadByActorAndTargetNameAndHost (actorId: number, targetName: string, targetHost: string, t?: Sequelize.Transaction) { |
169 | const actorFollowingPartInclude = { | 170 | const actorFollowingPartInclude: IIncludeOptions = { |
170 | model: ActorModel, | 171 | model: ActorModel, |
171 | required: true, | 172 | required: true, |
172 | as: 'ActorFollowing', | 173 | as: 'ActorFollowing', |
173 | where: { | 174 | where: { |
174 | preferredUsername: targetName | 175 | preferredUsername: targetName |
175 | } | 176 | }, |
177 | include: [ | ||
178 | { | ||
179 | model: VideoChannelModel, | ||
180 | required: false | ||
181 | } | ||
182 | ] | ||
176 | } | 183 | } |
177 | 184 | ||
178 | if (targetHost === null) { | 185 | if (targetHost === null) { |
179 | actorFollowingPartInclude.where['serverId'] = null | 186 | actorFollowingPartInclude.where['serverId'] = null |
180 | } else { | 187 | } else { |
181 | Object.assign(actorFollowingPartInclude, { | 188 | actorFollowingPartInclude.include.push({ |
182 | include: [ | 189 | model: ServerModel, |
183 | { | 190 | required: true, |
184 | model: ServerModel, | 191 | where: { |
185 | required: true, | 192 | host: targetHost |
186 | where: { | 193 | } |
187 | host: targetHost | ||
188 | } | ||
189 | } | ||
190 | ] | ||
191 | }) | 194 | }) |
192 | } | 195 | } |
193 | 196 | ||