diff options
Diffstat (limited to 'server/models')
-rw-r--r-- | server/models/account/account-video-rate.ts | 3 | ||||
-rw-r--r-- | server/models/activitypub/actor-follow.ts | 36 | ||||
-rw-r--r-- | server/models/video/video-format-utils.ts | 16 |
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 @@ | |||
1 | import * as Bluebird from 'bluebird' | 1 | import * as Bluebird from 'bluebird' |
2 | import { difference, values } from 'lodash' | 2 | import { difference, values } from 'lodash' |
3 | import { IncludeOptions, Op, QueryTypes, Transaction, WhereOptions } from 'sequelize' | ||
3 | import { | 4 | import { |
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' |
20 | import { FollowState } from '../../../shared/models/actors' | 22 | import { isActivityPubUrlValid } from '@server/helpers/custom-validators/activitypub/misc' |
21 | import { ActorFollow } from '../../../shared/models/actors/follow.model' | 23 | import { getServerActor } from '@server/models/application/application' |
22 | import { logger } from '../../helpers/logger' | 24 | import { VideoModel } from '@server/models/video/video' |
23 | import { ACTOR_FOLLOW_SCORE, FOLLOW_STATES, SERVER_ACTOR_NAME } from '../../initializers/constants' | ||
24 | import { ServerModel } from '../server/server' | ||
25 | import { createSafeIn, getFollowsSort, getSort, searchAttribute } from '../utils' | ||
26 | import { ActorModel, unusedActorAttributesForAPI } from './actor' | ||
27 | import { VideoChannelModel } from '../video/video-channel' | ||
28 | import { AccountModel } from '../account/account' | ||
29 | import { IncludeOptions, Op, QueryTypes, Transaction, WhereOptions } from 'sequelize' | ||
30 | import { | 25 | import { |
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' |
37 | import { ActivityPubActorType } from '@shared/models' | 32 | import { ActivityPubActorType } from '@shared/models' |
38 | import { VideoModel } from '@server/models/video/video' | 33 | import { FollowState } from '../../../shared/models/actors' |
39 | import { getServerActor } from '@server/models/application/application' | 34 | import { ActorFollow } from '../../../shared/models/actors/follow.model' |
35 | import { logger } from '../../helpers/logger' | ||
36 | import { ACTOR_FOLLOW_SCORE, CONSTRAINTS_FIELDS, FOLLOW_STATES, SERVER_ACTOR_NAME } from '../../initializers/constants' | ||
37 | import { AccountModel } from '../account/account' | ||
38 | import { ServerModel } from '../server/server' | ||
39 | import { createSafeIn, getFollowsSort, getSort, searchAttribute, throwIfNotValid } from '../utils' | ||
40 | import { VideoChannelModel } from '../video/video-channel' | ||
41 | import { 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 | |||
4 | import { MIMETYPES, WEBSERVER } from '../../initializers/constants' | 4 | import { MIMETYPES, WEBSERVER } from '../../initializers/constants' |
5 | import { VideoCaptionModel } from './video-caption' | 5 | import { VideoCaptionModel } from './video-caption' |
6 | import { | 6 | import { |
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' |
12 | import { isArray } from '../../helpers/custom-validators/misc' | 12 | import { isArray } from '../../helpers/custom-validators/misc' |
13 | import { VideoStreamingPlaylist } from '../../../shared/models/videos/video-streaming-playlist.model' | 13 | import { 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', |