diff options
author | Chocobozzz <me@florianbigard.com> | 2020-11-20 11:21:08 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-11-20 11:21:08 +0100 |
commit | de94ac86a211dec657332d964693857ec235ce40 (patch) | |
tree | 3bff96a40e7c862d83561a26249992b07331b0a2 /server/models/activitypub | |
parent | 3fba4b6bce69247b1d37f923894d8f44818a891c (diff) | |
download | PeerTube-de94ac86a211dec657332d964693857ec235ce40.tar.gz PeerTube-de94ac86a211dec657332d964693857ec235ce40.tar.zst PeerTube-de94ac86a211dec657332d964693857ec235ce40.zip |
Fix incorrect IDs in AP federation
Diffstat (limited to 'server/models/activitypub')
-rw-r--r-- | server/models/activitypub/actor-follow.ts | 36 |
1 files changed, 24 insertions, 12 deletions
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 | ||