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:
include:
- env: TEST_SUITE=client
- env: TEST_SUITE=misc
- env: TEST_SUITE=api-fast
- env: TEST_SUITE=api-slow
- env: TEST_SUITE=cli

View file

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

View file

@ -6,7 +6,7 @@ db.init(true)
return getServerAccount()
})
.then(serverAccount => {
return db.AccountFollow.listAcceptedFollowingUrlsForApi([ serverAccount.id ])
return db.AccountFollow.listAcceptedFollowingUrlsForApi([ serverAccount.id ], undefined)
})
.then(res => {
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)
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 -----------

View file

@ -73,7 +73,7 @@ async function accountFollowersController (req: express.Request, res: express.Re
const page = req.query.page || 1
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)
return res.json(activityPubResult)
@ -85,7 +85,7 @@ async function accountFollowingController (req: express.Request, res: express.Re
const page = req.query.page || 1
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)
return res.json(activityPubResult)

View file

@ -38,15 +38,16 @@ async function outboxController (req: express.Request, res: express.Response, ne
const videoObject = video.toActivityPubObject()
// This is a shared video
const videoChannel = video.VideoChannel
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 announceActivity = await announceActivityData(url, account, addActivity)
const announceActivity = await announceActivityData(url, account, addActivity, undefined)
activities.push(announceActivity)
} 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)
}

View file

@ -27,7 +27,7 @@ async function sendDeleteVideo (video: VideoInstance, 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)
}

View file

@ -109,7 +109,7 @@ const videoChannelsShareValidator = [
if (areValidationErrors(req, 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) {
return res.status(404)
.end()

View file

@ -222,7 +222,7 @@ const videosShareValidator = [
if (areValidationErrors(req, 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) {
return res.status(404)
.end()

View file

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

View file

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

View file

@ -41,8 +41,9 @@ describe('Test a client controllers', function () {
it('Should have valid Open Graph tags on the watch page with video id', async function () {
const res = await request(server.url)
.get('/videos/watch/' + server.video.id)
.expect(200)
.get('/videos/watch/' + server.video.id)
.set('Accept', 'text/html')
.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:description" content="my super description for server 1" />')
@ -50,8 +51,9 @@ describe('Test a client controllers', function () {
it('Should have valid Open Graph tags on the watch page with video uuid', async function () {
const res = await request(server.url)
.get('/videos/watch/' + server.video.uuid)
.expect(200)
.get('/videos/watch/' + server.video.uuid)
.set('Accept', 'text/html')
.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:description" content="my super description for server 1" />')
@ -61,6 +63,7 @@ describe('Test a client controllers', function () {
const path = '/videos/watch/' + server.video.uuid
const res = await request(server.url)
.get(path)
.set('Accept', 'text/html')
.expect(200)
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
import './client'
import './activitypub'
import './api/'
import './cli/'

View file

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