aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/controllers/api/users/index.ts3
-rw-r--r--server/controllers/api/video-channel.ts11
-rw-r--r--server/helpers/custom-validators/accounts.ts11
-rw-r--r--server/helpers/custom-validators/video-channels.ts9
-rw-r--r--server/initializers/constants.ts2
-rw-r--r--server/initializers/migrations/0385-remove-actor-uuid.ts19
-rw-r--r--server/lib/activitypub/actor.ts26
-rw-r--r--server/lib/activitypub/process/process-delete.ts8
-rw-r--r--server/lib/activitypub/process/process-update.ts4
-rw-r--r--server/middlewares/validators/feeds.ts13
-rw-r--r--server/models/account/account.ts19
-rw-r--r--server/models/activitypub/actor.ts14
-rw-r--r--server/models/video/video-channel.ts21
-rw-r--r--server/tests/api/users/users-multiple-servers.ts40
-rw-r--r--server/tests/api/videos/video-channels.ts4
-rw-r--r--server/tests/feeds/feeds.ts76
16 files changed, 105 insertions, 175 deletions
diff --git a/server/controllers/api/users/index.ts b/server/controllers/api/users/index.ts
index a04f77841..2e03587ce 100644
--- a/server/controllers/api/users/index.ts
+++ b/server/controllers/api/users/index.ts
@@ -190,8 +190,7 @@ async function createUser (req: express.Request, res: express.Response) {
190 user: { 190 user: {
191 id: user.id, 191 id: user.id,
192 account: { 192 account: {
193 id: account.id, 193 id: account.id
194 uuid: account.Actor.uuid
195 } 194 }
196 } 195 }
197 }).end() 196 }).end()
diff --git a/server/controllers/api/video-channel.ts b/server/controllers/api/video-channel.ts
index 3d6dbfe70..c98a39be2 100644
--- a/server/controllers/api/video-channel.ts
+++ b/server/controllers/api/video-channel.ts
@@ -143,15 +143,14 @@ async function addVideoChannel (req: express.Request, res: express.Response) {
143 }) 143 })
144 144
145 setAsyncActorKeys(videoChannelCreated.Actor) 145 setAsyncActorKeys(videoChannelCreated.Actor)
146 .catch(err => logger.error('Cannot set async actor keys for account %s.', videoChannelCreated.Actor.uuid, { err })) 146 .catch(err => logger.error('Cannot set async actor keys for account %s.', videoChannelCreated.Actor.url, { err }))
147 147
148 auditLogger.create(getAuditIdFromRes(res), new VideoChannelAuditView(videoChannelCreated.toFormattedJSON())) 148 auditLogger.create(getAuditIdFromRes(res), new VideoChannelAuditView(videoChannelCreated.toFormattedJSON()))
149 logger.info('Video channel with uuid %s created.', videoChannelCreated.Actor.uuid) 149 logger.info('Video channel %s created.', videoChannelCreated.Actor.url)
150 150
151 return res.json({ 151 return res.json({
152 videoChannel: { 152 videoChannel: {
153 id: videoChannelCreated.id, 153 id: videoChannelCreated.id
154 uuid: videoChannelCreated.Actor.uuid
155 } 154 }
156 }).end() 155 }).end()
157} 156}
@@ -180,7 +179,7 @@ async function updateVideoChannel (req: express.Request, res: express.Response)
180 new VideoChannelAuditView(videoChannelInstanceUpdated.toFormattedJSON()), 179 new VideoChannelAuditView(videoChannelInstanceUpdated.toFormattedJSON()),
181 oldVideoChannelAuditKeys 180 oldVideoChannelAuditKeys
182 ) 181 )
183 logger.info('Video channel with name %s and uuid %s updated.', videoChannelInstance.name, videoChannelInstance.Actor.uuid) 182 logger.info('Video channel %s updated.', videoChannelInstance.Actor.url)
184 }) 183 })
185 } catch (err) { 184 } catch (err) {
186 logger.debug('Cannot update the video channel.', { err }) 185 logger.debug('Cannot update the video channel.', { err })
@@ -205,7 +204,7 @@ async function removeVideoChannel (req: express.Request, res: express.Response)
205 await videoChannelInstance.destroy({ transaction: t }) 204 await videoChannelInstance.destroy({ transaction: t })
206 205
207 auditLogger.delete(getAuditIdFromRes(res), new VideoChannelAuditView(videoChannelInstance.toFormattedJSON())) 206 auditLogger.delete(getAuditIdFromRes(res), new VideoChannelAuditView(videoChannelInstance.toFormattedJSON()))
208 logger.info('Video channel with name %s and uuid %s deleted.', videoChannelInstance.name, videoChannelInstance.Actor.uuid) 207 logger.info('Video channel %s deleted.', videoChannelInstance.Actor.url)
209 }) 208 })
210 209
211 return res.type('json').status(204).end() 210 return res.type('json').status(204).end()
diff --git a/server/helpers/custom-validators/accounts.ts b/server/helpers/custom-validators/accounts.ts
index 146c7708e..31a2de5ca 100644
--- a/server/helpers/custom-validators/accounts.ts
+++ b/server/helpers/custom-validators/accounts.ts
@@ -1,7 +1,6 @@
1import * as Bluebird from 'bluebird' 1import * as Bluebird from 'bluebird'
2import { Response } from 'express' 2import { Response } from 'express'
3import 'express-validator' 3import 'express-validator'
4import * as validator from 'validator'
5import { AccountModel } from '../../models/account/account' 4import { AccountModel } from '../../models/account/account'
6import { isUserDescriptionValid, isUserUsernameValid } from './users' 5import { isUserDescriptionValid, isUserUsernameValid } from './users'
7import { exists } from './misc' 6import { exists } from './misc'
@@ -18,14 +17,8 @@ function isAccountDescriptionValid (value: string) {
18 return isUserDescriptionValid(value) 17 return isUserDescriptionValid(value)
19} 18}
20 19
21function doesAccountIdExist (id: number | string, res: Response, sendNotFound = true) { 20function doesAccountIdExist (id: number, res: Response, sendNotFound = true) {
22 let promise: Bluebird<AccountModel> 21 const promise = AccountModel.load(id)
23
24 if (validator.isInt('' + id)) {
25 promise = AccountModel.load(+id)
26 } else { // UUID
27 promise = AccountModel.loadByUUID('' + id)
28 }
29 22
30 return doesAccountExist(promise, res, sendNotFound) 23 return doesAccountExist(promise, res, sendNotFound)
31} 24}
diff --git a/server/helpers/custom-validators/video-channels.ts b/server/helpers/custom-validators/video-channels.ts
index fd56b9a70..f818ce8f1 100644
--- a/server/helpers/custom-validators/video-channels.ts
+++ b/server/helpers/custom-validators/video-channels.ts
@@ -26,13 +26,8 @@ async function doesLocalVideoChannelNameExist (name: string, res: express.Respon
26 return processVideoChannelExist(videoChannel, res) 26 return processVideoChannelExist(videoChannel, res)
27} 27}
28 28
29async function doesVideoChannelIdExist (id: number | string, res: express.Response) { 29async function doesVideoChannelIdExist (id: number, res: express.Response) {
30 let videoChannel: VideoChannelModel 30 const videoChannel = await VideoChannelModel.loadAndPopulateAccount(+id)
31 if (validator.isInt('' + id)) {
32 videoChannel = await VideoChannelModel.loadAndPopulateAccount(+id)
33 } else { // UUID
34 videoChannel = await VideoChannelModel.loadByUUIDAndPopulateAccount('' + id)
35 }
36 31
37 return processVideoChannelExist(videoChannel, res) 32 return processVideoChannelExist(videoChannel, res)
38} 33}
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts
index ec040b80e..be30be463 100644
--- a/server/initializers/constants.ts
+++ b/server/initializers/constants.ts
@@ -14,7 +14,7 @@ import { CONFIG, registerConfigChangedHandler } from './config'
14 14
15// --------------------------------------------------------------------------- 15// ---------------------------------------------------------------------------
16 16
17const LAST_MIGRATION_VERSION = 380 17const LAST_MIGRATION_VERSION = 385
18 18
19// --------------------------------------------------------------------------- 19// ---------------------------------------------------------------------------
20 20
diff --git a/server/initializers/migrations/0385-remove-actor-uuid.ts b/server/initializers/migrations/0385-remove-actor-uuid.ts
new file mode 100644
index 000000000..032c0562b
--- /dev/null
+++ b/server/initializers/migrations/0385-remove-actor-uuid.ts
@@ -0,0 +1,19 @@
1import * as Sequelize from 'sequelize'
2
3async function up (utils: {
4 transaction: Sequelize.Transaction,
5 queryInterface: Sequelize.QueryInterface,
6 sequelize: Sequelize.Sequelize,
7 db: any
8}): Promise<void> {
9 await utils.queryInterface.removeColumn('actor', 'uuid')
10}
11
12function down (options) {
13 throw new Error('Not implemented.')
14}
15
16export {
17 up,
18 down
19}
diff --git a/server/lib/activitypub/actor.ts b/server/lib/activitypub/actor.ts
index 25cd40905..e0cb986bd 100644
--- a/server/lib/activitypub/actor.ts
+++ b/server/lib/activitypub/actor.ts
@@ -33,7 +33,7 @@ function setAsyncActorKeys (actor: ActorModel) {
33 return actor.save() 33 return actor.save()
34 }) 34 })
35 .catch(err => { 35 .catch(err => {
36 logger.error('Cannot set public/private keys of actor %d.', actor.uuid, { err }) 36 logger.error('Cannot set public/private keys of actor %d.', actor.url, { err })
37 return actor 37 return actor
38 }) 38 })
39} 39}
@@ -128,18 +128,17 @@ async function updateActorInstance (actorInstance: ActorModel, attributes: Activ
128 const followersCount = await fetchActorTotalItems(attributes.followers) 128 const followersCount = await fetchActorTotalItems(attributes.followers)
129 const followingCount = await fetchActorTotalItems(attributes.following) 129 const followingCount = await fetchActorTotalItems(attributes.following)
130 130
131 actorInstance.set('type', attributes.type) 131 actorInstance.type = attributes.type
132 actorInstance.set('uuid', attributes.uuid) 132 actorInstance.preferredUsername = attributes.preferredUsername
133 actorInstance.set('preferredUsername', attributes.preferredUsername) 133 actorInstance.url = attributes.id
134 actorInstance.set('url', attributes.id) 134 actorInstance.publicKey = attributes.publicKey.publicKeyPem
135 actorInstance.set('publicKey', attributes.publicKey.publicKeyPem) 135 actorInstance.followersCount = followersCount
136 actorInstance.set('followersCount', followersCount) 136 actorInstance.followingCount = followingCount
137 actorInstance.set('followingCount', followingCount) 137 actorInstance.inboxUrl = attributes.inbox
138 actorInstance.set('inboxUrl', attributes.inbox) 138 actorInstance.outboxUrl = attributes.outbox
139 actorInstance.set('outboxUrl', attributes.outbox) 139 actorInstance.sharedInboxUrl = attributes.endpoints.sharedInbox
140 actorInstance.set('sharedInboxUrl', attributes.endpoints.sharedInbox) 140 actorInstance.followersUrl = attributes.followers
141 actorInstance.set('followersUrl', attributes.followers) 141 actorInstance.followingUrl = attributes.following
142 actorInstance.set('followingUrl', attributes.following)
143} 142}
144 143
145async function updateActorAvatarInstance (actorInstance: ActorModel, avatarName: string, t: Transaction) { 144async function updateActorAvatarInstance (actorInstance: ActorModel, avatarName: string, t: Transaction) {
@@ -388,7 +387,6 @@ async function fetchRemoteActor (actorUrl: string): Promise<{ statusCode?: numbe
388 387
389 const actor = new ActorModel({ 388 const actor = new ActorModel({
390 type: actorJSON.type, 389 type: actorJSON.type,
391 uuid: actorJSON.uuid,
392 preferredUsername: actorJSON.preferredUsername, 390 preferredUsername: actorJSON.preferredUsername,
393 url: actorJSON.id, 391 url: actorJSON.id,
394 publicKey: actorJSON.publicKey.publicKeyPem, 392 publicKey: actorJSON.publicKey.publicKeyPem,
diff --git a/server/lib/activitypub/process/process-delete.ts b/server/lib/activitypub/process/process-delete.ts
index 76f07fd8a..6f10a50bd 100644
--- a/server/lib/activitypub/process/process-delete.ts
+++ b/server/lib/activitypub/process/process-delete.ts
@@ -95,23 +95,23 @@ async function processDeleteVideoPlaylist (actor: ActorModel, playlistToDelete:
95} 95}
96 96
97async function processDeleteAccount (accountToRemove: AccountModel) { 97async function processDeleteAccount (accountToRemove: AccountModel) {
98 logger.debug('Removing remote account "%s".', accountToRemove.Actor.uuid) 98 logger.debug('Removing remote account "%s".', accountToRemove.Actor.url)
99 99
100 await sequelizeTypescript.transaction(async t => { 100 await sequelizeTypescript.transaction(async t => {
101 await accountToRemove.destroy({ transaction: t }) 101 await accountToRemove.destroy({ transaction: t })
102 }) 102 })
103 103
104 logger.info('Remote account with uuid %s removed.', accountToRemove.Actor.uuid) 104 logger.info('Remote account %s removed.', accountToRemove.Actor.url)
105} 105}
106 106
107async function processDeleteVideoChannel (videoChannelToRemove: VideoChannelModel) { 107async function processDeleteVideoChannel (videoChannelToRemove: VideoChannelModel) {
108 logger.debug('Removing remote video channel "%s".', videoChannelToRemove.Actor.uuid) 108 logger.debug('Removing remote video channel "%s".', videoChannelToRemove.Actor.url)
109 109
110 await sequelizeTypescript.transaction(async t => { 110 await sequelizeTypescript.transaction(async t => {
111 await videoChannelToRemove.destroy({ transaction: t }) 111 await videoChannelToRemove.destroy({ transaction: t })
112 }) 112 })
113 113
114 logger.info('Remote video channel with uuid %s removed.', videoChannelToRemove.Actor.uuid) 114 logger.info('Remote video channel %s removed.', videoChannelToRemove.Actor.url)
115} 115}
116 116
117function processDeleteVideoComment (byActor: ActorModel, videoComment: VideoCommentModel, activity: ActivityDelete) { 117function processDeleteVideoComment (byActor: ActorModel, videoComment: VideoCommentModel, activity: ActivityDelete) {
diff --git a/server/lib/activitypub/process/process-update.ts b/server/lib/activitypub/process/process-update.ts
index 54a9234bb..71a16dacc 100644
--- a/server/lib/activitypub/process/process-update.ts
+++ b/server/lib/activitypub/process/process-update.ts
@@ -95,7 +95,7 @@ async function processUpdateCacheFile (byActor: ActorModel, activity: ActivityUp
95async function processUpdateActor (actor: ActorModel, activity: ActivityUpdate) { 95async function processUpdateActor (actor: ActorModel, activity: ActivityUpdate) {
96 const actorAttributesToUpdate = activity.object as ActivityPubActor 96 const actorAttributesToUpdate = activity.object as ActivityPubActor
97 97
98 logger.debug('Updating remote account "%s".', actorAttributesToUpdate.uuid) 98 logger.debug('Updating remote account "%s".', actorAttributesToUpdate.url)
99 let accountOrChannelInstance: AccountModel | VideoChannelModel 99 let accountOrChannelInstance: AccountModel | VideoChannelModel
100 let actorFieldsSave: object 100 let actorFieldsSave: object
101 let accountOrChannelFieldsSave: object 101 let accountOrChannelFieldsSave: object
@@ -128,7 +128,7 @@ async function processUpdateActor (actor: ActorModel, activity: ActivityUpdate)
128 await accountOrChannelInstance.save({ transaction: t }) 128 await accountOrChannelInstance.save({ transaction: t })
129 }) 129 })
130 130
131 logger.info('Remote account with uuid %s updated', actorAttributesToUpdate.uuid) 131 logger.info('Remote account %s updated', actorAttributesToUpdate.url)
132 } catch (err) { 132 } catch (err) {
133 if (actor !== undefined && actorFieldsSave !== undefined) { 133 if (actor !== undefined && actorFieldsSave !== undefined) {
134 resetSequelizeInstance(actor, actorFieldsSave) 134 resetSequelizeInstance(actor, actorFieldsSave)
diff --git a/server/middlewares/validators/feeds.ts b/server/middlewares/validators/feeds.ts
index e4f5c98fe..dd362619d 100644
--- a/server/middlewares/validators/feeds.ts
+++ b/server/middlewares/validators/feeds.ts
@@ -1,21 +1,20 @@
1import * as express from 'express' 1import * as express from 'express'
2import { param, query } from 'express-validator/check' 2import { param, query } from 'express-validator/check'
3import { doesAccountIdExist, isAccountNameValid, doesAccountNameWithHostExist } from '../../helpers/custom-validators/accounts' 3import { doesAccountIdExist, doesAccountNameWithHostExist } from '../../helpers/custom-validators/accounts'
4import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc' 4import { isIdOrUUIDValid, isIdValid } from '../../helpers/custom-validators/misc'
5import { logger } from '../../helpers/logger' 5import { logger } from '../../helpers/logger'
6import { areValidationErrors } from './utils' 6import { areValidationErrors } from './utils'
7import { isValidRSSFeed } from '../../helpers/custom-validators/feeds' 7import { isValidRSSFeed } from '../../helpers/custom-validators/feeds'
8import { doesVideoChannelIdExist, doesVideoChannelNameWithHostExist } from '../../helpers/custom-validators/video-channels' 8import { doesVideoChannelIdExist, doesVideoChannelNameWithHostExist } from '../../helpers/custom-validators/video-channels'
9import { doesVideoExist } from '../../helpers/custom-validators/videos' 9import { doesVideoExist } from '../../helpers/custom-validators/videos'
10import { isActorPreferredUsernameValid } from '../../helpers/custom-validators/activitypub/actor'
11 10
12const videoFeedsValidator = [ 11const videoFeedsValidator = [
13 param('format').optional().custom(isValidRSSFeed).withMessage('Should have a valid format (rss, atom, json)'), 12 param('format').optional().custom(isValidRSSFeed).withMessage('Should have a valid format (rss, atom, json)'),
14 query('format').optional().custom(isValidRSSFeed).withMessage('Should have a valid format (rss, atom, json)'), 13 query('format').optional().custom(isValidRSSFeed).withMessage('Should have a valid format (rss, atom, json)'),
15 query('accountId').optional().custom(isIdOrUUIDValid), 14 query('accountId').optional().custom(isIdValid),
16 query('accountName').optional().custom(isAccountNameValid), 15 query('accountName').optional(),
17 query('videoChannelId').optional().custom(isIdOrUUIDValid), 16 query('videoChannelId').optional().custom(isIdValid),
18 query('videoChannelName').optional().custom(isActorPreferredUsernameValid), 17 query('videoChannelName').optional(),
19 18
20 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 19 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
21 logger.debug('Checking feeds parameters', { parameters: req.query }) 20 logger.debug('Checking feeds parameters', { parameters: req.query })
diff --git a/server/models/account/account.ts b/server/models/account/account.ts
index 2b04acd86..09cada096 100644
--- a/server/models/account/account.ts
+++ b/server/models/account/account.ts
@@ -47,7 +47,7 @@ export enum ScopeNames {
47 attributes: [ 'id', 'name' ], 47 attributes: [ 'id', 'name' ],
48 include: [ 48 include: [
49 { 49 {
50 attributes: [ 'id', 'uuid', 'preferredUsername', 'url', 'serverId', 'avatarId' ], 50 attributes: [ 'id', 'preferredUsername', 'url', 'serverId', 'avatarId' ],
51 model: ActorModel.unscoped(), 51 model: ActorModel.unscoped(),
52 required: true, 52 required: true,
53 where: whereActor, 53 where: whereActor,
@@ -180,22 +180,6 @@ export class AccountModel extends Model<AccountModel> {
180 return AccountModel.findByPk(id, { transaction }) 180 return AccountModel.findByPk(id, { transaction })
181 } 181 }
182 182
183 static loadByUUID (uuid: string) {
184 const query = {
185 include: [
186 {
187 model: ActorModel,
188 required: true,
189 where: {
190 uuid
191 }
192 }
193 ]
194 }
195
196 return AccountModel.findOne(query)
197 }
198
199 static loadByNameWithHost (nameWithHost: string) { 183 static loadByNameWithHost (nameWithHost: string) {
200 const [ accountName, host ] = nameWithHost.split('@') 184 const [ accountName, host ] = nameWithHost.split('@')
201 185
@@ -332,7 +316,6 @@ export class AccountModel extends Model<AccountModel> {
332 316
333 return { 317 return {
334 id: this.id, 318 id: this.id,
335 uuid: actor.uuid,
336 name: actor.name, 319 name: actor.name,
337 displayName: this.getDisplayName(), 320 displayName: this.getDisplayName(),
338 url: actor.url, 321 url: actor.url,
diff --git a/server/models/activitypub/actor.ts b/server/models/activitypub/actor.ts
index 4a466441c..bd6a2c8fd 100644
--- a/server/models/activitypub/actor.ts
+++ b/server/models/activitypub/actor.ts
@@ -7,13 +7,11 @@ import {
7 Column, 7 Column,
8 CreatedAt, 8 CreatedAt,
9 DataType, 9 DataType,
10 Default,
11 DefaultScope, 10 DefaultScope,
12 ForeignKey, 11 ForeignKey,
13 HasMany, 12 HasMany,
14 HasOne, 13 HasOne,
15 Is, 14 Is,
16 IsUUID,
17 Model, 15 Model,
18 Scopes, 16 Scopes,
19 Table, 17 Table,
@@ -120,10 +118,6 @@ export const unusedActorAttributesForAPI = [
120 fields: [ 'avatarId' ] 118 fields: [ 'avatarId' ]
121 }, 119 },
122 { 120 {
123 fields: [ 'uuid' ],
124 unique: true
125 },
126 {
127 fields: [ 'followersUrl' ] 121 fields: [ 'followersUrl' ]
128 } 122 }
129 ] 123 ]
@@ -135,12 +129,6 @@ export class ActorModel extends Model<ActorModel> {
135 type: ActivityPubActorType 129 type: ActivityPubActorType
136 130
137 @AllowNull(false) 131 @AllowNull(false)
138 @Default(DataType.UUIDV4)
139 @IsUUID(4)
140 @Column(DataType.UUID)
141 uuid: string
142
143 @AllowNull(false)
144 @Is('ActorPreferredUsername', value => throwIfNotValid(value, isActorPreferredUsernameValid, 'actor preferred username')) 132 @Is('ActorPreferredUsername', value => throwIfNotValid(value, isActorPreferredUsernameValid, 'actor preferred username'))
145 @Column 133 @Column
146 preferredUsername: string 134 preferredUsername: string
@@ -408,7 +396,6 @@ export class ActorModel extends Model<ActorModel> {
408 return { 396 return {
409 id: this.id, 397 id: this.id,
410 url: this.url, 398 url: this.url,
411 uuid: this.uuid,
412 name: this.preferredUsername, 399 name: this.preferredUsername,
413 host: this.getHost(), 400 host: this.getHost(),
414 hostRedundancyAllowed: this.getRedundancyAllowed(), 401 hostRedundancyAllowed: this.getRedundancyAllowed(),
@@ -454,7 +441,6 @@ export class ActorModel extends Model<ActorModel> {
454 endpoints: { 441 endpoints: {
455 sharedInbox: this.sharedInboxUrl 442 sharedInbox: this.sharedInboxUrl
456 }, 443 },
457 uuid: this.uuid,
458 publicKey: { 444 publicKey: {
459 id: this.getPublicKeyUrl(), 445 id: this.getPublicKeyUrl(),
460 owner: this.url, 446 owner: this.url,
diff --git a/server/models/video/video-channel.ts b/server/models/video/video-channel.ts
index d73be18d6..b0b261c88 100644
--- a/server/models/video/video-channel.ts
+++ b/server/models/video/video-channel.ts
@@ -72,7 +72,7 @@ type AvailableForListOptions = {
72 attributes: [ 'name', 'description', 'id', 'actorId' ], 72 attributes: [ 'name', 'description', 'id', 'actorId' ],
73 include: [ 73 include: [
74 { 74 {
75 attributes: [ 'uuid', 'preferredUsername', 'url', 'serverId', 'avatarId' ], 75 attributes: [ 'preferredUsername', 'url', 'serverId', 'avatarId' ],
76 model: ActorModel.unscoped(), 76 model: ActorModel.unscoped(),
77 required: true, 77 required: true,
78 include: [ 78 include: [
@@ -387,24 +387,6 @@ export class VideoChannelModel extends Model<VideoChannelModel> {
387 .findByPk(id) 387 .findByPk(id)
388 } 388 }
389 389
390 static loadByUUIDAndPopulateAccount (uuid: string) {
391 const query = {
392 include: [
393 {
394 model: ActorModel,
395 required: true,
396 where: {
397 uuid
398 }
399 }
400 ]
401 }
402
403 return VideoChannelModel
404 .scope([ ScopeNames.WITH_ACCOUNT ])
405 .findOne(query)
406 }
407
408 static loadByUrlAndPopulateAccount (url: string) { 390 static loadByUrlAndPopulateAccount (url: string) {
409 const query = { 391 const query = {
410 include: [ 392 include: [
@@ -510,7 +492,6 @@ export class VideoChannelModel extends Model<VideoChannelModel> {
510 492
511 return { 493 return {
512 id: this.id, 494 id: this.id,
513 uuid: actor.uuid,
514 name: actor.name, 495 name: actor.name,
515 displayName: this.getDisplayName(), 496 displayName: this.getDisplayName(),
516 url: actor.url, 497 url: actor.url,
diff --git a/server/tests/api/users/users-multiple-servers.ts b/server/tests/api/users/users-multiple-servers.ts
index 988fdad3f..791418318 100644
--- a/server/tests/api/users/users-multiple-servers.ts
+++ b/server/tests/api/users/users-multiple-servers.ts
@@ -5,7 +5,8 @@ import 'mocha'
5import { Account } from '../../../../shared/models/actors' 5import { Account } from '../../../../shared/models/actors'
6import { 6import {
7 checkTmpIsEmpty, 7 checkTmpIsEmpty,
8 checkVideoFilesWereRemoved, cleanupTests, 8 checkVideoFilesWereRemoved,
9 cleanupTests,
9 createUser, 10 createUser,
10 doubleFollow, 11 doubleFollow,
11 flushAndRunMultipleServers, 12 flushAndRunMultipleServers,
@@ -15,14 +16,7 @@ import {
15 updateMyUser, 16 updateMyUser,
16 userLogin 17 userLogin
17} from '../../../../shared/extra-utils' 18} from '../../../../shared/extra-utils'
18import { 19import { getMyUserInformation, ServerInfo, testImage, updateMyAvatar, uploadVideo } from '../../../../shared/extra-utils/index'
19 getMyUserInformation,
20 killallServers,
21 ServerInfo,
22 testImage,
23 updateMyAvatar,
24 uploadVideo
25} from '../../../../shared/extra-utils/index'
26import { checkActorFilesWereRemoved, getAccount, getAccountsList } from '../../../../shared/extra-utils/users/accounts' 20import { checkActorFilesWereRemoved, getAccount, getAccountsList } from '../../../../shared/extra-utils/users/accounts'
27import { setAccessTokensToServers } from '../../../../shared/extra-utils/users/login' 21import { setAccessTokensToServers } from '../../../../shared/extra-utils/users/login'
28import { User } from '../../../../shared/models/users' 22import { User } from '../../../../shared/models/users'
@@ -34,12 +28,10 @@ const expect = chai.expect
34describe('Test users with multiple servers', function () { 28describe('Test users with multiple servers', function () {
35 let servers: ServerInfo[] = [] 29 let servers: ServerInfo[] = []
36 let user: User 30 let user: User
37 let userAccountName: string
38 let userAccountUUID: string
39 let userVideoChannelUUID: string
40 let userId: number 31 let userId: number
41 let videoUUID: string 32 let videoUUID: string
42 let userAccessToken: string 33 let userAccessToken: string
34 let userAvatarFilename: string
43 35
44 before(async function () { 36 before(async function () {
45 this.timeout(120000) 37 this.timeout(120000)
@@ -75,19 +67,6 @@ describe('Test users with multiple servers', function () {
75 } 67 }
76 68
77 { 69 {
78 const res = await getMyUserInformation(servers[0].url, userAccessToken)
79 const account: Account = res.body.account
80 userAccountName = account.name + '@' + account.host
81 userAccountUUID = account.uuid
82 }
83
84 {
85 const res = await getMyUserInformation(servers[ 0 ].url, servers[ 0 ].accessToken)
86 const user: User = res.body
87 userVideoChannelUUID = user.videoChannels[0].uuid
88 }
89
90 {
91 const resVideo = await uploadVideo(servers[ 0 ].url, userAccessToken, {}) 70 const resVideo = await uploadVideo(servers[ 0 ].url, userAccessToken, {})
92 videoUUID = resVideo.body.video.uuid 71 videoUUID = resVideo.body.video.uuid
93 } 72 }
@@ -106,6 +85,8 @@ describe('Test users with multiple servers', function () {
106 85
107 const res = await getMyUserInformation(servers[0].url, servers[0].accessToken) 86 const res = await getMyUserInformation(servers[0].url, servers[0].accessToken)
108 user = res.body 87 user = res.body
88
89 const account: Account = user.account
109 expect(user.account.displayName).to.equal('my super display name') 90 expect(user.account.displayName).to.equal('my super display name')
110 91
111 await waitJobs(servers) 92 await waitJobs(servers)
@@ -142,7 +123,9 @@ describe('Test users with multiple servers', function () {
142 const res = await getMyUserInformation(servers[0].url, servers[0].accessToken) 123 const res = await getMyUserInformation(servers[0].url, servers[0].accessToken)
143 user = res.body 124 user = res.body
144 125
145 await testImage(servers[0].url, 'avatar2-resized', user.account.avatar.path, '.png') 126 userAvatarFilename = user.account.avatar.path
127
128 await testImage(servers[0].url, 'avatar2-resized', userAvatarFilename, '.png')
146 129
147 await waitJobs(servers) 130 await waitJobs(servers)
148 }) 131 })
@@ -173,7 +156,7 @@ describe('Test users with multiple servers', function () {
173 156
174 it('Should list account videos', async function () { 157 it('Should list account videos', async function () {
175 for (const server of servers) { 158 for (const server of servers) {
176 const res = await getAccountVideos(server.url, server.accessToken, userAccountName, 0, 5) 159 const res = await getAccountVideos(server.url, server.accessToken, 'user1@localhost:' + servers[0].port, 0, 5)
177 160
178 expect(res.body.total).to.equal(1) 161 expect(res.body.total).to.equal(1)
179 expect(res.body.data).to.be.an('array') 162 expect(res.body.data).to.be.an('array')
@@ -218,8 +201,7 @@ describe('Test users with multiple servers', function () {
218 201
219 it('Should not have actor files', async () => { 202 it('Should not have actor files', async () => {
220 for (const server of servers) { 203 for (const server of servers) {
221 await checkActorFilesWereRemoved(userAccountUUID, server.internalServerNumber) 204 await checkActorFilesWereRemoved(userAvatarFilename, server.internalServerNumber)
222 await checkActorFilesWereRemoved(userVideoChannelUUID, server.internalServerNumber)
223 } 205 }
224 }) 206 })
225 207
diff --git a/server/tests/api/videos/video-channels.ts b/server/tests/api/videos/video-channels.ts
index e98f14ea8..2d298dd3f 100644
--- a/server/tests/api/videos/video-channels.ts
+++ b/server/tests/api/videos/video-channels.ts
@@ -18,12 +18,10 @@ import {
18import { 18import {
19 addVideoChannel, 19 addVideoChannel,
20 deleteVideoChannel, 20 deleteVideoChannel,
21 flushTests,
22 getAccountVideoChannelsList, 21 getAccountVideoChannelsList,
23 getMyUserInformation, 22 getMyUserInformation,
24 getVideoChannel, 23 getVideoChannel,
25 getVideoChannelsList, 24 getVideoChannelsList,
26 killallServers,
27 ServerInfo, 25 ServerInfo,
28 setAccessTokensToServers, 26 setAccessTokensToServers,
29 updateVideoChannel 27 updateVideoChannel
@@ -35,7 +33,6 @@ const expect = chai.expect
35describe('Test video channels', function () { 33describe('Test video channels', function () {
36 let servers: ServerInfo[] 34 let servers: ServerInfo[]
37 let userInfo: User 35 let userInfo: User
38 let accountUUID: string
39 let firstVideoChannelId: number 36 let firstVideoChannelId: number
40 let secondVideoChannelId: number 37 let secondVideoChannelId: number
41 let videoUUID: string 38 let videoUUID: string
@@ -51,7 +48,6 @@ describe('Test video channels', function () {
51 { 48 {
52 const res = await getMyUserInformation(servers[0].url, servers[0].accessToken) 49 const res = await getMyUserInformation(servers[0].url, servers[0].accessToken)
53 const user: User = res.body 50 const user: User = res.body
54 accountUUID = user.account.uuid
55 51
56 firstVideoChannelId = user.videoChannels[0].id 52 firstVideoChannelId = user.videoChannels[0].id
57 } 53 }
diff --git a/server/tests/feeds/feeds.ts b/server/tests/feeds/feeds.ts
index 0dcdf09cf..437470327 100644
--- a/server/tests/feeds/feeds.ts
+++ b/server/tests/feeds/feeds.ts
@@ -7,13 +7,13 @@ import {
7 createUser, 7 createUser,
8 doubleFollow, 8 doubleFollow,
9 flushAndRunMultipleServers, 9 flushAndRunMultipleServers,
10 flushTests, 10 getJSONfeed,
11 getJSONfeed, getMyUserInformation, 11 getMyUserInformation,
12 getXMLfeed, 12 getXMLfeed,
13 killallServers,
14 ServerInfo, 13 ServerInfo,
15 setAccessTokensToServers, 14 setAccessTokensToServers,
16 uploadVideo, userLogin 15 uploadVideo,
16 userLogin
17} from '../../../shared/extra-utils' 17} from '../../../shared/extra-utils'
18import * as libxmljs from 'libxmljs' 18import * as libxmljs from 'libxmljs'
19import { addVideoCommentThread } from '../../../shared/extra-utils/videos/video-comments' 19import { addVideoCommentThread } from '../../../shared/extra-utils/videos/video-comments'
@@ -28,10 +28,10 @@ const expect = chai.expect
28describe('Test syndication feeds', () => { 28describe('Test syndication feeds', () => {
29 let servers: ServerInfo[] = [] 29 let servers: ServerInfo[] = []
30 let userAccessToken: string 30 let userAccessToken: string
31 let rootAccountUUID: string 31 let rootAccountId: number
32 let rootChannelUUID: string 32 let rootChannelId: number
33 let userAccountUUID: string 33 let userAccountId: number
34 let userChannelUUID: string 34 let userChannelId: number
35 35
36 before(async function () { 36 before(async function () {
37 this.timeout(120000) 37 this.timeout(120000)
@@ -45,8 +45,8 @@ describe('Test syndication feeds', () => {
45 { 45 {
46 const res = await getMyUserInformation(servers[0].url, servers[0].accessToken) 46 const res = await getMyUserInformation(servers[0].url, servers[0].accessToken)
47 const user: User = res.body 47 const user: User = res.body
48 rootAccountUUID = user.account.uuid 48 rootAccountId = user.account.id
49 rootChannelUUID = user.videoChannels[0].uuid 49 rootChannelId = user.videoChannels[0].id
50 } 50 }
51 51
52 { 52 {
@@ -56,8 +56,8 @@ describe('Test syndication feeds', () => {
56 56
57 const res = await getMyUserInformation(servers[0].url, userAccessToken) 57 const res = await getMyUserInformation(servers[0].url, userAccessToken)
58 const user: User = res.body 58 const user: User = res.body
59 userAccountUUID = user.account.uuid 59 userAccountId = user.account.id
60 userChannelUUID = user.videoChannels[0].uuid 60 userChannelId = user.videoChannels[0].id
61 } 61 }
62 62
63 { 63 {
@@ -127,71 +127,71 @@ describe('Test syndication feeds', () => {
127 }) 127 })
128 128
129 it('Should filter by account', async function () { 129 it('Should filter by account', async function () {
130 {
131 const json = await getJSONfeed(servers[0].url, 'videos', { accountId: rootAccountId })
132 const jsonObj = JSON.parse(json.text)
133 expect(jsonObj.items.length).to.be.equal(1)
134 expect(jsonObj.items[ 0 ].title).to.equal('my super name for server 1')
135 expect(jsonObj.items[ 0 ].author.name).to.equal('root')
136 }
137
138 {
139 const json = await getJSONfeed(servers[0].url, 'videos', { accountId: userAccountId })
140 const jsonObj = JSON.parse(json.text)
141 expect(jsonObj.items.length).to.be.equal(1)
142 expect(jsonObj.items[ 0 ].title).to.equal('user video')
143 expect(jsonObj.items[ 0 ].author.name).to.equal('john')
144 }
145
130 for (const server of servers) { 146 for (const server of servers) {
131 { 147 {
132 const json = await getJSONfeed(server.url, 'videos', { accountId: rootAccountUUID }) 148 const json = await getJSONfeed(server.url, 'videos', { accountName: 'root@localhost:' + servers[0].port })
133 const jsonObj = JSON.parse(json.text) 149 const jsonObj = JSON.parse(json.text)
134 expect(jsonObj.items.length).to.be.equal(1) 150 expect(jsonObj.items.length).to.be.equal(1)
135 expect(jsonObj.items[ 0 ].title).to.equal('my super name for server 1') 151 expect(jsonObj.items[ 0 ].title).to.equal('my super name for server 1')
136 expect(jsonObj.items[ 0 ].author.name).to.equal('root')
137 } 152 }
138 153
139 { 154 {
140 const json = await getJSONfeed(server.url, 'videos', { accountId: userAccountUUID }) 155 const json = await getJSONfeed(server.url, 'videos', { accountName: 'john@localhost:' + servers[0].port })
141 const jsonObj = JSON.parse(json.text) 156 const jsonObj = JSON.parse(json.text)
142 expect(jsonObj.items.length).to.be.equal(1) 157 expect(jsonObj.items.length).to.be.equal(1)
143 expect(jsonObj.items[ 0 ].title).to.equal('user video') 158 expect(jsonObj.items[ 0 ].title).to.equal('user video')
144 expect(jsonObj.items[ 0 ].author.name).to.equal('john')
145 } 159 }
146 } 160 }
161 })
147 162
163 it('Should filter by video channel', async function () {
148 { 164 {
149 const json = await getJSONfeed(servers[0].url, 'videos', { accountName: 'root' }) 165 const json = await getJSONfeed(servers[0].url, 'videos', { videoChannelId: rootChannelId })
150 const jsonObj = JSON.parse(json.text) 166 const jsonObj = JSON.parse(json.text)
151 expect(jsonObj.items.length).to.be.equal(1) 167 expect(jsonObj.items.length).to.be.equal(1)
152 expect(jsonObj.items[ 0 ].title).to.equal('my super name for server 1') 168 expect(jsonObj.items[ 0 ].title).to.equal('my super name for server 1')
169 expect(jsonObj.items[ 0 ].author.name).to.equal('root')
153 } 170 }
154 171
155 { 172 {
156 const json = await getJSONfeed(servers[0].url, 'videos', { accountName: 'john' }) 173 const json = await getJSONfeed(servers[0].url, 'videos', { videoChannelId: userChannelId })
157 const jsonObj = JSON.parse(json.text) 174 const jsonObj = JSON.parse(json.text)
158 expect(jsonObj.items.length).to.be.equal(1) 175 expect(jsonObj.items.length).to.be.equal(1)
159 expect(jsonObj.items[ 0 ].title).to.equal('user video') 176 expect(jsonObj.items[ 0 ].title).to.equal('user video')
177 expect(jsonObj.items[ 0 ].author.name).to.equal('john')
160 } 178 }
161 })
162 179
163 it('Should filter by video channel', async function () {
164 for (const server of servers) { 180 for (const server of servers) {
165 { 181 {
166 const json = await getJSONfeed(server.url, 'videos', { videoChannelId: rootChannelUUID }) 182 const json = await getJSONfeed(server.url, 'videos', { videoChannelName: 'root_channel@localhost:' + servers[0].port })
167 const jsonObj = JSON.parse(json.text) 183 const jsonObj = JSON.parse(json.text)
168 expect(jsonObj.items.length).to.be.equal(1) 184 expect(jsonObj.items.length).to.be.equal(1)
169 expect(jsonObj.items[ 0 ].title).to.equal('my super name for server 1') 185 expect(jsonObj.items[ 0 ].title).to.equal('my super name for server 1')
170 expect(jsonObj.items[ 0 ].author.name).to.equal('root')
171 } 186 }
172 187
173 { 188 {
174 const json = await getJSONfeed(server.url, 'videos', { videoChannelId: userChannelUUID }) 189 const json = await getJSONfeed(server.url, 'videos', { videoChannelName: 'john_channel@localhost:' + servers[0].port })
175 const jsonObj = JSON.parse(json.text) 190 const jsonObj = JSON.parse(json.text)
176 expect(jsonObj.items.length).to.be.equal(1) 191 expect(jsonObj.items.length).to.be.equal(1)
177 expect(jsonObj.items[ 0 ].title).to.equal('user video') 192 expect(jsonObj.items[ 0 ].title).to.equal('user video')
178 expect(jsonObj.items[ 0 ].author.name).to.equal('john')
179 } 193 }
180 } 194 }
181
182 {
183 const json = await getJSONfeed(servers[0].url, 'videos', { videoChannelName: 'root_channel' })
184 const jsonObj = JSON.parse(json.text)
185 expect(jsonObj.items.length).to.be.equal(1)
186 expect(jsonObj.items[ 0 ].title).to.equal('my super name for server 1')
187 }
188
189 {
190 const json = await getJSONfeed(servers[0].url, 'videos', { videoChannelName: 'john_channel' })
191 const jsonObj = JSON.parse(json.text)
192 expect(jsonObj.items.length).to.be.equal(1)
193 expect(jsonObj.items[ 0 ].title).to.equal('user video')
194 }
195 }) 195 })
196 }) 196 })
197 197