Remove unused actor uuid field

This commit is contained in:
Chocobozzz 2019-05-31 14:02:26 +02:00
parent 4c72c1cd41
commit 57cfff7885
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
26 changed files with 130 additions and 200 deletions

View File

@ -1,5 +1,7 @@
<div class="margin-content"> <div class="margin-content">
<div class="no-results" i18n *ngIf="channelPagination.totalItems === 0">This account does not have channels.</div>
<div class="channels" myInfiniteScroller (nearOfBottom)="onNearOfBottom()" [autoInit]="true"> <div class="channels" myInfiniteScroller (nearOfBottom)="onNearOfBottom()" [autoInit]="true">
<div class="section channel" *ngFor="let videoChannel of videoChannels"> <div class="section channel" *ngFor="let videoChannel of videoChannels">
<div class="section-title"> <div class="section-title">

View File

@ -4,7 +4,6 @@ import { getAbsoluteAPIUrl } from '@app/shared/misc/utils'
export abstract class Actor implements ActorServer { export abstract class Actor implements ActorServer {
id: number id: number
uuid: string
url: string url: string
name: string name: string
host: string host: string
@ -35,7 +34,6 @@ export abstract class Actor implements ActorServer {
protected constructor (hash: ActorServer) { protected constructor (hash: ActorServer) {
this.id = hash.id this.id = hash.id
this.uuid = hash.uuid
this.url = hash.url this.url = hash.url
this.name = hash.name this.name = hash.name
this.host = hash.host this.host = hash.host

View File

@ -17,8 +17,11 @@ removeFiles () {
} }
dropRedis () { dropRedis () {
redis-cli KEYS "bull-localhost:900$1*" | grep -v empty | xargs --no-run-if-empty redis-cli DEL port=$((9000+$1))
redis-cli KEYS "redis-localhost:900$1*" | grep -v empty | xargs --no-run-if-empty redis-cli DEL
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) seq=$(seq 1 6)

View File

@ -3,6 +3,8 @@
set -eu set -eu
npm run build:server npm run build:server
npm run setup:cli
npm run travis -- lint npm run travis -- lint
mocha --exit --require ts-node/register/type-check --bail server/tests/index.ts mocha --exit --require ts-node/register/type-check --bail server/tests/index.ts

View File

@ -190,8 +190,7 @@ async function createUser (req: express.Request, res: express.Response) {
user: { user: {
id: user.id, id: user.id,
account: { account: {
id: account.id, id: account.id
uuid: account.Actor.uuid
} }
} }
}).end() }).end()

View File

@ -143,15 +143,14 @@ async function addVideoChannel (req: express.Request, res: express.Response) {
}) })
setAsyncActorKeys(videoChannelCreated.Actor) 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())) 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({ return res.json({
videoChannel: { videoChannel: {
id: videoChannelCreated.id, id: videoChannelCreated.id
uuid: videoChannelCreated.Actor.uuid
} }
}).end() }).end()
} }
@ -180,7 +179,7 @@ async function updateVideoChannel (req: express.Request, res: express.Response)
new VideoChannelAuditView(videoChannelInstanceUpdated.toFormattedJSON()), new VideoChannelAuditView(videoChannelInstanceUpdated.toFormattedJSON()),
oldVideoChannelAuditKeys 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) { } catch (err) {
logger.debug('Cannot update the video channel.', { 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 }) await videoChannelInstance.destroy({ transaction: t })
auditLogger.delete(getAuditIdFromRes(res), new VideoChannelAuditView(videoChannelInstance.toFormattedJSON())) 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() return res.type('json').status(204).end()

View File

@ -1,7 +1,6 @@
import * as Bluebird from 'bluebird' import * as Bluebird from 'bluebird'
import { Response } from 'express' import { Response } from 'express'
import 'express-validator' import 'express-validator'
import * as validator from 'validator'
import { AccountModel } from '../../models/account/account' import { AccountModel } from '../../models/account/account'
import { isUserDescriptionValid, isUserUsernameValid } from './users' import { isUserDescriptionValid, isUserUsernameValid } from './users'
import { exists } from './misc' import { exists } from './misc'
@ -18,14 +17,8 @@ function isAccountDescriptionValid (value: string) {
return isUserDescriptionValid(value) return isUserDescriptionValid(value)
} }
function doesAccountIdExist (id: number | string, res: Response, sendNotFound = true) { function doesAccountIdExist (id: number, res: Response, sendNotFound = true) {
let promise: Bluebird<AccountModel> const promise = AccountModel.load(id)
if (validator.isInt('' + id)) {
promise = AccountModel.load(+id)
} else { // UUID
promise = AccountModel.loadByUUID('' + id)
}
return doesAccountExist(promise, res, sendNotFound) return doesAccountExist(promise, res, sendNotFound)
} }

View File

@ -26,13 +26,8 @@ async function doesLocalVideoChannelNameExist (name: string, res: express.Respon
return processVideoChannelExist(videoChannel, res) return processVideoChannelExist(videoChannel, res)
} }
async function doesVideoChannelIdExist (id: number | string, res: express.Response) { async function doesVideoChannelIdExist (id: number, res: express.Response) {
let videoChannel: VideoChannelModel const videoChannel = await VideoChannelModel.loadAndPopulateAccount(+id)
if (validator.isInt('' + id)) {
videoChannel = await VideoChannelModel.loadAndPopulateAccount(+id)
} else { // UUID
videoChannel = await VideoChannelModel.loadByUUIDAndPopulateAccount('' + id)
}
return processVideoChannelExist(videoChannel, res) return processVideoChannelExist(videoChannel, res)
} }

View File

@ -14,7 +14,7 @@ import { CONFIG, registerConfigChangedHandler } from './config'
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
const LAST_MIGRATION_VERSION = 380 const LAST_MIGRATION_VERSION = 385
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------

View File

@ -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<void> {
await utils.queryInterface.removeColumn('actor', 'uuid')
}
function down (options) {
throw new Error('Not implemented.')
}
export {
up,
down
}

View File

@ -33,7 +33,7 @@ function setAsyncActorKeys (actor: ActorModel) {
return actor.save() return actor.save()
}) })
.catch(err => { .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 return actor
}) })
} }
@ -128,18 +128,17 @@ async function updateActorInstance (actorInstance: ActorModel, attributes: Activ
const followersCount = await fetchActorTotalItems(attributes.followers) const followersCount = await fetchActorTotalItems(attributes.followers)
const followingCount = await fetchActorTotalItems(attributes.following) const followingCount = await fetchActorTotalItems(attributes.following)
actorInstance.set('type', attributes.type) actorInstance.type = attributes.type
actorInstance.set('uuid', attributes.uuid) actorInstance.preferredUsername = attributes.preferredUsername
actorInstance.set('preferredUsername', attributes.preferredUsername) actorInstance.url = attributes.id
actorInstance.set('url', attributes.id) actorInstance.publicKey = attributes.publicKey.publicKeyPem
actorInstance.set('publicKey', attributes.publicKey.publicKeyPem) actorInstance.followersCount = followersCount
actorInstance.set('followersCount', followersCount) actorInstance.followingCount = followingCount
actorInstance.set('followingCount', followingCount) actorInstance.inboxUrl = attributes.inbox
actorInstance.set('inboxUrl', attributes.inbox) actorInstance.outboxUrl = attributes.outbox
actorInstance.set('outboxUrl', attributes.outbox) actorInstance.sharedInboxUrl = attributes.endpoints.sharedInbox
actorInstance.set('sharedInboxUrl', attributes.endpoints.sharedInbox) actorInstance.followersUrl = attributes.followers
actorInstance.set('followersUrl', attributes.followers) actorInstance.followingUrl = attributes.following
actorInstance.set('followingUrl', attributes.following)
} }
async function updateActorAvatarInstance (actorInstance: ActorModel, avatarName: string, t: Transaction) { 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({ const actor = new ActorModel({
type: actorJSON.type, type: actorJSON.type,
uuid: actorJSON.uuid,
preferredUsername: actorJSON.preferredUsername, preferredUsername: actorJSON.preferredUsername,
url: actorJSON.id, url: actorJSON.id,
publicKey: actorJSON.publicKey.publicKeyPem, publicKey: actorJSON.publicKey.publicKeyPem,

View File

@ -95,23 +95,23 @@ async function processDeleteVideoPlaylist (actor: ActorModel, playlistToDelete:
} }
async function processDeleteAccount (accountToRemove: AccountModel) { 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 sequelizeTypescript.transaction(async t => {
await accountToRemove.destroy({ transaction: 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) { 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 sequelizeTypescript.transaction(async t => {
await videoChannelToRemove.destroy({ transaction: 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) { function processDeleteVideoComment (byActor: ActorModel, videoComment: VideoCommentModel, activity: ActivityDelete) {

View File

@ -95,7 +95,7 @@ async function processUpdateCacheFile (byActor: ActorModel, activity: ActivityUp
async function processUpdateActor (actor: ActorModel, activity: ActivityUpdate) { async function processUpdateActor (actor: ActorModel, activity: ActivityUpdate) {
const actorAttributesToUpdate = activity.object as ActivityPubActor 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 accountOrChannelInstance: AccountModel | VideoChannelModel
let actorFieldsSave: object let actorFieldsSave: object
let accountOrChannelFieldsSave: object let accountOrChannelFieldsSave: object
@ -128,7 +128,7 @@ async function processUpdateActor (actor: ActorModel, activity: ActivityUpdate)
await accountOrChannelInstance.save({ transaction: t }) 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) { } catch (err) {
if (actor !== undefined && actorFieldsSave !== undefined) { if (actor !== undefined && actorFieldsSave !== undefined) {
resetSequelizeInstance(actor, actorFieldsSave) resetSequelizeInstance(actor, actorFieldsSave)

View File

@ -1,21 +1,20 @@
import * as express from 'express' import * as express from 'express'
import { param, query } from 'express-validator/check' import { param, query } from 'express-validator/check'
import { doesAccountIdExist, isAccountNameValid, doesAccountNameWithHostExist } from '../../helpers/custom-validators/accounts' import { doesAccountIdExist, doesAccountNameWithHostExist } from '../../helpers/custom-validators/accounts'
import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc' import { isIdOrUUIDValid, isIdValid } from '../../helpers/custom-validators/misc'
import { logger } from '../../helpers/logger' import { logger } from '../../helpers/logger'
import { areValidationErrors } from './utils' import { areValidationErrors } from './utils'
import { isValidRSSFeed } from '../../helpers/custom-validators/feeds' import { isValidRSSFeed } from '../../helpers/custom-validators/feeds'
import { doesVideoChannelIdExist, doesVideoChannelNameWithHostExist } from '../../helpers/custom-validators/video-channels' import { doesVideoChannelIdExist, doesVideoChannelNameWithHostExist } from '../../helpers/custom-validators/video-channels'
import { doesVideoExist } from '../../helpers/custom-validators/videos' import { doesVideoExist } from '../../helpers/custom-validators/videos'
import { isActorPreferredUsernameValid } from '../../helpers/custom-validators/activitypub/actor'
const videoFeedsValidator = [ const videoFeedsValidator = [
param('format').optional().custom(isValidRSSFeed).withMessage('Should have a valid format (rss, atom, json)'), 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('format').optional().custom(isValidRSSFeed).withMessage('Should have a valid format (rss, atom, json)'),
query('accountId').optional().custom(isIdOrUUIDValid), query('accountId').optional().custom(isIdValid),
query('accountName').optional().custom(isAccountNameValid), query('accountName').optional(),
query('videoChannelId').optional().custom(isIdOrUUIDValid), query('videoChannelId').optional().custom(isIdValid),
query('videoChannelName').optional().custom(isActorPreferredUsernameValid), query('videoChannelName').optional(),
async (req: express.Request, res: express.Response, next: express.NextFunction) => { async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking feeds parameters', { parameters: req.query }) logger.debug('Checking feeds parameters', { parameters: req.query })

View File

@ -47,7 +47,7 @@ export enum ScopeNames {
attributes: [ 'id', 'name' ], attributes: [ 'id', 'name' ],
include: [ include: [
{ {
attributes: [ 'id', 'uuid', 'preferredUsername', 'url', 'serverId', 'avatarId' ], attributes: [ 'id', 'preferredUsername', 'url', 'serverId', 'avatarId' ],
model: ActorModel.unscoped(), model: ActorModel.unscoped(),
required: true, required: true,
where: whereActor, where: whereActor,
@ -180,22 +180,6 @@ export class AccountModel extends Model<AccountModel> {
return AccountModel.findByPk(id, { transaction }) 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) { static loadByNameWithHost (nameWithHost: string) {
const [ accountName, host ] = nameWithHost.split('@') const [ accountName, host ] = nameWithHost.split('@')
@ -332,7 +316,6 @@ export class AccountModel extends Model<AccountModel> {
return { return {
id: this.id, id: this.id,
uuid: actor.uuid,
name: actor.name, name: actor.name,
displayName: this.getDisplayName(), displayName: this.getDisplayName(),
url: actor.url, url: actor.url,

View File

@ -7,13 +7,11 @@ import {
Column, Column,
CreatedAt, CreatedAt,
DataType, DataType,
Default,
DefaultScope, DefaultScope,
ForeignKey, ForeignKey,
HasMany, HasMany,
HasOne, HasOne,
Is, Is,
IsUUID,
Model, Model,
Scopes, Scopes,
Table, Table,
@ -119,10 +117,6 @@ export const unusedActorAttributesForAPI = [
{ {
fields: [ 'avatarId' ] fields: [ 'avatarId' ]
}, },
{
fields: [ 'uuid' ],
unique: true
},
{ {
fields: [ 'followersUrl' ] fields: [ 'followersUrl' ]
} }
@ -134,12 +128,6 @@ export class ActorModel extends Model<ActorModel> {
@Column(DataType.ENUM(...values(ACTIVITY_PUB_ACTOR_TYPES))) @Column(DataType.ENUM(...values(ACTIVITY_PUB_ACTOR_TYPES)))
type: ActivityPubActorType type: ActivityPubActorType
@AllowNull(false)
@Default(DataType.UUIDV4)
@IsUUID(4)
@Column(DataType.UUID)
uuid: string
@AllowNull(false) @AllowNull(false)
@Is('ActorPreferredUsername', value => throwIfNotValid(value, isActorPreferredUsernameValid, 'actor preferred username')) @Is('ActorPreferredUsername', value => throwIfNotValid(value, isActorPreferredUsernameValid, 'actor preferred username'))
@Column @Column
@ -408,7 +396,6 @@ export class ActorModel extends Model<ActorModel> {
return { return {
id: this.id, id: this.id,
url: this.url, url: this.url,
uuid: this.uuid,
name: this.preferredUsername, name: this.preferredUsername,
host: this.getHost(), host: this.getHost(),
hostRedundancyAllowed: this.getRedundancyAllowed(), hostRedundancyAllowed: this.getRedundancyAllowed(),
@ -454,7 +441,6 @@ export class ActorModel extends Model<ActorModel> {
endpoints: { endpoints: {
sharedInbox: this.sharedInboxUrl sharedInbox: this.sharedInboxUrl
}, },
uuid: this.uuid,
publicKey: { publicKey: {
id: this.getPublicKeyUrl(), id: this.getPublicKeyUrl(),
owner: this.url, owner: this.url,

View File

@ -72,7 +72,7 @@ type AvailableForListOptions = {
attributes: [ 'name', 'description', 'id', 'actorId' ], attributes: [ 'name', 'description', 'id', 'actorId' ],
include: [ include: [
{ {
attributes: [ 'uuid', 'preferredUsername', 'url', 'serverId', 'avatarId' ], attributes: [ 'preferredUsername', 'url', 'serverId', 'avatarId' ],
model: ActorModel.unscoped(), model: ActorModel.unscoped(),
required: true, required: true,
include: [ include: [
@ -387,24 +387,6 @@ export class VideoChannelModel extends Model<VideoChannelModel> {
.findByPk(id) .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) { static loadByUrlAndPopulateAccount (url: string) {
const query = { const query = {
include: [ include: [
@ -510,7 +492,6 @@ export class VideoChannelModel extends Model<VideoChannelModel> {
return { return {
id: this.id, id: this.id,
uuid: actor.uuid,
name: actor.name, name: actor.name,
displayName: this.getDisplayName(), displayName: this.getDisplayName(),
url: actor.url, url: actor.url,

View File

@ -5,7 +5,8 @@ import 'mocha'
import { Account } from '../../../../shared/models/actors' import { Account } from '../../../../shared/models/actors'
import { import {
checkTmpIsEmpty, checkTmpIsEmpty,
checkVideoFilesWereRemoved, cleanupTests, checkVideoFilesWereRemoved,
cleanupTests,
createUser, createUser,
doubleFollow, doubleFollow,
flushAndRunMultipleServers, flushAndRunMultipleServers,
@ -15,14 +16,7 @@ import {
updateMyUser, updateMyUser,
userLogin userLogin
} from '../../../../shared/extra-utils' } from '../../../../shared/extra-utils'
import { import { getMyUserInformation, ServerInfo, testImage, updateMyAvatar, uploadVideo } from '../../../../shared/extra-utils/index'
getMyUserInformation,
killallServers,
ServerInfo,
testImage,
updateMyAvatar,
uploadVideo
} from '../../../../shared/extra-utils/index'
import { checkActorFilesWereRemoved, getAccount, getAccountsList } from '../../../../shared/extra-utils/users/accounts' import { checkActorFilesWereRemoved, getAccount, getAccountsList } from '../../../../shared/extra-utils/users/accounts'
import { setAccessTokensToServers } from '../../../../shared/extra-utils/users/login' import { setAccessTokensToServers } from '../../../../shared/extra-utils/users/login'
import { User } from '../../../../shared/models/users' import { User } from '../../../../shared/models/users'
@ -34,12 +28,10 @@ const expect = chai.expect
describe('Test users with multiple servers', function () { describe('Test users with multiple servers', function () {
let servers: ServerInfo[] = [] let servers: ServerInfo[] = []
let user: User let user: User
let userAccountName: string
let userAccountUUID: string
let userVideoChannelUUID: string
let userId: number let userId: number
let videoUUID: string let videoUUID: string
let userAccessToken: string let userAccessToken: string
let userAvatarFilename: string
before(async function () { before(async function () {
this.timeout(120000) this.timeout(120000)
@ -74,19 +66,6 @@ describe('Test users with multiple servers', function () {
userAccessToken = await userLogin(servers[ 0 ], user) 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, {}) const resVideo = await uploadVideo(servers[ 0 ].url, userAccessToken, {})
videoUUID = resVideo.body.video.uuid 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) const res = await getMyUserInformation(servers[0].url, servers[0].accessToken)
user = res.body user = res.body
const account: Account = user.account
expect(user.account.displayName).to.equal('my super display name') expect(user.account.displayName).to.equal('my super display name')
await waitJobs(servers) await waitJobs(servers)
@ -142,7 +123,9 @@ describe('Test users with multiple servers', function () {
const res = await getMyUserInformation(servers[0].url, servers[0].accessToken) const res = await getMyUserInformation(servers[0].url, servers[0].accessToken)
user = res.body 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) await waitJobs(servers)
}) })
@ -173,7 +156,7 @@ describe('Test users with multiple servers', function () {
it('Should list account videos', async function () { it('Should list account videos', async function () {
for (const server of servers) { 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.total).to.equal(1)
expect(res.body.data).to.be.an('array') 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 () => { it('Should not have actor files', async () => {
for (const server of servers) { for (const server of servers) {
await checkActorFilesWereRemoved(userAccountUUID, server.internalServerNumber) await checkActorFilesWereRemoved(userAvatarFilename, server.internalServerNumber)
await checkActorFilesWereRemoved(userVideoChannelUUID, server.internalServerNumber)
} }
}) })

View File

@ -18,12 +18,10 @@ import {
import { import {
addVideoChannel, addVideoChannel,
deleteVideoChannel, deleteVideoChannel,
flushTests,
getAccountVideoChannelsList, getAccountVideoChannelsList,
getMyUserInformation, getMyUserInformation,
getVideoChannel, getVideoChannel,
getVideoChannelsList, getVideoChannelsList,
killallServers,
ServerInfo, ServerInfo,
setAccessTokensToServers, setAccessTokensToServers,
updateVideoChannel updateVideoChannel
@ -35,7 +33,6 @@ const expect = chai.expect
describe('Test video channels', function () { describe('Test video channels', function () {
let servers: ServerInfo[] let servers: ServerInfo[]
let userInfo: User let userInfo: User
let accountUUID: string
let firstVideoChannelId: number let firstVideoChannelId: number
let secondVideoChannelId: number let secondVideoChannelId: number
let videoUUID: string let videoUUID: string
@ -51,7 +48,6 @@ describe('Test video channels', function () {
{ {
const res = await getMyUserInformation(servers[0].url, servers[0].accessToken) const res = await getMyUserInformation(servers[0].url, servers[0].accessToken)
const user: User = res.body const user: User = res.body
accountUUID = user.account.uuid
firstVideoChannelId = user.videoChannels[0].id firstVideoChannelId = user.videoChannels[0].id
} }

View File

@ -7,13 +7,13 @@ import {
createUser, createUser,
doubleFollow, doubleFollow,
flushAndRunMultipleServers, flushAndRunMultipleServers,
flushTests, getJSONfeed,
getJSONfeed, getMyUserInformation, getMyUserInformation,
getXMLfeed, getXMLfeed,
killallServers,
ServerInfo, ServerInfo,
setAccessTokensToServers, setAccessTokensToServers,
uploadVideo, userLogin uploadVideo,
userLogin
} from '../../../shared/extra-utils' } from '../../../shared/extra-utils'
import * as libxmljs from 'libxmljs' import * as libxmljs from 'libxmljs'
import { addVideoCommentThread } from '../../../shared/extra-utils/videos/video-comments' import { addVideoCommentThread } from '../../../shared/extra-utils/videos/video-comments'
@ -28,10 +28,10 @@ const expect = chai.expect
describe('Test syndication feeds', () => { describe('Test syndication feeds', () => {
let servers: ServerInfo[] = [] let servers: ServerInfo[] = []
let userAccessToken: string let userAccessToken: string
let rootAccountUUID: string let rootAccountId: number
let rootChannelUUID: string let rootChannelId: number
let userAccountUUID: string let userAccountId: number
let userChannelUUID: string let userChannelId: number
before(async function () { before(async function () {
this.timeout(120000) this.timeout(120000)
@ -45,8 +45,8 @@ describe('Test syndication feeds', () => {
{ {
const res = await getMyUserInformation(servers[0].url, servers[0].accessToken) const res = await getMyUserInformation(servers[0].url, servers[0].accessToken)
const user: User = res.body const user: User = res.body
rootAccountUUID = user.account.uuid rootAccountId = user.account.id
rootChannelUUID = user.videoChannels[0].uuid rootChannelId = user.videoChannels[0].id
} }
{ {
@ -56,8 +56,8 @@ describe('Test syndication feeds', () => {
const res = await getMyUserInformation(servers[0].url, userAccessToken) const res = await getMyUserInformation(servers[0].url, userAccessToken)
const user: User = res.body const user: User = res.body
userAccountUUID = user.account.uuid userAccountId = user.account.id
userChannelUUID = user.videoChannels[0].uuid userChannelId = user.videoChannels[0].id
} }
{ {
@ -127,9 +127,8 @@ describe('Test syndication feeds', () => {
}) })
it('Should filter by account', async function () { it('Should filter by account', async function () {
for (const server of servers) {
{ {
const json = await getJSONfeed(server.url, 'videos', { accountId: rootAccountUUID }) const json = await getJSONfeed(servers[0].url, 'videos', { accountId: rootAccountId })
const jsonObj = JSON.parse(json.text) const jsonObj = JSON.parse(json.text)
expect(jsonObj.items.length).to.be.equal(1) 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 ].title).to.equal('my super name for server 1')
@ -137,33 +136,33 @@ describe('Test syndication feeds', () => {
} }
{ {
const json = await getJSONfeed(server.url, 'videos', { accountId: userAccountUUID }) const json = await getJSONfeed(servers[0].url, 'videos', { accountId: userAccountId })
const jsonObj = JSON.parse(json.text) const jsonObj = JSON.parse(json.text)
expect(jsonObj.items.length).to.be.equal(1) expect(jsonObj.items.length).to.be.equal(1)
expect(jsonObj.items[ 0 ].title).to.equal('user video') expect(jsonObj.items[ 0 ].title).to.equal('user video')
expect(jsonObj.items[ 0 ].author.name).to.equal('john') expect(jsonObj.items[ 0 ].author.name).to.equal('john')
} }
}
for (const server of servers) {
{ {
const json = await getJSONfeed(servers[0].url, 'videos', { accountName: 'root' }) const json = await getJSONfeed(server.url, 'videos', { accountName: 'root@localhost:' + servers[0].port })
const jsonObj = JSON.parse(json.text) const jsonObj = JSON.parse(json.text)
expect(jsonObj.items.length).to.be.equal(1) 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 ].title).to.equal('my super name for server 1')
} }
{ {
const json = await getJSONfeed(servers[0].url, 'videos', { accountName: 'john' }) const json = await getJSONfeed(server.url, 'videos', { accountName: 'john@localhost:' + servers[0].port })
const jsonObj = JSON.parse(json.text) const jsonObj = JSON.parse(json.text)
expect(jsonObj.items.length).to.be.equal(1) expect(jsonObj.items.length).to.be.equal(1)
expect(jsonObj.items[ 0 ].title).to.equal('user video') expect(jsonObj.items[ 0 ].title).to.equal('user video')
} }
}
}) })
it('Should filter by video channel', async function () { 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(servers[0].url, 'videos', { videoChannelId: rootChannelId })
const jsonObj = JSON.parse(json.text) const jsonObj = JSON.parse(json.text)
expect(jsonObj.items.length).to.be.equal(1) 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 ].title).to.equal('my super name for server 1')
@ -171,27 +170,28 @@ describe('Test syndication feeds', () => {
} }
{ {
const json = await getJSONfeed(server.url, 'videos', { videoChannelId: userChannelUUID }) const json = await getJSONfeed(servers[0].url, 'videos', { videoChannelId: userChannelId })
const jsonObj = JSON.parse(json.text) const jsonObj = JSON.parse(json.text)
expect(jsonObj.items.length).to.be.equal(1) expect(jsonObj.items.length).to.be.equal(1)
expect(jsonObj.items[ 0 ].title).to.equal('user video') expect(jsonObj.items[ 0 ].title).to.equal('user video')
expect(jsonObj.items[ 0 ].author.name).to.equal('john') expect(jsonObj.items[ 0 ].author.name).to.equal('john')
} }
}
for (const server of servers) {
{ {
const json = await getJSONfeed(servers[0].url, 'videos', { videoChannelName: 'root_channel' }) const json = await getJSONfeed(server.url, 'videos', { videoChannelName: 'root_channel@localhost:' + servers[0].port })
const jsonObj = JSON.parse(json.text) const jsonObj = JSON.parse(json.text)
expect(jsonObj.items.length).to.be.equal(1) 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 ].title).to.equal('my super name for server 1')
} }
{ {
const json = await getJSONfeed(servers[0].url, 'videos', { videoChannelName: 'john_channel' }) const json = await getJSONfeed(server.url, 'videos', { videoChannelName: 'john_channel@localhost:' + servers[0].port })
const jsonObj = JSON.parse(json.text) const jsonObj = JSON.parse(json.text)
expect(jsonObj.items.length).to.be.equal(1) expect(jsonObj.items.length).to.be.equal(1)
expect(jsonObj.items[ 0 ].title).to.equal('user video') expect(jsonObj.items[ 0 ].title).to.equal('user video')
} }
}
}) })
}) })

View File

@ -39,7 +39,7 @@ async function expectAccountFollows (url: string, nameWithDomain: string, follow
expect(account.followingCount).to.equal(followingCount, message) 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 const testDirectory = 'test' + serverNumber
for (const directory of [ 'avatars' ]) { for (const directory of [ 'avatars' ]) {
@ -50,7 +50,7 @@ async function checkActorFilesWereRemoved (actorUUID: string, serverNumber: numb
const files = await readdir(directoryPath) const files = await readdir(directoryPath)
for (const file of files) { for (const file of files) {
expect(file).to.not.contain(actorUUID) expect(file).to.not.contain(filename)
} }
} }
} }

View File

@ -524,7 +524,6 @@ async function completeVideoCheck (
expect(video.nsfw).to.equal(attributes.nsfw) expect(video.nsfw).to.equal(attributes.nsfw)
expect(video.description).to.equal(attributes.description) expect(video.description).to.equal(attributes.description)
expect(video.account.id).to.be.a('number') 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.host).to.equal(attributes.account.host)
expect(video.account.name).to.equal(attributes.account.name) expect(video.account.name).to.equal(attributes.account.name)
expect(video.channel.displayName).to.equal(attributes.channel.displayName) expect(video.channel.displayName).to.equal(attributes.channel.displayName)

View File

@ -21,7 +21,6 @@ export interface ActivityPubActor {
attributedTo: ActivityPubAttributedTo[] attributedTo: ActivityPubAttributedTo[]
support?: string support?: string
uuid: string
publicKey: { publicKey: {
id: string id: string
owner: string owner: string

View File

@ -10,7 +10,6 @@ export interface Account extends Actor {
export interface AccountSummary { export interface AccountSummary {
id: number id: number
uuid: string
name: string name: string
displayName: string displayName: string
url: string url: string

View File

@ -2,7 +2,6 @@ import { Avatar } from '../avatars/avatar.model'
export interface Actor { export interface Actor {
id: number id: number
uuid: string
url: string url: string
name: string name: string
host: string host: string

View File

@ -12,7 +12,6 @@ export interface VideoChannel extends Actor {
export interface VideoChannelSummary { export interface VideoChannelSummary {
id: number id: number
uuid: string
name: string name: string
displayName: string displayName: string
url: string url: string