]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/models/video/video-channel.ts
Update channel updatedAt when uploading a video
[github/Chocobozzz/PeerTube.git] / server / models / video / video-channel.ts
CommitLineData
e024fd6a 1import { FindOptions, Includeable, literal, Op, QueryTypes, ScopeOptions, Transaction } from 'sequelize'
3fd3ab2d 2import {
06a05d5f
C
3 AllowNull,
4 BeforeDestroy,
5 BelongsTo,
6 Column,
7 CreatedAt,
8 DataType,
9 Default,
10 DefaultScope,
11 ForeignKey,
6dd9de95 12 HasMany,
06a05d5f
C
13 Is,
14 Model,
15 Scopes,
f37dc0dd 16 Sequelize,
06a05d5f
C
17 Table,
18 UpdatedAt
3fd3ab2d 19} from 'sequelize-typescript'
e024fd6a 20import { setAsUpdated } from '@server/helpers/database-utils'
a59f210f 21import { MAccountActor } from '@server/types/models'
50d6de9c 22import { ActivityPubActor } from '../../../shared/models/activitypub'
418d092a 23import { VideoChannel, VideoChannelSummary } from '../../../shared/models/videos'
2422c46b 24import {
06a05d5f
C
25 isVideoChannelDescriptionValid,
26 isVideoChannelNameValid,
2422c46b
C
27 isVideoChannelSupportValid
28} from '../../helpers/custom-validators/video-channels'
74dc3bca 29import { CONSTRAINTS_FIELDS, WEBSERVER } from '../../initializers/constants'
2af337c8 30import { sendDeleteActor } from '../../lib/activitypub/send'
453e83ea 31import {
453e83ea 32 MChannelActor,
b5fecbf4 33 MChannelAP,
2cb03dc1 34 MChannelBannerAccountDefault,
b5fecbf4
C
35 MChannelFormattable,
36 MChannelSummaryFormattable
26d6bf65 37} from '../../types/models/video'
2af337c8 38import { AccountModel, ScopeNames as AccountModelScopeNames, SummaryOptions as AccountSummaryOptions } from '../account/account'
f4796856 39import { ActorImageModel } from '../account/actor-image'
2af337c8
C
40import { ActorModel, unusedActorAttributesForAPI } from '../activitypub/actor'
41import { ActorFollowModel } from '../activitypub/actor-follow'
2af337c8
C
42import { ServerModel } from '../server/server'
43import { buildServerIdsFollowedBy, buildTrigramSearchIndex, createSimilarityAttribute, getSort, throwIfNotValid } from '../utils'
44import { VideoModel } from './video'
45import { VideoPlaylistModel } from './video-playlist'
f37dc0dd 46
418d092a 47export enum ScopeNames {
453e83ea 48 FOR_API = 'FOR_API',
8165d00a 49 SUMMARY = 'SUMMARY',
d48ff09d 50 WITH_ACCOUNT = 'WITH_ACCOUNT',
50d6de9c 51 WITH_ACTOR = 'WITH_ACTOR',
2cb03dc1 52 WITH_ACTOR_BANNER = 'WITH_ACTOR_BANNER',
418d092a 53 WITH_VIDEOS = 'WITH_VIDEOS',
8165d00a 54 WITH_STATS = 'WITH_STATS'
d48ff09d
C
55}
56
f37dc0dd
C
57type AvailableForListOptions = {
58 actorId: number
bc99dfe5 59 search?: string
f37dc0dd
C
60}
61
8165d00a
RK
62type AvailableWithStatsOptions = {
63 daysPrior: number
64}
65
bfbd9128 66export type SummaryOptions = {
4f32032f 67 actorRequired?: boolean // Default: true
bfbd9128
C
68 withAccount?: boolean // Default: false
69 withAccountBlockerIds?: number[]
70}
71
3acc5084 72@DefaultScope(() => ({
50d6de9c
C
73 include: [
74 {
3acc5084 75 model: ActorModel,
50d6de9c
C
76 required: true
77 }
78 ]
3acc5084
C
79}))
80@Scopes(() => ({
453e83ea 81 [ScopeNames.FOR_API]: (options: AvailableForListOptions) => {
f37dc0dd 82 // Only list local channels OR channels that are on an instance followed by actorId
418d092a 83 const inQueryInstanceFollow = buildServerIdsFollowedBy(options.actorId)
f37dc0dd
C
84
85 return {
86 include: [
87 {
88 attributes: {
89 exclude: unusedActorAttributesForAPI
90 },
91 model: ActorModel,
92 where: {
1735c825 93 [Op.or]: [
c305467c 94 {
f37dc0dd
C
95 serverId: null
96 },
97 {
98 serverId: {
a1587156 99 [Op.in]: Sequelize.literal(inQueryInstanceFollow)
f37dc0dd 100 }
c305467c
C
101 }
102 ]
213e30ef
C
103 },
104 include: [
105 {
106 model: ActorImageModel,
107 as: 'Banner',
108 required: false
109 }
110 ]
f37dc0dd
C
111 },
112 {
113 model: AccountModel,
114 required: true,
115 include: [
116 {
117 attributes: {
118 exclude: unusedActorAttributesForAPI
119 },
120 model: ActorModel, // Default scope includes avatar and server
121 required: true
122 }
123 ]
124 }
125 ]
126 }
127 },
8165d00a 128 [ScopeNames.SUMMARY]: (options: SummaryOptions = {}) => {
b49f22d8
C
129 const include: Includeable[] = [
130 {
131 attributes: [ 'id', 'preferredUsername', 'url', 'serverId', 'avatarId' ],
132 model: ActorModel.unscoped(),
133 required: options.actorRequired ?? true,
134 include: [
135 {
136 attributes: [ 'host' ],
137 model: ServerModel.unscoped(),
138 required: false
139 },
140 {
f4796856
C
141 model: ActorImageModel.unscoped(),
142 as: 'Avatar',
b49f22d8
C
143 required: false
144 }
145 ]
146 }
147 ]
148
8165d00a 149 const base: FindOptions = {
b49f22d8 150 attributes: [ 'id', 'name', 'description', 'actorId' ]
8165d00a
RK
151 }
152
153 if (options.withAccount === true) {
b49f22d8 154 include.push({
8165d00a
RK
155 model: AccountModel.scope({
156 method: [ AccountModelScopeNames.SUMMARY, { withAccountBlockerIds: options.withAccountBlockerIds } as AccountSummaryOptions ]
157 }),
158 required: true
159 })
160 }
161
b49f22d8
C
162 base.include = include
163
8165d00a
RK
164 return base
165 },
f37dc0dd
C
166 [ScopeNames.WITH_ACCOUNT]: {
167 include: [
168 {
3acc5084 169 model: AccountModel,
f37dc0dd 170 required: true
d48ff09d
C
171 }
172 ]
173 },
8165d00a 174 [ScopeNames.WITH_ACTOR]: {
d48ff09d 175 include: [
8165d00a 176 ActorModel
d48ff09d 177 ]
50d6de9c 178 },
2cb03dc1
C
179 [ScopeNames.WITH_ACTOR_BANNER]: {
180 include: [
181 {
182 model: ActorModel,
183 include: [
184 {
185 model: ActorImageModel,
186 required: false,
187 as: 'Banner'
188 }
189 ]
190 }
191 ]
192 },
8165d00a 193 [ScopeNames.WITH_VIDEOS]: {
50d6de9c 194 include: [
8165d00a 195 VideoModel
50d6de9c 196 ]
8165d00a 197 },
3d527ba1
RK
198 [ScopeNames.WITH_STATS]: (options: AvailableWithStatsOptions = { daysPrior: 30 }) => {
199 const daysPrior = parseInt(options.daysPrior + '', 10)
200
201 return {
202 attributes: {
203 include: [
1ba471c5
C
204 [
205 literal('(SELECT COUNT(*) FROM "video" WHERE "channelId" = "VideoChannelModel"."id")'),
206 'videosCount'
207 ],
3d527ba1
RK
208 [
209 literal(
210 '(' +
211 `SELECT string_agg(concat_ws('|', t.day, t.views), ',') ` +
212 'FROM ( ' +
213 'WITH ' +
214 'days AS ( ' +
215 `SELECT generate_series(date_trunc('day', now()) - '${daysPrior} day'::interval, ` +
216 `date_trunc('day', now()), '1 day'::interval) AS day ` +
8165d00a 217 ') ' +
5a61ffbb
C
218 'SELECT days.day AS day, COALESCE(SUM("videoView".views), 0) AS views ' +
219 'FROM days ' +
220 'LEFT JOIN (' +
221 '"videoView" INNER JOIN "video" ON "videoView"."videoId" = "video"."id" ' +
222 'AND "video"."channelId" = "VideoChannelModel"."id"' +
223 `) ON date_trunc('day', "videoView"."startDate") = date_trunc('day', days.day) ` +
224 'GROUP BY day ' +
225 'ORDER BY day ' +
226 ') t' +
3d527ba1
RK
227 ')'
228 ),
229 'viewsPerDay'
230 ]
8165d00a 231 ]
3d527ba1 232 }
8165d00a 233 }
3d527ba1 234 }
3acc5084 235}))
3fd3ab2d
C
236@Table({
237 tableName: 'videoChannel',
0374b6b5
C
238 indexes: [
239 buildTrigramSearchIndex('video_channel_name_trigram', 'name'),
240
241 {
242 fields: [ 'accountId' ]
243 },
244 {
245 fields: [ 'actorId' ]
246 }
247 ]
3fd3ab2d 248})
b49f22d8 249export class VideoChannelModel extends Model {
72c7248b 250
3fd3ab2d
C
251 @AllowNull(false)
252 @Is('VideoChannelName', value => throwIfNotValid(value, isVideoChannelNameValid, 'name'))
253 @Column
254 name: string
72c7248b 255
3fd3ab2d 256 @AllowNull(true)
2422c46b 257 @Default(null)
1735c825 258 @Is('VideoChannelDescription', value => throwIfNotValid(value, isVideoChannelDescriptionValid, 'description', true))
a10fc78b 259 @Column(DataType.STRING(CONSTRAINTS_FIELDS.VIDEO_CHANNELS.DESCRIPTION.max))
3fd3ab2d 260 description: string
72c7248b 261
2422c46b
C
262 @AllowNull(true)
263 @Default(null)
1735c825 264 @Is('VideoChannelSupport', value => throwIfNotValid(value, isVideoChannelSupportValid, 'support', true))
a10fc78b 265 @Column(DataType.STRING(CONSTRAINTS_FIELDS.VIDEO_CHANNELS.SUPPORT.max))
2422c46b
C
266 support: string
267
3fd3ab2d
C
268 @CreatedAt
269 createdAt: Date
72c7248b 270
3fd3ab2d
C
271 @UpdatedAt
272 updatedAt: Date
4e50b6a1 273
fadf619a
C
274 @ForeignKey(() => ActorModel)
275 @Column
276 actorId: number
277
278 @BelongsTo(() => ActorModel, {
279 foreignKey: {
280 allowNull: false
281 },
282 onDelete: 'cascade'
283 })
284 Actor: ActorModel
285
3fd3ab2d
C
286 @ForeignKey(() => AccountModel)
287 @Column
288 accountId: number
4e50b6a1 289
3fd3ab2d
C
290 @BelongsTo(() => AccountModel, {
291 foreignKey: {
292 allowNull: false
293 },
6b738c7a 294 hooks: true
3fd3ab2d
C
295 })
296 Account: AccountModel
72c7248b 297
3fd3ab2d 298 @HasMany(() => VideoModel, {
72c7248b 299 foreignKey: {
3fd3ab2d 300 name: 'channelId',
72c7248b
C
301 allowNull: false
302 },
f05a1c30
C
303 onDelete: 'CASCADE',
304 hooks: true
72c7248b 305 })
3fd3ab2d 306 Videos: VideoModel[]
72c7248b 307
418d092a
C
308 @HasMany(() => VideoPlaylistModel, {
309 foreignKey: {
07b1a18a 310 allowNull: true
418d092a 311 },
df0b219d 312 onDelete: 'CASCADE',
418d092a
C
313 hooks: true
314 })
315 VideoPlaylists: VideoPlaylistModel[]
316
f05a1c30
C
317 @BeforeDestroy
318 static async sendDeleteIfOwned (instance: VideoChannelModel, options) {
319 if (!instance.Actor) {
e6122097 320 instance.Actor = await instance.$get('Actor', { transaction: options.transaction })
f05a1c30
C
321 }
322
2af337c8
C
323 await ActorFollowModel.removeFollowsOf(instance.Actor.id, options.transaction)
324
c5a893d5 325 if (instance.Actor.isOwned()) {
c5a893d5
C
326 return sendDeleteActor(instance.Actor, options.transaction)
327 }
328
329 return undefined
3fd3ab2d 330 }
72c7248b 331
3fd3ab2d
C
332 static countByAccount (accountId: number) {
333 const query = {
334 where: {
335 accountId
336 }
72c7248b 337 }
3fd3ab2d
C
338
339 return VideoChannelModel.count(query)
72c7248b
C
340 }
341
fe19f600
RK
342 static async getStats () {
343
344 function getActiveVideoChannels (days: number) {
345 const options = {
346 type: QueryTypes.SELECT as QueryTypes.SELECT,
347 raw: true
348 }
349
350 const query = `
351SELECT COUNT(DISTINCT("VideoChannelModel"."id")) AS "count"
352FROM "videoChannel" AS "VideoChannelModel"
353INNER JOIN "video" AS "Videos"
354ON "VideoChannelModel"."id" = "Videos"."channelId"
355AND ("Videos"."publishedAt" > Now() - interval '${days}d')
356INNER JOIN "account" AS "Account"
357ON "VideoChannelModel"."accountId" = "Account"."id"
358INNER JOIN "actor" AS "Account->Actor"
359ON "Account"."actorId" = "Account->Actor"."id"
360AND "Account->Actor"."serverId" IS NULL
361LEFT OUTER JOIN "server" AS "Account->Actor->Server"
362ON "Account->Actor"."serverId" = "Account->Actor->Server"."id"`
363
364 return VideoChannelModel.sequelize.query<{ count: string }>(query, options)
365 .then(r => parseInt(r[0].count, 10))
366 }
367
368 const totalLocalVideoChannels = await VideoChannelModel.count()
369 const totalLocalDailyActiveVideoChannels = await getActiveVideoChannels(1)
370 const totalLocalWeeklyActiveVideoChannels = await getActiveVideoChannels(7)
371 const totalLocalMonthlyActiveVideoChannels = await getActiveVideoChannels(30)
372 const totalHalfYearActiveVideoChannels = await getActiveVideoChannels(180)
373
374 return {
375 totalLocalVideoChannels,
376 totalLocalDailyActiveVideoChannels,
377 totalLocalWeeklyActiveVideoChannels,
378 totalLocalMonthlyActiveVideoChannels,
379 totalHalfYearActiveVideoChannels
380 }
381 }
382
bc99dfe5
RK
383 static listForApi (parameters: {
384 actorId: number
385 start: number
386 count: number
387 sort: string
bc99dfe5 388 }) {
4f5d0459 389 const { actorId } = parameters
bc99dfe5 390
3fd3ab2d 391 const query = {
bc99dfe5
RK
392 offset: parameters.start,
393 limit: parameters.count,
394 order: getSort(parameters.sort)
3fd3ab2d 395 }
72c7248b 396
50d6de9c 397 return VideoChannelModel
b49f22d8
C
398 .scope({
399 method: [ ScopeNames.FOR_API, { actorId } as AvailableForListOptions ]
400 })
f37dc0dd
C
401 .findAndCountAll(query)
402 .then(({ rows, count }) => {
403 return { total: count, data: rows }
404 })
405 }
406
b49f22d8 407 static listLocalsForSitemap (sort: string): Promise<MChannelActor[]> {
2feebf3e
C
408 const query = {
409 attributes: [ ],
410 offset: 0,
411 order: getSort(sort),
412 include: [
413 {
414 attributes: [ 'preferredUsername', 'serverId' ],
415 model: ActorModel.unscoped(),
416 where: {
417 serverId: null
418 }
419 }
420 ]
421 }
422
423 return VideoChannelModel
424 .unscoped()
425 .findAll(query)
426 }
427
f37dc0dd
C
428 static searchForApi (options: {
429 actorId: number
430 search: string
431 start: number
432 count: number
433 sort: string
434 }) {
435 const attributesInclude = []
436 const escapedSearch = VideoModel.sequelize.escape(options.search)
437 const escapedLikeSearch = VideoModel.sequelize.escape('%' + options.search + '%')
438 attributesInclude.push(createSimilarityAttribute('VideoChannelModel.name', options.search))
439
440 const query = {
441 attributes: {
442 include: attributesInclude
443 },
444 offset: options.start,
445 limit: options.count,
446 order: getSort(options.sort),
447 where: {
1735c825 448 [Op.or]: [
c3c2ab1c
C
449 Sequelize.literal(
450 'lower(immutable_unaccent("VideoChannelModel"."name")) % lower(immutable_unaccent(' + escapedSearch + '))'
451 ),
452 Sequelize.literal(
453 'lower(immutable_unaccent("VideoChannelModel"."name")) LIKE lower(immutable_unaccent(' + escapedLikeSearch + '))'
f37dc0dd 454 )
c3c2ab1c 455 ]
f37dc0dd
C
456 }
457 }
458
f37dc0dd 459 return VideoChannelModel
b49f22d8
C
460 .scope({
461 method: [ ScopeNames.FOR_API, { actorId: options.actorId } as AvailableForListOptions ]
462 })
50d6de9c 463 .findAndCountAll(query)
3fd3ab2d
C
464 .then(({ rows, count }) => {
465 return { total: count, data: rows }
466 })
72c7248b
C
467 }
468
91b66319 469 static listByAccount (options: {
a1587156
C
470 accountId: number
471 start: number
472 count: number
91b66319 473 sort: string
8165d00a 474 withStats?: boolean
4f5d0459 475 search?: string
91b66319 476 }) {
4f5d0459
RK
477 const escapedSearch = VideoModel.sequelize.escape(options.search)
478 const escapedLikeSearch = VideoModel.sequelize.escape('%' + options.search + '%')
479 const where = options.search
480 ? {
481 [Op.or]: [
482 Sequelize.literal(
483 'lower(immutable_unaccent("VideoChannelModel"."name")) % lower(immutable_unaccent(' + escapedSearch + '))'
484 ),
485 Sequelize.literal(
486 'lower(immutable_unaccent("VideoChannelModel"."name")) LIKE lower(immutable_unaccent(' + escapedLikeSearch + '))'
487 )
488 ]
489 }
490 : null
491
3fd3ab2d 492 const query = {
91b66319
C
493 offset: options.start,
494 limit: options.count,
495 order: getSort(options.sort),
3fd3ab2d
C
496 include: [
497 {
498 model: AccountModel,
499 where: {
91b66319 500 id: options.accountId
3fd3ab2d 501 },
50d6de9c 502 required: true
3fd3ab2d 503 }
4f5d0459
RK
504 ],
505 where
3fd3ab2d 506 }
72c7248b 507
2cb03dc1 508 const scopes: string | ScopeOptions | (string | ScopeOptions)[] = [ ScopeNames.WITH_ACTOR_BANNER ]
8165d00a 509
5a61ffbb 510 if (options.withStats === true) {
8165d00a
RK
511 scopes.push({
512 method: [ ScopeNames.WITH_STATS, { daysPrior: 30 } as AvailableWithStatsOptions ]
513 })
514 }
515
50d6de9c 516 return VideoChannelModel
8165d00a 517 .scope(scopes)
50d6de9c 518 .findAndCountAll(query)
3fd3ab2d
C
519 .then(({ rows, count }) => {
520 return { total: count, data: rows }
521 })
72c7248b
C
522 }
523
2cb03dc1 524 static loadAndPopulateAccount (id: number): Promise<MChannelBannerAccountDefault> {
5cf84858 525 return VideoChannelModel.unscoped()
2cb03dc1 526 .scope([ ScopeNames.WITH_ACTOR_BANNER, ScopeNames.WITH_ACCOUNT ])
9b39106d 527 .findByPk(id)
3fd3ab2d 528 }
0d0e8dd0 529
2cb03dc1 530 static loadByUrlAndPopulateAccount (url: string): Promise<MChannelBannerAccountDefault> {
f37dc0dd
C
531 const query = {
532 include: [
533 {
534 model: ActorModel,
535 required: true,
536 where: {
537 url
2cb03dc1
C
538 },
539 include: [
540 {
541 model: ActorImageModel,
542 required: false,
543 as: 'Banner'
544 }
545 ]
f37dc0dd
C
546 }
547 ]
548 }
549
550 return VideoChannelModel
551 .scope([ ScopeNames.WITH_ACCOUNT ])
8a19bee1 552 .findOne(query)
72c7248b
C
553 }
554
92bf2f62
C
555 static loadByNameWithHostAndPopulateAccount (nameWithHost: string) {
556 const [ name, host ] = nameWithHost.split('@')
557
6dd9de95 558 if (!host || host === WEBSERVER.HOST) return VideoChannelModel.loadLocalByNameAndPopulateAccount(name)
92bf2f62
C
559
560 return VideoChannelModel.loadByNameAndHostAndPopulateAccount(name, host)
561 }
562
2cb03dc1 563 static loadLocalByNameAndPopulateAccount (name: string): Promise<MChannelBannerAccountDefault> {
8a19bee1 564 const query = {
3fd3ab2d 565 include: [
8a19bee1
C
566 {
567 model: ActorModel,
568 required: true,
569 where: {
570 preferredUsername: name,
571 serverId: null
2cb03dc1
C
572 },
573 include: [
574 {
575 model: ActorImageModel,
576 required: false,
577 as: 'Banner'
578 }
579 ]
8a19bee1 580 }
3fd3ab2d
C
581 ]
582 }
72c7248b 583
5cf84858 584 return VideoChannelModel.unscoped()
2cb03dc1 585 .scope([ ScopeNames.WITH_ACCOUNT ])
8a19bee1 586 .findOne(query)
72c7248b
C
587 }
588
2cb03dc1 589 static loadByNameAndHostAndPopulateAccount (name: string, host: string): Promise<MChannelBannerAccountDefault> {
06a05d5f
C
590 const query = {
591 include: [
592 {
593 model: ActorModel,
594 required: true,
595 where: {
8a19bee1
C
596 preferredUsername: name
597 },
598 include: [
599 {
600 model: ServerModel,
601 required: true,
602 where: { host }
2cb03dc1
C
603 },
604 {
605 model: ActorImageModel,
606 required: false,
607 as: 'Banner'
8a19bee1
C
608 }
609 ]
06a05d5f
C
610 }
611 ]
612 }
613
5cf84858 614 return VideoChannelModel.unscoped()
2cb03dc1 615 .scope([ ScopeNames.WITH_ACCOUNT ])
8a19bee1
C
616 .findOne(query)
617 }
618
1ca9f7c3
C
619 toFormattedSummaryJSON (this: MChannelSummaryFormattable): VideoChannelSummary {
620 const actor = this.Actor.toFormattedSummaryJSON()
621
622 return {
623 id: this.id,
624 name: actor.name,
625 displayName: this.getDisplayName(),
626 url: actor.url,
627 host: actor.host,
628 avatar: actor.avatar
629 }
630 }
631
632 toFormattedJSON (this: MChannelFormattable): VideoChannel {
1ba471c5
C
633 const viewsPerDayString = this.get('viewsPerDay') as string
634 const videosCount = this.get('videosCount') as number
635
636 let viewsPerDay: { date: Date, views: number }[]
637
638 if (viewsPerDayString) {
639 viewsPerDay = viewsPerDayString.split(',')
640 .map(v => {
641 const [ dateString, amount ] = v.split('|')
642
643 return {
644 date: new Date(dateString),
645 views: +amount
646 }
647 })
648 }
8165d00a 649
50d6de9c 650 const actor = this.Actor.toFormattedJSON()
6b738c7a 651 const videoChannel = {
3fd3ab2d 652 id: this.id,
749c7247 653 displayName: this.getDisplayName(),
3fd3ab2d 654 description: this.description,
2422c46b 655 support: this.support,
50d6de9c 656 isLocal: this.Actor.isOwned(),
e024fd6a 657 updatedAt: this.updatedAt,
8165d00a 658 ownerAccount: undefined,
1ba471c5
C
659 videosCount,
660 viewsPerDay
6b738c7a
C
661 }
662
a4f99a76 663 if (this.Account) videoChannel.ownerAccount = this.Account.toFormattedJSON()
72c7248b 664
6b738c7a 665 return Object.assign(actor, videoChannel)
72c7248b
C
666 }
667
b5fecbf4 668 toActivityPubObject (this: MChannelAP): ActivityPubActor {
8424c402 669 const obj = this.Actor.toActivityPubObject(this.name)
50d6de9c
C
670
671 return Object.assign(obj, {
672 summary: this.description,
2422c46b 673 support: this.support,
50d6de9c
C
674 attributedTo: [
675 {
676 type: 'Person' as 'Person',
677 id: this.Account.Actor.url
678 }
679 ]
680 })
72c7248b 681 }
749c7247 682
a59f210f
C
683 getLocalUrl (this: MAccountActor | MChannelActor) {
684 return WEBSERVER.URL + `/video-channels/` + this.Actor.preferredUsername
685 }
686
749c7247
C
687 getDisplayName () {
688 return this.name
689 }
744d0eca
C
690
691 isOutdated () {
692 return this.Actor.isOutdated()
693 }
e024fd6a
C
694
695 setAsUpdated (transaction: Transaction) {
696 return setAsUpdated('videoChannel', this.id, transaction)
697 }
72c7248b 698}