aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models
diff options
context:
space:
mode:
Diffstat (limited to 'server/models')
-rw-r--r--server/models/account/account-video-rate.ts3
-rw-r--r--server/models/activitypub/actor-follow.ts36
-rw-r--r--server/models/video/video-format-utils.ts16
3 files changed, 34 insertions, 21 deletions
diff --git a/server/models/account/account-video-rate.ts b/server/models/account/account-video-rate.ts
index 5064987dc..6955f45ee 100644
--- a/server/models/account/account-video-rate.ts
+++ b/server/models/account/account-video-rate.ts
@@ -168,7 +168,8 @@ export class AccountVideoRateModel extends Model<AccountVideoRateModel> {
168 model: ActorModel.unscoped(), 168 model: ActorModel.unscoped(),
169 required: true, 169 required: true,
170 where: { 170 where: {
171 preferredUsername: accountName 171 preferredUsername: accountName,
172 serverId: null
172 } 173 }
173 } 174 }
174 ] 175 ]
diff --git a/server/models/activitypub/actor-follow.ts b/server/models/activitypub/actor-follow.ts
index 10c13304f..58bc63d34 100644
--- a/server/models/activitypub/actor-follow.ts
+++ b/server/models/activitypub/actor-follow.ts
@@ -1,5 +1,6 @@
1import * as Bluebird from 'bluebird' 1import * as Bluebird from 'bluebird'
2import { difference, values } from 'lodash' 2import { difference, values } from 'lodash'
3import { IncludeOptions, Op, QueryTypes, Transaction, WhereOptions } from 'sequelize'
3import { 4import {
4 AfterCreate, 5 AfterCreate,
5 AfterDestroy, 6 AfterDestroy,
@@ -11,22 +12,16 @@ import {
11 DataType, 12 DataType,
12 Default, 13 Default,
13 ForeignKey, 14 ForeignKey,
15 Is,
14 IsInt, 16 IsInt,
15 Max, 17 Max,
16 Model, 18 Model,
17 Table, 19 Table,
18 UpdatedAt 20 UpdatedAt
19} from 'sequelize-typescript' 21} from 'sequelize-typescript'
20import { FollowState } from '../../../shared/models/actors' 22import { isActivityPubUrlValid } from '@server/helpers/custom-validators/activitypub/misc'
21import { ActorFollow } from '../../../shared/models/actors/follow.model' 23import { getServerActor } from '@server/models/application/application'
22import { logger } from '../../helpers/logger' 24import { VideoModel } from '@server/models/video/video'
23import { ACTOR_FOLLOW_SCORE, FOLLOW_STATES, SERVER_ACTOR_NAME } from '../../initializers/constants'
24import { ServerModel } from '../server/server'
25import { createSafeIn, getFollowsSort, getSort, searchAttribute } from '../utils'
26import { ActorModel, unusedActorAttributesForAPI } from './actor'
27import { VideoChannelModel } from '../video/video-channel'
28import { AccountModel } from '../account/account'
29import { IncludeOptions, Op, QueryTypes, Transaction, WhereOptions } from 'sequelize'
30import { 25import {
31 MActorFollowActorsDefault, 26 MActorFollowActorsDefault,
32 MActorFollowActorsDefaultSubscription, 27 MActorFollowActorsDefaultSubscription,
@@ -35,8 +30,15 @@ import {
35 MActorFollowSubscriptions 30 MActorFollowSubscriptions
36} from '@server/types/models' 31} from '@server/types/models'
37import { ActivityPubActorType } from '@shared/models' 32import { ActivityPubActorType } from '@shared/models'
38import { VideoModel } from '@server/models/video/video' 33import { FollowState } from '../../../shared/models/actors'
39import { getServerActor } from '@server/models/application/application' 34import { ActorFollow } from '../../../shared/models/actors/follow.model'
35import { logger } from '../../helpers/logger'
36import { ACTOR_FOLLOW_SCORE, CONSTRAINTS_FIELDS, FOLLOW_STATES, SERVER_ACTOR_NAME } from '../../initializers/constants'
37import { AccountModel } from '../account/account'
38import { ServerModel } from '../server/server'
39import { createSafeIn, getFollowsSort, getSort, searchAttribute, throwIfNotValid } from '../utils'
40import { VideoChannelModel } from '../video/video-channel'
41import { ActorModel, unusedActorAttributesForAPI } from './actor'
40 42
41@Table({ 43@Table({
42 tableName: 'actorFollow', 44 tableName: 'actorFollow',
@@ -53,6 +55,10 @@ import { getServerActor } from '@server/models/application/application'
53 }, 55 },
54 { 56 {
55 fields: [ 'score' ] 57 fields: [ 'score' ]
58 },
59 {
60 fields: [ 'url' ],
61 unique: true
56 } 62 }
57 ] 63 ]
58}) 64})
@@ -69,6 +75,12 @@ export class ActorFollowModel extends Model<ActorFollowModel> {
69 @Column 75 @Column
70 score: number 76 score: number
71 77
78 // Allow null because we added this column in PeerTube v3, and don't want to generate fake URLs of remote follows
79 @AllowNull(true)
80 @Is('ActorFollowUrl', value => throwIfNotValid(value, isActivityPubUrlValid, 'url'))
81 @Column(DataType.STRING(CONSTRAINTS_FIELDS.COMMONS.URL.max))
82 url: string
83
72 @CreatedAt 84 @CreatedAt
73 createdAt: Date 85 createdAt: Date
74 86
diff --git a/server/models/video/video-format-utils.ts b/server/models/video/video-format-utils.ts
index d4b213686..b1adbcb86 100644
--- a/server/models/video/video-format-utils.ts
+++ b/server/models/video/video-format-utils.ts
@@ -4,10 +4,10 @@ import { ActivityTagObject, ActivityUrlObject, VideoObject } from '../../../shar
4import { MIMETYPES, WEBSERVER } from '../../initializers/constants' 4import { MIMETYPES, WEBSERVER } from '../../initializers/constants'
5import { VideoCaptionModel } from './video-caption' 5import { VideoCaptionModel } from './video-caption'
6import { 6import {
7 getVideoCommentsActivityPubUrl, 7 getLocalVideoCommentsActivityPubUrl,
8 getVideoDislikesActivityPubUrl, 8 getLocalVideoDislikesActivityPubUrl,
9 getVideoLikesActivityPubUrl, 9 getLocalVideoLikesActivityPubUrl,
10 getVideoSharesActivityPubUrl 10 getLocalVideoSharesActivityPubUrl
11} from '../../lib/activitypub/url' 11} from '../../lib/activitypub/url'
12import { isArray } from '../../helpers/custom-validators/misc' 12import { isArray } from '../../helpers/custom-validators/misc'
13import { VideoStreamingPlaylist } from '../../../shared/models/videos/video-streaming-playlist.model' 13import { VideoStreamingPlaylist } from '../../../shared/models/videos/video-streaming-playlist.model'
@@ -382,10 +382,10 @@ function videoModelToActivityPubObject (video: MVideoAP): VideoObject {
382 height: i.height 382 height: i.height
383 })), 383 })),
384 url, 384 url,
385 likes: getVideoLikesActivityPubUrl(video), 385 likes: getLocalVideoLikesActivityPubUrl(video),
386 dislikes: getVideoDislikesActivityPubUrl(video), 386 dislikes: getLocalVideoDislikesActivityPubUrl(video),
387 shares: getVideoSharesActivityPubUrl(video), 387 shares: getLocalVideoSharesActivityPubUrl(video),
388 comments: getVideoCommentsActivityPubUrl(video), 388 comments: getLocalVideoCommentsActivityPubUrl(video),
389 attributedTo: [ 389 attributedTo: [
390 { 390 {
391 type: 'Person', 391 type: 'Person',