aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video/video-channel.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-08-16 15:25:20 +0200
committerChocobozzz <me@florianbigard.com>2018-08-27 09:41:54 +0200
commit06a05d5f4784a7cbb27aa1188385b5679845dad8 (patch)
treeac197f3ed0768529456225ad76c912f22bc55e29 /server/models/video/video-channel.ts
parent4bda2e47bbc937c401ddcf14c1be53c70481a294 (diff)
downloadPeerTube-06a05d5f4784a7cbb27aa1188385b5679845dad8.tar.gz
PeerTube-06a05d5f4784a7cbb27aa1188385b5679845dad8.tar.zst
PeerTube-06a05d5f4784a7cbb27aa1188385b5679845dad8.zip
Add subscriptions endpoints to REST API
Diffstat (limited to 'server/models/video/video-channel.ts')
-rw-r--r--server/models/video/video-channel.ts41
1 files changed, 35 insertions, 6 deletions
diff --git a/server/models/video/video-channel.ts b/server/models/video/video-channel.ts
index d0dba18d5..0273fab13 100644
--- a/server/models/video/video-channel.ts
+++ b/server/models/video/video-channel.ts
@@ -1,14 +1,27 @@
1import { 1import {
2 AllowNull, BeforeDestroy, BelongsTo, Column, CreatedAt, DefaultScope, ForeignKey, HasMany, Is, Model, Scopes, Table, 2 AllowNull,
3 UpdatedAt, Default, DataType 3 BeforeDestroy,
4 BelongsTo,
5 Column,
6 CreatedAt,
7 DataType,
8 Default,
9 DefaultScope,
10 ForeignKey,
11 HasMany,
12 Is,
13 Model,
14 Scopes,
15 Table,
16 UpdatedAt
4} from 'sequelize-typescript' 17} from 'sequelize-typescript'
5import { ActivityPubActor } from '../../../shared/models/activitypub' 18import { ActivityPubActor } from '../../../shared/models/activitypub'
6import { VideoChannel } from '../../../shared/models/videos' 19import { VideoChannel } from '../../../shared/models/videos'
7import { 20import {
8 isVideoChannelDescriptionValid, isVideoChannelNameValid, 21 isVideoChannelDescriptionValid,
22 isVideoChannelNameValid,
9 isVideoChannelSupportValid 23 isVideoChannelSupportValid
10} from '../../helpers/custom-validators/video-channels' 24} from '../../helpers/custom-validators/video-channels'
11import { logger } from '../../helpers/logger'
12import { sendDeleteActor } from '../../lib/activitypub/send' 25import { sendDeleteActor } from '../../lib/activitypub/send'
13import { AccountModel } from '../account/account' 26import { AccountModel } from '../account/account'
14import { ActorModel } from '../activitypub/actor' 27import { ActorModel } from '../activitypub/actor'
@@ -241,6 +254,23 @@ export class VideoChannelModel extends Model<VideoChannelModel> {
241 .findById(id, options) 254 .findById(id, options)
242 } 255 }
243 256
257 static loadLocalByName (name: string) {
258 const query = {
259 include: [
260 {
261 model: ActorModel,
262 required: true,
263 where: {
264 preferredUsername: name,
265 serverId: null
266 }
267 }
268 ]
269 }
270
271 return VideoChannelModel.findOne(query)
272 }
273
244 toFormattedJSON (): VideoChannel { 274 toFormattedJSON (): VideoChannel {
245 const actor = this.Actor.toFormattedJSON() 275 const actor = this.Actor.toFormattedJSON()
246 const videoChannel = { 276 const videoChannel = {
@@ -251,8 +281,7 @@ export class VideoChannelModel extends Model<VideoChannelModel> {
251 isLocal: this.Actor.isOwned(), 281 isLocal: this.Actor.isOwned(),
252 createdAt: this.createdAt, 282 createdAt: this.createdAt,
253 updatedAt: this.updatedAt, 283 updatedAt: this.updatedAt,
254 ownerAccount: undefined, 284 ownerAccount: undefined
255 videos: undefined
256 } 285 }
257 286
258 if (this.Account) videoChannel.ownerAccount = this.Account.toFormattedJSON() 287 if (this.Account) videoChannel.ownerAccount = this.Account.toFormattedJSON()