ActivityPub-federated video streaming platform using P2P directly in your web browser
Fix lint
Chocobozzz98ec8b8e73a9
diff --git a/.travis.yml b/.travis.ymlindex bb7e2c1302..1ca6ea8861 100644--- a/.travis.yml+++ b/.travis.yml@@ -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=clidiff --git a/scripts/travis.sh b/scripts/travis.shindex e0a59806af..f24aac885d 100755--- a/scripts/travis.sh+++ b/scripts/travis.sh@@ -5,9 +5,9 @@ if [ $# -eq 0 ]; thenexit -1fi-if [ "$1" = "client" ]; then+if [ "$1" = "misc" ]; thennpm 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.tselif [ "$1" = "api" ]; thennpm run build:servermocha --exit --require ts-node/register --bail server/tests/api/index.tsdiff --git a/scripts/update-host.ts b/scripts/update-host.tsindex 4410e1ff7e..759443623e 100755--- a/scripts/update-host.ts+++ b/scripts/update-host.ts@@ -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 > 0diff --git a/server.ts b/server.tsindex 3221c17907..a723dd32b6 100644--- a/server.ts+++ b/server.ts@@ -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 -----------diff --git a/server/controllers/activitypub/client.ts b/server/controllers/activitypub/client.tsindex 62cde1fc7a..a478acd140 100644--- a/server/controllers/activitypub/client.ts+++ b/server/controllers/activitypub/client.ts@@ -73,7 +73,7 @@ async function accountFollowersController (req: express.Request, res: express.Reconst page = req.query.page || 1const { 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.Reconst page = req.query.page || 1const { 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)diff --git a/server/controllers/activitypub/outbox.ts b/server/controllers/activitypub/outbox.tsindex e2c4e9b1e6..5a2d43f3dd 100644--- a/server/controllers/activitypub/outbox.ts+++ b/server/controllers/activitypub/outbox.ts@@ -38,15 +38,16 @@ async function outboxController (req: express.Request, res: express.Response, neconst videoObject = video.toActivityPubObject()// This is a shared video+ const videoChannel = video.VideoChannelif (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)}diff --git a/server/lib/activitypub/send/send-delete.ts b/server/lib/activitypub/send/send-delete.tsindex c49cda04f9..8193790b3f 100644--- a/server/lib/activitypub/send/send-delete.ts+++ b/server/lib/activitypub/send/send-delete.ts@@ -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)}diff --git a/server/middlewares/validators/video-channels.ts b/server/middlewares/validators/video-channels.tsindex 4683c91e13..3d31a7e52e 100644--- a/server/middlewares/validators/video-channels.ts+++ b/server/middlewares/validators/video-channels.ts@@ -109,7 +109,7 @@ const videoChannelsShareValidator = [if (areValidationErrors(req, res)) returnif (!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()diff --git a/server/middlewares/validators/videos.ts b/server/middlewares/validators/videos.tsindex 52b4475ce3..f21680aa04 100644--- a/server/middlewares/validators/videos.ts+++ b/server/middlewares/validators/videos.ts@@ -222,7 +222,7 @@ const videosShareValidator = [if (areValidationErrors(req, res)) returnif (!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()diff --git a/server/models/video/video-channel-share-interface.ts b/server/models/video/video-channel-share-interface.tsindex 0482e82971..2fff41a1b9 100644--- a/server/models/video/video-channel-share-interface.ts+++ b/server/models/video/video-channel-share-interface.ts@@ -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 {diff --git a/server/models/video/video-share-interface.ts b/server/models/video/video-share-interface.tsindex 8ad10e095b..3946303f17 100644--- a/server/models/video/video-share-interface.ts+++ b/server/models/video/video-share-interface.ts@@ -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 {diff --git a/server/tests/client.ts b/server/tests/client.tsindex 0d70e34519..8c4334c534 100644--- a/server/tests/client.ts+++ b/server/tests/client.ts@@ -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.uuidconst 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?' +diff --git a/server/tests/index.ts b/server/tests/index.tsindex a7dd0d824f..755fb26046 100644--- a/server/tests/index.ts+++ b/server/tests/index.ts@@ -1,4 +1,5 @@// Order of the tests we want to executeimport './client'+import './activitypub'import './api/'import './cli/'diff --git a/server/tests/utils/index.ts b/server/tests/utils/index.tsindex 4308fd49a2..b918ee83d2 100644--- a/server/tests/utils/index.ts+++ b/server/tests/utils/index.ts@@ -1,3 +1,4 @@+export * from './activitypub'export * from './cli'export * from './clients'export * from './config'