1
0
Fork 0
This commit is contained in:
Chocobozzz 2017-11-30 13:16:23 +01:00
parent 1b5b10d131
commit 98ec8b8e73
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
14 changed files with 31 additions and 23 deletions

View File

@ -38,7 +38,7 @@ before_script:
matrix: matrix:
include: include:
- env: TEST_SUITE=client - env: TEST_SUITE=misc
- env: TEST_SUITE=api-fast - env: TEST_SUITE=api-fast
- env: TEST_SUITE=api-slow - env: TEST_SUITE=api-slow
- env: TEST_SUITE=cli - env: TEST_SUITE=cli

View File

@ -5,9 +5,9 @@ if [ $# -eq 0 ]; then
exit -1 exit -1
fi fi
if [ "$1" = "client" ]; then if [ "$1" = "misc" ]; then
npm run build npm run build
mocha --exit --require ts-node/register --bail server/tests/client.ts mocha --exit --require ts-node/register --bail server/tests/client.ts server/tests/activitypub.ts
elif [ "$1" = "api" ]; then elif [ "$1" = "api" ]; then
npm run build:server npm run build:server
mocha --exit --require ts-node/register --bail server/tests/api/index.ts mocha --exit --require ts-node/register --bail server/tests/api/index.ts

View File

@ -6,7 +6,7 @@ db.init(true)
return getServerAccount() return getServerAccount()
}) })
.then(serverAccount => { .then(serverAccount => {
return db.AccountFollow.listAcceptedFollowingUrlsForApi([ serverAccount.id ]) return db.AccountFollow.listAcceptedFollowingUrlsForApi([ serverAccount.id ], undefined)
}) })
.then(res => { .then(res => {
return res.total > 0 return res.total > 0

View File

@ -129,7 +129,11 @@ app.use('/', staticRouter)
// Always serve index client page (the client is a single page application, let it handle routing) // Always serve index client page (the client is a single page application, let it handle routing)
app.use('/*', function (req, res) { app.use('/*', function (req, res) {
res.sendFile(path.join(__dirname, '../client/dist/index.html')) if (req.accepts('html')) {
return res.sendFile(path.join(__dirname, '../client/dist/index.html'))
}
return res.status(404).end()
}) })
// ----------- Errors ----------- // ----------- Errors -----------

View File

@ -73,7 +73,7 @@ async function accountFollowersController (req: express.Request, res: express.Re
const page = req.query.page || 1 const page = req.query.page || 1
const { start, count } = pageToStartAndCount(page, ACTIVITY_PUB.COLLECTION_ITEMS_PER_PAGE) const { start, count } = pageToStartAndCount(page, ACTIVITY_PUB.COLLECTION_ITEMS_PER_PAGE)
const result = await db.AccountFollow.listAcceptedFollowerUrlsForApi([ account.id ], start, count) const result = await db.AccountFollow.listAcceptedFollowerUrlsForApi([ account.id ], undefined, start, count)
const activityPubResult = activityPubCollectionPagination(CONFIG.WEBSERVER.URL + req.url, page, result) const activityPubResult = activityPubCollectionPagination(CONFIG.WEBSERVER.URL + req.url, page, result)
return res.json(activityPubResult) return res.json(activityPubResult)
@ -85,7 +85,7 @@ async function accountFollowingController (req: express.Request, res: express.Re
const page = req.query.page || 1 const page = req.query.page || 1
const { start, count } = pageToStartAndCount(page, ACTIVITY_PUB.COLLECTION_ITEMS_PER_PAGE) const { start, count } = pageToStartAndCount(page, ACTIVITY_PUB.COLLECTION_ITEMS_PER_PAGE)
const result = await db.AccountFollow.listAcceptedFollowingUrlsForApi([ account.id ], start, count) const result = await db.AccountFollow.listAcceptedFollowingUrlsForApi([ account.id ], undefined, start, count)
const activityPubResult = activityPubCollectionPagination(CONFIG.WEBSERVER.URL + req.url, page, result) const activityPubResult = activityPubCollectionPagination(CONFIG.WEBSERVER.URL + req.url, page, result)
return res.json(activityPubResult) return res.json(activityPubResult)

View File

@ -38,15 +38,16 @@ async function outboxController (req: express.Request, res: express.Response, ne
const videoObject = video.toActivityPubObject() const videoObject = video.toActivityPubObject()
// This is a shared video // This is a shared video
const videoChannel = video.VideoChannel
if (video.VideoShares !== undefined && video.VideoShares.length !== 0) { if (video.VideoShares !== undefined && video.VideoShares.length !== 0) {
const addActivity = await addActivityData(video.url, video.VideoChannel.Account, video, video.VideoChannel.url, videoObject) const addActivity = await addActivityData(video.url, videoChannel.Account, video, videoChannel.url, videoObject, undefined)
const url = getAnnounceActivityPubUrl(video.url, account) const url = getAnnounceActivityPubUrl(video.url, account)
const announceActivity = await announceActivityData(url, account, addActivity) const announceActivity = await announceActivityData(url, account, addActivity, undefined)
activities.push(announceActivity) activities.push(announceActivity)
} else { } else {
const addActivity = await addActivityData(video.url, account, video, video.VideoChannel.url, videoObject) const addActivity = await addActivityData(video.url, account, video, videoChannel.url, videoObject, undefined)
activities.push(addActivity) activities.push(addActivity)
} }

View File

@ -27,7 +27,7 @@ async function sendDeleteVideo (video: VideoInstance, t: Transaction) {
} }
async function sendDeleteAccount (account: AccountInstance, t: Transaction) { async function sendDeleteAccount (account: AccountInstance, t: Transaction) {
const data = await deleteActivityData(account.url, account) const data = deleteActivityData(account.url, account)
return broadcastToFollowers(data, account, [ account ], t) return broadcastToFollowers(data, account, [ account ], t)
} }

View File

@ -109,7 +109,7 @@ const videoChannelsShareValidator = [
if (areValidationErrors(req, res)) return if (areValidationErrors(req, res)) return
if (!await isVideoChannelExist(req.params.id, res)) return if (!await isVideoChannelExist(req.params.id, res)) return
const share = await db.VideoChannelShare.load(res.locals.video.id, req.params.accountId) const share = await db.VideoChannelShare.load(res.locals.video.id, req.params.accountId, undefined)
if (!share) { if (!share) {
return res.status(404) return res.status(404)
.end() .end()

View File

@ -222,7 +222,7 @@ const videosShareValidator = [
if (areValidationErrors(req, res)) return if (areValidationErrors(req, res)) return
if (!await isVideoExist(req.params.id, res)) return if (!await isVideoExist(req.params.id, res)) return
const share = await db.VideoShare.load(req.params.accountId, res.locals.video.id) const share = await db.VideoShare.load(req.params.accountId, res.locals.video.id, undefined)
if (!share) { if (!share) {
return res.status(404) return res.status(404)
.end() .end()

View File

@ -1,12 +1,11 @@
import * as Bluebird from 'bluebird' import * as Bluebird from 'bluebird'
import * as Sequelize from 'sequelize' import * as Sequelize from 'sequelize'
import { Transaction } from 'sequelize'
import { AccountInstance } from '../account/account-interface' import { AccountInstance } from '../account/account-interface'
import { VideoChannelInstance } from './video-channel-interface' import { VideoChannelInstance } from './video-channel-interface'
export namespace VideoChannelShareMethods { export namespace VideoChannelShareMethods {
export type LoadAccountsByShare = (videoChannelId: number, t: Transaction) => Bluebird<AccountInstance[]> export type LoadAccountsByShare = (videoChannelId: number, t: Sequelize.Transaction) => Bluebird<AccountInstance[]>
export type Load = (accountId: number, videoId: number, t: Transaction) => Bluebird<VideoChannelShareInstance> export type Load = (accountId: number, videoId: number, t: Sequelize.Transaction) => Bluebird<VideoChannelShareInstance>
} }
export interface VideoChannelShareClass { export interface VideoChannelShareClass {

View File

@ -1,12 +1,11 @@
import * as Bluebird from 'bluebird' import * as Bluebird from 'bluebird'
import * as Sequelize from 'sequelize' import * as Sequelize from 'sequelize'
import { Transaction } from 'sequelize'
import { AccountInstance } from '../account/account-interface' import { AccountInstance } from '../account/account-interface'
import { VideoInstance } from './video-interface' import { VideoInstance } from './video-interface'
export namespace VideoShareMethods { export namespace VideoShareMethods {
export type LoadAccountsByShare = (videoId: number, t: Transaction) => Bluebird<AccountInstance[]> export type LoadAccountsByShare = (videoId: number, t: Sequelize.Transaction) => Bluebird<AccountInstance[]>
export type Load = (accountId: number, videoId: number, t: Transaction) => Bluebird<VideoShareInstance> export type Load = (accountId: number, videoId: number, t: Sequelize.Transaction) => Bluebird<VideoShareInstance>
} }
export interface VideoShareClass { export interface VideoShareClass {

View File

@ -42,6 +42,7 @@ describe('Test a client controllers', function () {
it('Should have valid Open Graph tags on the watch page with video id', async function () { it('Should have valid Open Graph tags on the watch page with video id', async function () {
const res = await request(server.url) const res = await request(server.url)
.get('/videos/watch/' + server.video.id) .get('/videos/watch/' + server.video.id)
.set('Accept', 'text/html')
.expect(200) .expect(200)
expect(res.text).to.contain('<meta property="og:title" content="my super name for server 1" />') expect(res.text).to.contain('<meta property="og:title" content="my super name for server 1" />')
@ -51,6 +52,7 @@ describe('Test a client controllers', function () {
it('Should have valid Open Graph tags on the watch page with video uuid', async function () { it('Should have valid Open Graph tags on the watch page with video uuid', async function () {
const res = await request(server.url) const res = await request(server.url)
.get('/videos/watch/' + server.video.uuid) .get('/videos/watch/' + server.video.uuid)
.set('Accept', 'text/html')
.expect(200) .expect(200)
expect(res.text).to.contain('<meta property="og:title" content="my super name for server 1" />') expect(res.text).to.contain('<meta property="og:title" content="my super name for server 1" />')
@ -61,6 +63,7 @@ describe('Test a client controllers', function () {
const path = '/videos/watch/' + server.video.uuid const path = '/videos/watch/' + server.video.uuid
const res = await request(server.url) const res = await request(server.url)
.get(path) .get(path)
.set('Accept', 'text/html')
.expect(200) .expect(200)
const expectedLink = '<link rel="alternate" type="application/json+oembed" href="http://localhost:9001/services/oembed?' + const expectedLink = '<link rel="alternate" type="application/json+oembed" href="http://localhost:9001/services/oembed?' +

View File

@ -1,4 +1,5 @@
// Order of the tests we want to execute // Order of the tests we want to execute
import './client' import './client'
import './activitypub'
import './api/' import './api/'
import './cli/' import './cli/'

View File

@ -1,3 +1,4 @@
export * from './activitypub'
export * from './cli' export * from './cli'
export * from './clients' export * from './clients'
export * from './config' export * from './config'