aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/activitypub
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-11-20 11:21:08 +0100
committerChocobozzz <me@florianbigard.com>2020-11-20 11:21:08 +0100
commitde94ac86a211dec657332d964693857ec235ce40 (patch)
tree3bff96a40e7c862d83561a26249992b07331b0a2 /server/models/activitypub
parent3fba4b6bce69247b1d37f923894d8f44818a891c (diff)
downloadPeerTube-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.ts36
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 @@
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