From 57cfff78858b2360d9e038e2a504b761cb51da47 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 31 May 2019 14:02:26 +0200 Subject: Remove unused actor uuid field --- .../account-video-channels.component.html | 2 + client/src/app/shared/actor/actor.model.ts | 2 - scripts/clean/server/test.sh | 7 +- scripts/test.sh | 2 + server/controllers/api/users/index.ts | 3 +- server/controllers/api/video-channel.ts | 11 ++-- server/helpers/custom-validators/accounts.ts | 11 +--- server/helpers/custom-validators/video-channels.ts | 9 +-- server/initializers/constants.ts | 2 +- .../migrations/0385-remove-actor-uuid.ts | 19 ++++++ server/lib/activitypub/actor.ts | 26 ++++---- server/lib/activitypub/process/process-delete.ts | 8 +-- server/lib/activitypub/process/process-update.ts | 4 +- server/middlewares/validators/feeds.ts | 13 ++-- server/models/account/account.ts | 19 +----- server/models/activitypub/actor.ts | 14 ---- server/models/video/video-channel.ts | 21 +----- server/tests/api/users/users-multiple-servers.ts | 40 ++++-------- server/tests/api/videos/video-channels.ts | 4 -- server/tests/feeds/feeds.ts | 76 +++++++++++----------- shared/extra-utils/users/accounts.ts | 4 +- shared/extra-utils/videos/videos.ts | 1 - shared/models/activitypub/activitypub-actor.ts | 1 - shared/models/actors/account.model.ts | 1 - shared/models/actors/actor.model.ts | 1 - .../models/videos/channel/video-channel.model.ts | 1 - 26 files changed, 116 insertions(+), 186 deletions(-) create mode 100644 server/initializers/migrations/0385-remove-actor-uuid.ts diff --git a/client/src/app/+accounts/account-video-channels/account-video-channels.component.html b/client/src/app/+accounts/account-video-channels/account-video-channels.component.html index 25b74027e..43dbbebb3 100644 --- a/client/src/app/+accounts/account-video-channels/account-video-channels.component.html +++ b/client/src/app/+accounts/account-video-channels/account-video-channels.component.html @@ -1,5 +1,7 @@
+
This account does not have channels.
+
diff --git a/client/src/app/shared/actor/actor.model.ts b/client/src/app/shared/actor/actor.model.ts index adecec1fc..5a517c975 100644 --- a/client/src/app/shared/actor/actor.model.ts +++ b/client/src/app/shared/actor/actor.model.ts @@ -4,7 +4,6 @@ import { getAbsoluteAPIUrl } from '@app/shared/misc/utils' export abstract class Actor implements ActorServer { id: number - uuid: string url: string name: string host: string @@ -35,7 +34,6 @@ export abstract class Actor implements ActorServer { protected constructor (hash: ActorServer) { this.id = hash.id - this.uuid = hash.uuid this.url = hash.url this.name = hash.name this.host = hash.host diff --git a/scripts/clean/server/test.sh b/scripts/clean/server/test.sh index 5694ac922..34afd6a9d 100755 --- a/scripts/clean/server/test.sh +++ b/scripts/clean/server/test.sh @@ -17,8 +17,11 @@ removeFiles () { } dropRedis () { - redis-cli KEYS "bull-localhost:900$1*" | grep -v empty | xargs --no-run-if-empty redis-cli DEL - redis-cli KEYS "redis-localhost:900$1*" | grep -v empty | xargs --no-run-if-empty redis-cli DEL + port=$((9000+$1)) + + redis-cli KEYS "bull-localhost:$port*" | grep -v empty | xargs --no-run-if-empty redis-cli DEL + redis-cli KEYS "redis-localhost:$port*" | grep -v empty | xargs --no-run-if-empty redis-cli DEL + redis-cli KEYS "*redis-localhost:$port-" | grep -v empty | xargs --no-run-if-empty redis-cli DEL } seq=$(seq 1 6) diff --git a/scripts/test.sh b/scripts/test.sh index cf8895365..5ec7a5920 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -3,6 +3,8 @@ set -eu npm run build:server +npm run setup:cli + npm run travis -- lint mocha --exit --require ts-node/register/type-check --bail server/tests/index.ts 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) { user: { id: user.id, account: { - id: account.id, - uuid: account.Actor.uuid + id: account.id } } }).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) { }) setAsyncActorKeys(videoChannelCreated.Actor) - .catch(err => logger.error('Cannot set async actor keys for account %s.', videoChannelCreated.Actor.uuid, { err })) + .catch(err => logger.error('Cannot set async actor keys for account %s.', videoChannelCreated.Actor.url, { err })) auditLogger.create(getAuditIdFromRes(res), new VideoChannelAuditView(videoChannelCreated.toFormattedJSON())) - logger.info('Video channel with uuid %s created.', videoChannelCreated.Actor.uuid) + logger.info('Video channel %s created.', videoChannelCreated.Actor.url) return res.json({ videoChannel: { - id: videoChannelCreated.id, - uuid: videoChannelCreated.Actor.uuid + id: videoChannelCreated.id } }).end() } @@ -180,7 +179,7 @@ async function updateVideoChannel (req: express.Request, res: express.Response) new VideoChannelAuditView(videoChannelInstanceUpdated.toFormattedJSON()), oldVideoChannelAuditKeys ) - logger.info('Video channel with name %s and uuid %s updated.', videoChannelInstance.name, videoChannelInstance.Actor.uuid) + logger.info('Video channel %s updated.', videoChannelInstance.Actor.url) }) } catch (err) { logger.debug('Cannot update the video channel.', { err }) @@ -205,7 +204,7 @@ async function removeVideoChannel (req: express.Request, res: express.Response) await videoChannelInstance.destroy({ transaction: t }) auditLogger.delete(getAuditIdFromRes(res), new VideoChannelAuditView(videoChannelInstance.toFormattedJSON())) - logger.info('Video channel with name %s and uuid %s deleted.', videoChannelInstance.name, videoChannelInstance.Actor.uuid) + logger.info('Video channel %s deleted.', videoChannelInstance.Actor.url) }) 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 @@ import * as Bluebird from 'bluebird' import { Response } from 'express' import 'express-validator' -import * as validator from 'validator' import { AccountModel } from '../../models/account/account' import { isUserDescriptionValid, isUserUsernameValid } from './users' import { exists } from './misc' @@ -18,14 +17,8 @@ function isAccountDescriptionValid (value: string) { return isUserDescriptionValid(value) } -function doesAccountIdExist (id: number | string, res: Response, sendNotFound = true) { - let promise: Bluebird - - if (validator.isInt('' + id)) { - promise = AccountModel.load(+id) - } else { // UUID - promise = AccountModel.loadByUUID('' + id) - } +function doesAccountIdExist (id: number, res: Response, sendNotFound = true) { + const promise = AccountModel.load(id) return doesAccountExist(promise, res, sendNotFound) } 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 return processVideoChannelExist(videoChannel, res) } -async function doesVideoChannelIdExist (id: number | string, res: express.Response) { - let videoChannel: VideoChannelModel - if (validator.isInt('' + id)) { - videoChannel = await VideoChannelModel.loadAndPopulateAccount(+id) - } else { // UUID - videoChannel = await VideoChannelModel.loadByUUIDAndPopulateAccount('' + id) - } +async function doesVideoChannelIdExist (id: number, res: express.Response) { + const videoChannel = await VideoChannelModel.loadAndPopulateAccount(+id) return processVideoChannelExist(videoChannel, res) } 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' // --------------------------------------------------------------------------- -const LAST_MIGRATION_VERSION = 380 +const LAST_MIGRATION_VERSION = 385 // --------------------------------------------------------------------------- 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 @@ +import * as Sequelize from 'sequelize' + +async function up (utils: { + transaction: Sequelize.Transaction, + queryInterface: Sequelize.QueryInterface, + sequelize: Sequelize.Sequelize, + db: any +}): Promise { + await utils.queryInterface.removeColumn('actor', 'uuid') +} + +function down (options) { + throw new Error('Not implemented.') +} + +export { + up, + down +} 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) { return actor.save() }) .catch(err => { - logger.error('Cannot set public/private keys of actor %d.', actor.uuid, { err }) + logger.error('Cannot set public/private keys of actor %d.', actor.url, { err }) return actor }) } @@ -128,18 +128,17 @@ async function updateActorInstance (actorInstance: ActorModel, attributes: Activ const followersCount = await fetchActorTotalItems(attributes.followers) const followingCount = await fetchActorTotalItems(attributes.following) - actorInstance.set('type', attributes.type) - actorInstance.set('uuid', attributes.uuid) - actorInstance.set('preferredUsername', attributes.preferredUsername) - actorInstance.set('url', attributes.id) - actorInstance.set('publicKey', attributes.publicKey.publicKeyPem) - actorInstance.set('followersCount', followersCount) - actorInstance.set('followingCount', followingCount) - actorInstance.set('inboxUrl', attributes.inbox) - actorInstance.set('outboxUrl', attributes.outbox) - actorInstance.set('sharedInboxUrl', attributes.endpoints.sharedInbox) - actorInstance.set('followersUrl', attributes.followers) - actorInstance.set('followingUrl', attributes.following) + actorInstance.type = attributes.type + actorInstance.preferredUsername = attributes.preferredUsername + actorInstance.url = attributes.id + actorInstance.publicKey = attributes.publicKey.publicKeyPem + actorInstance.followersCount = followersCount + actorInstance.followingCount = followingCount + actorInstance.inboxUrl = attributes.inbox + actorInstance.outboxUrl = attributes.outbox + actorInstance.sharedInboxUrl = attributes.endpoints.sharedInbox + actorInstance.followersUrl = attributes.followers + actorInstance.followingUrl = attributes.following } async function updateActorAvatarInstance (actorInstance: ActorModel, avatarName: string, t: Transaction) { @@ -388,7 +387,6 @@ async function fetchRemoteActor (actorUrl: string): Promise<{ statusCode?: numbe const actor = new ActorModel({ type: actorJSON.type, - uuid: actorJSON.uuid, preferredUsername: actorJSON.preferredUsername, url: actorJSON.id, 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: } async function processDeleteAccount (accountToRemove: AccountModel) { - logger.debug('Removing remote account "%s".', accountToRemove.Actor.uuid) + logger.debug('Removing remote account "%s".', accountToRemove.Actor.url) await sequelizeTypescript.transaction(async t => { await accountToRemove.destroy({ transaction: t }) }) - logger.info('Remote account with uuid %s removed.', accountToRemove.Actor.uuid) + logger.info('Remote account %s removed.', accountToRemove.Actor.url) } async function processDeleteVideoChannel (videoChannelToRemove: VideoChannelModel) { - logger.debug('Removing remote video channel "%s".', videoChannelToRemove.Actor.uuid) + logger.debug('Removing remote video channel "%s".', videoChannelToRemove.Actor.url) await sequelizeTypescript.transaction(async t => { await videoChannelToRemove.destroy({ transaction: t }) }) - logger.info('Remote video channel with uuid %s removed.', videoChannelToRemove.Actor.uuid) + logger.info('Remote video channel %s removed.', videoChannelToRemove.Actor.url) } function 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 async function processUpdateActor (actor: ActorModel, activity: ActivityUpdate) { const actorAttributesToUpdate = activity.object as ActivityPubActor - logger.debug('Updating remote account "%s".', actorAttributesToUpdate.uuid) + logger.debug('Updating remote account "%s".', actorAttributesToUpdate.url) let accountOrChannelInstance: AccountModel | VideoChannelModel let actorFieldsSave: object let accountOrChannelFieldsSave: object @@ -128,7 +128,7 @@ async function processUpdateActor (actor: ActorModel, activity: ActivityUpdate) await accountOrChannelInstance.save({ transaction: t }) }) - logger.info('Remote account with uuid %s updated', actorAttributesToUpdate.uuid) + logger.info('Remote account %s updated', actorAttributesToUpdate.url) } catch (err) { if (actor !== undefined && actorFieldsSave !== undefined) { 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 @@ import * as express from 'express' import { param, query } from 'express-validator/check' -import { doesAccountIdExist, isAccountNameValid, doesAccountNameWithHostExist } from '../../helpers/custom-validators/accounts' -import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc' +import { doesAccountIdExist, doesAccountNameWithHostExist } from '../../helpers/custom-validators/accounts' +import { isIdOrUUIDValid, isIdValid } from '../../helpers/custom-validators/misc' import { logger } from '../../helpers/logger' import { areValidationErrors } from './utils' import { isValidRSSFeed } from '../../helpers/custom-validators/feeds' import { doesVideoChannelIdExist, doesVideoChannelNameWithHostExist } from '../../helpers/custom-validators/video-channels' import { doesVideoExist } from '../../helpers/custom-validators/videos' -import { isActorPreferredUsernameValid } from '../../helpers/custom-validators/activitypub/actor' const videoFeedsValidator = [ param('format').optional().custom(isValidRSSFeed).withMessage('Should have a valid format (rss, atom, json)'), query('format').optional().custom(isValidRSSFeed).withMessage('Should have a valid format (rss, atom, json)'), - query('accountId').optional().custom(isIdOrUUIDValid), - query('accountName').optional().custom(isAccountNameValid), - query('videoChannelId').optional().custom(isIdOrUUIDValid), - query('videoChannelName').optional().custom(isActorPreferredUsernameValid), + query('accountId').optional().custom(isIdValid), + query('accountName').optional(), + query('videoChannelId').optional().custom(isIdValid), + query('videoChannelName').optional(), async (req: express.Request, res: express.Response, next: express.NextFunction) => { 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 { attributes: [ 'id', 'name' ], include: [ { - attributes: [ 'id', 'uuid', 'preferredUsername', 'url', 'serverId', 'avatarId' ], + attributes: [ 'id', 'preferredUsername', 'url', 'serverId', 'avatarId' ], model: ActorModel.unscoped(), required: true, where: whereActor, @@ -180,22 +180,6 @@ export class AccountModel extends Model { return AccountModel.findByPk(id, { transaction }) } - static loadByUUID (uuid: string) { - const query = { - include: [ - { - model: ActorModel, - required: true, - where: { - uuid - } - } - ] - } - - return AccountModel.findOne(query) - } - static loadByNameWithHost (nameWithHost: string) { const [ accountName, host ] = nameWithHost.split('@') @@ -332,7 +316,6 @@ export class AccountModel extends Model { return { id: this.id, - uuid: actor.uuid, name: actor.name, displayName: this.getDisplayName(), 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 { Column, CreatedAt, DataType, - Default, DefaultScope, ForeignKey, HasMany, HasOne, Is, - IsUUID, Model, Scopes, Table, @@ -119,10 +117,6 @@ export const unusedActorAttributesForAPI = [ { fields: [ 'avatarId' ] }, - { - fields: [ 'uuid' ], - unique: true - }, { fields: [ 'followersUrl' ] } @@ -134,12 +128,6 @@ export class ActorModel extends Model { @Column(DataType.ENUM(...values(ACTIVITY_PUB_ACTOR_TYPES))) type: ActivityPubActorType - @AllowNull(false) - @Default(DataType.UUIDV4) - @IsUUID(4) - @Column(DataType.UUID) - uuid: string - @AllowNull(false) @Is('ActorPreferredUsername', value => throwIfNotValid(value, isActorPreferredUsernameValid, 'actor preferred username')) @Column @@ -408,7 +396,6 @@ export class ActorModel extends Model { return { id: this.id, url: this.url, - uuid: this.uuid, name: this.preferredUsername, host: this.getHost(), hostRedundancyAllowed: this.getRedundancyAllowed(), @@ -454,7 +441,6 @@ export class ActorModel extends Model { endpoints: { sharedInbox: this.sharedInboxUrl }, - uuid: this.uuid, publicKey: { id: this.getPublicKeyUrl(), 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 = { attributes: [ 'name', 'description', 'id', 'actorId' ], include: [ { - attributes: [ 'uuid', 'preferredUsername', 'url', 'serverId', 'avatarId' ], + attributes: [ 'preferredUsername', 'url', 'serverId', 'avatarId' ], model: ActorModel.unscoped(), required: true, include: [ @@ -387,24 +387,6 @@ export class VideoChannelModel extends Model { .findByPk(id) } - static loadByUUIDAndPopulateAccount (uuid: string) { - const query = { - include: [ - { - model: ActorModel, - required: true, - where: { - uuid - } - } - ] - } - - return VideoChannelModel - .scope([ ScopeNames.WITH_ACCOUNT ]) - .findOne(query) - } - static loadByUrlAndPopulateAccount (url: string) { const query = { include: [ @@ -510,7 +492,6 @@ export class VideoChannelModel extends Model { return { id: this.id, - uuid: actor.uuid, name: actor.name, displayName: this.getDisplayName(), 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' import { Account } from '../../../../shared/models/actors' import { checkTmpIsEmpty, - checkVideoFilesWereRemoved, cleanupTests, + checkVideoFilesWereRemoved, + cleanupTests, createUser, doubleFollow, flushAndRunMultipleServers, @@ -15,14 +16,7 @@ import { updateMyUser, userLogin } from '../../../../shared/extra-utils' -import { - getMyUserInformation, - killallServers, - ServerInfo, - testImage, - updateMyAvatar, - uploadVideo -} from '../../../../shared/extra-utils/index' +import { getMyUserInformation, ServerInfo, testImage, updateMyAvatar, uploadVideo } from '../../../../shared/extra-utils/index' import { checkActorFilesWereRemoved, getAccount, getAccountsList } from '../../../../shared/extra-utils/users/accounts' import { setAccessTokensToServers } from '../../../../shared/extra-utils/users/login' import { User } from '../../../../shared/models/users' @@ -34,12 +28,10 @@ const expect = chai.expect describe('Test users with multiple servers', function () { let servers: ServerInfo[] = [] let user: User - let userAccountName: string - let userAccountUUID: string - let userVideoChannelUUID: string let userId: number let videoUUID: string let userAccessToken: string + let userAvatarFilename: string before(async function () { this.timeout(120000) @@ -74,19 +66,6 @@ describe('Test users with multiple servers', function () { userAccessToken = await userLogin(servers[ 0 ], user) } - { - const res = await getMyUserInformation(servers[0].url, userAccessToken) - const account: Account = res.body.account - userAccountName = account.name + '@' + account.host - userAccountUUID = account.uuid - } - - { - const res = await getMyUserInformation(servers[ 0 ].url, servers[ 0 ].accessToken) - const user: User = res.body - userVideoChannelUUID = user.videoChannels[0].uuid - } - { const resVideo = await uploadVideo(servers[ 0 ].url, userAccessToken, {}) videoUUID = resVideo.body.video.uuid @@ -106,6 +85,8 @@ describe('Test users with multiple servers', function () { const res = await getMyUserInformation(servers[0].url, servers[0].accessToken) user = res.body + + const account: Account = user.account expect(user.account.displayName).to.equal('my super display name') await waitJobs(servers) @@ -142,7 +123,9 @@ describe('Test users with multiple servers', function () { const res = await getMyUserInformation(servers[0].url, servers[0].accessToken) user = res.body - await testImage(servers[0].url, 'avatar2-resized', user.account.avatar.path, '.png') + userAvatarFilename = user.account.avatar.path + + await testImage(servers[0].url, 'avatar2-resized', userAvatarFilename, '.png') await waitJobs(servers) }) @@ -173,7 +156,7 @@ describe('Test users with multiple servers', function () { it('Should list account videos', async function () { for (const server of servers) { - const res = await getAccountVideos(server.url, server.accessToken, userAccountName, 0, 5) + const res = await getAccountVideos(server.url, server.accessToken, 'user1@localhost:' + servers[0].port, 0, 5) expect(res.body.total).to.equal(1) expect(res.body.data).to.be.an('array') @@ -218,8 +201,7 @@ describe('Test users with multiple servers', function () { it('Should not have actor files', async () => { for (const server of servers) { - await checkActorFilesWereRemoved(userAccountUUID, server.internalServerNumber) - await checkActorFilesWereRemoved(userVideoChannelUUID, server.internalServerNumber) + await checkActorFilesWereRemoved(userAvatarFilename, server.internalServerNumber) } }) 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 { import { addVideoChannel, deleteVideoChannel, - flushTests, getAccountVideoChannelsList, getMyUserInformation, getVideoChannel, getVideoChannelsList, - killallServers, ServerInfo, setAccessTokensToServers, updateVideoChannel @@ -35,7 +33,6 @@ const expect = chai.expect describe('Test video channels', function () { let servers: ServerInfo[] let userInfo: User - let accountUUID: string let firstVideoChannelId: number let secondVideoChannelId: number let videoUUID: string @@ -51,7 +48,6 @@ describe('Test video channels', function () { { const res = await getMyUserInformation(servers[0].url, servers[0].accessToken) const user: User = res.body - accountUUID = user.account.uuid firstVideoChannelId = user.videoChannels[0].id } 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 { createUser, doubleFollow, flushAndRunMultipleServers, - flushTests, - getJSONfeed, getMyUserInformation, + getJSONfeed, + getMyUserInformation, getXMLfeed, - killallServers, ServerInfo, setAccessTokensToServers, - uploadVideo, userLogin + uploadVideo, + userLogin } from '../../../shared/extra-utils' import * as libxmljs from 'libxmljs' import { addVideoCommentThread } from '../../../shared/extra-utils/videos/video-comments' @@ -28,10 +28,10 @@ const expect = chai.expect describe('Test syndication feeds', () => { let servers: ServerInfo[] = [] let userAccessToken: string - let rootAccountUUID: string - let rootChannelUUID: string - let userAccountUUID: string - let userChannelUUID: string + let rootAccountId: number + let rootChannelId: number + let userAccountId: number + let userChannelId: number before(async function () { this.timeout(120000) @@ -45,8 +45,8 @@ describe('Test syndication feeds', () => { { const res = await getMyUserInformation(servers[0].url, servers[0].accessToken) const user: User = res.body - rootAccountUUID = user.account.uuid - rootChannelUUID = user.videoChannels[0].uuid + rootAccountId = user.account.id + rootChannelId = user.videoChannels[0].id } { @@ -56,8 +56,8 @@ describe('Test syndication feeds', () => { const res = await getMyUserInformation(servers[0].url, userAccessToken) const user: User = res.body - userAccountUUID = user.account.uuid - userChannelUUID = user.videoChannels[0].uuid + userAccountId = user.account.id + userChannelId = user.videoChannels[0].id } { @@ -127,71 +127,71 @@ describe('Test syndication feeds', () => { }) it('Should filter by account', async function () { + { + const json = await getJSONfeed(servers[0].url, 'videos', { accountId: rootAccountId }) + const jsonObj = JSON.parse(json.text) + expect(jsonObj.items.length).to.be.equal(1) + expect(jsonObj.items[ 0 ].title).to.equal('my super name for server 1') + expect(jsonObj.items[ 0 ].author.name).to.equal('root') + } + + { + const json = await getJSONfeed(servers[0].url, 'videos', { accountId: userAccountId }) + const jsonObj = JSON.parse(json.text) + expect(jsonObj.items.length).to.be.equal(1) + expect(jsonObj.items[ 0 ].title).to.equal('user video') + expect(jsonObj.items[ 0 ].author.name).to.equal('john') + } + for (const server of servers) { { - const json = await getJSONfeed(server.url, 'videos', { accountId: rootAccountUUID }) + const json = await getJSONfeed(server.url, 'videos', { accountName: 'root@localhost:' + servers[0].port }) const jsonObj = JSON.parse(json.text) expect(jsonObj.items.length).to.be.equal(1) expect(jsonObj.items[ 0 ].title).to.equal('my super name for server 1') - expect(jsonObj.items[ 0 ].author.name).to.equal('root') } { - const json = await getJSONfeed(server.url, 'videos', { accountId: userAccountUUID }) + const json = await getJSONfeed(server.url, 'videos', { accountName: 'john@localhost:' + servers[0].port }) const jsonObj = JSON.parse(json.text) expect(jsonObj.items.length).to.be.equal(1) expect(jsonObj.items[ 0 ].title).to.equal('user video') - expect(jsonObj.items[ 0 ].author.name).to.equal('john') } } + }) + it('Should filter by video channel', async function () { { - const json = await getJSONfeed(servers[0].url, 'videos', { accountName: 'root' }) + const json = await getJSONfeed(servers[0].url, 'videos', { videoChannelId: rootChannelId }) const jsonObj = JSON.parse(json.text) expect(jsonObj.items.length).to.be.equal(1) expect(jsonObj.items[ 0 ].title).to.equal('my super name for server 1') + expect(jsonObj.items[ 0 ].author.name).to.equal('root') } { - const json = await getJSONfeed(servers[0].url, 'videos', { accountName: 'john' }) + const json = await getJSONfeed(servers[0].url, 'videos', { videoChannelId: userChannelId }) const jsonObj = JSON.parse(json.text) expect(jsonObj.items.length).to.be.equal(1) expect(jsonObj.items[ 0 ].title).to.equal('user video') + expect(jsonObj.items[ 0 ].author.name).to.equal('john') } - }) - it('Should filter by video channel', async function () { for (const server of servers) { { - const json = await getJSONfeed(server.url, 'videos', { videoChannelId: rootChannelUUID }) + const json = await getJSONfeed(server.url, 'videos', { videoChannelName: 'root_channel@localhost:' + servers[0].port }) const jsonObj = JSON.parse(json.text) expect(jsonObj.items.length).to.be.equal(1) expect(jsonObj.items[ 0 ].title).to.equal('my super name for server 1') - expect(jsonObj.items[ 0 ].author.name).to.equal('root') } { - const json = await getJSONfeed(server.url, 'videos', { videoChannelId: userChannelUUID }) + const json = await getJSONfeed(server.url, 'videos', { videoChannelName: 'john_channel@localhost:' + servers[0].port }) const jsonObj = JSON.parse(json.text) expect(jsonObj.items.length).to.be.equal(1) expect(jsonObj.items[ 0 ].title).to.equal('user video') - expect(jsonObj.items[ 0 ].author.name).to.equal('john') } } - - { - const json = await getJSONfeed(servers[0].url, 'videos', { videoChannelName: 'root_channel' }) - const jsonObj = JSON.parse(json.text) - expect(jsonObj.items.length).to.be.equal(1) - expect(jsonObj.items[ 0 ].title).to.equal('my super name for server 1') - } - - { - const json = await getJSONfeed(servers[0].url, 'videos', { videoChannelName: 'john_channel' }) - const jsonObj = JSON.parse(json.text) - expect(jsonObj.items.length).to.be.equal(1) - expect(jsonObj.items[ 0 ].title).to.equal('user video') - } }) }) diff --git a/shared/extra-utils/users/accounts.ts b/shared/extra-utils/users/accounts.ts index f64a2dbad..627e17cc3 100644 --- a/shared/extra-utils/users/accounts.ts +++ b/shared/extra-utils/users/accounts.ts @@ -39,7 +39,7 @@ async function expectAccountFollows (url: string, nameWithDomain: string, follow expect(account.followingCount).to.equal(followingCount, message) } -async function checkActorFilesWereRemoved (actorUUID: string, serverNumber: number) { +async function checkActorFilesWereRemoved (filename: string, serverNumber: number) { const testDirectory = 'test' + serverNumber for (const directory of [ 'avatars' ]) { @@ -50,7 +50,7 @@ async function checkActorFilesWereRemoved (actorUUID: string, serverNumber: numb const files = await readdir(directoryPath) for (const file of files) { - expect(file).to.not.contain(actorUUID) + expect(file).to.not.contain(filename) } } } diff --git a/shared/extra-utils/videos/videos.ts b/shared/extra-utils/videos/videos.ts index b64de2470..a4ca43f26 100644 --- a/shared/extra-utils/videos/videos.ts +++ b/shared/extra-utils/videos/videos.ts @@ -524,7 +524,6 @@ async function completeVideoCheck ( expect(video.nsfw).to.equal(attributes.nsfw) expect(video.description).to.equal(attributes.description) expect(video.account.id).to.be.a('number') - expect(video.account.uuid).to.be.a('string') expect(video.account.host).to.equal(attributes.account.host) expect(video.account.name).to.equal(attributes.account.name) expect(video.channel.displayName).to.equal(attributes.channel.displayName) diff --git a/shared/models/activitypub/activitypub-actor.ts b/shared/models/activitypub/activitypub-actor.ts index 5e30bf783..53ec579bc 100644 --- a/shared/models/activitypub/activitypub-actor.ts +++ b/shared/models/activitypub/activitypub-actor.ts @@ -21,7 +21,6 @@ export interface ActivityPubActor { attributedTo: ActivityPubAttributedTo[] support?: string - uuid: string publicKey: { id: string owner: string diff --git a/shared/models/actors/account.model.ts b/shared/models/actors/account.model.ts index 043a2507e..2ff4b9f5e 100644 --- a/shared/models/actors/account.model.ts +++ b/shared/models/actors/account.model.ts @@ -10,7 +10,6 @@ export interface Account extends Actor { export interface AccountSummary { id: number - uuid: string name: string displayName: string url: string diff --git a/shared/models/actors/actor.model.ts b/shared/models/actors/actor.model.ts index a3953874d..1dbf5f638 100644 --- a/shared/models/actors/actor.model.ts +++ b/shared/models/actors/actor.model.ts @@ -2,7 +2,6 @@ import { Avatar } from '../avatars/avatar.model' export interface Actor { id: number - uuid: string url: string name: string host: string diff --git a/shared/models/videos/channel/video-channel.model.ts b/shared/models/videos/channel/video-channel.model.ts index 14a813f8f..de4c26b3d 100644 --- a/shared/models/videos/channel/video-channel.model.ts +++ b/shared/models/videos/channel/video-channel.model.ts @@ -12,7 +12,6 @@ export interface VideoChannel extends Actor { export interface VideoChannelSummary { id: number - uuid: string name: string displayName: string url: string -- cgit v1.2.3