diff options
-rw-r--r-- | .travis.yml | 2 | ||||
-rwxr-xr-x | scripts/travis.sh | 4 | ||||
-rwxr-xr-x | scripts/update-host.ts | 2 | ||||
-rw-r--r-- | server.ts | 6 | ||||
-rw-r--r-- | server/controllers/activitypub/client.ts | 4 | ||||
-rw-r--r-- | server/controllers/activitypub/outbox.ts | 7 | ||||
-rw-r--r-- | server/lib/activitypub/send/send-delete.ts | 2 | ||||
-rw-r--r-- | server/middlewares/validators/video-channels.ts | 2 | ||||
-rw-r--r-- | server/middlewares/validators/videos.ts | 2 | ||||
-rw-r--r-- | server/models/video/video-channel-share-interface.ts | 5 | ||||
-rw-r--r-- | server/models/video/video-share-interface.ts | 5 | ||||
-rw-r--r-- | server/tests/client.ts | 11 | ||||
-rw-r--r-- | server/tests/index.ts | 1 | ||||
-rw-r--r-- | server/tests/utils/index.ts | 1 |
14 files changed, 31 insertions, 23 deletions
diff --git a/.travis.yml b/.travis.yml index bb7e2c130..1ca6ea886 100644 --- a/.travis.yml +++ b/.travis.yml | |||
@@ -38,7 +38,7 @@ before_script: | |||
38 | 38 | ||
39 | matrix: | 39 | matrix: |
40 | include: | 40 | include: |
41 | - env: TEST_SUITE=client | 41 | - env: TEST_SUITE=misc |
42 | - env: TEST_SUITE=api-fast | 42 | - env: TEST_SUITE=api-fast |
43 | - env: TEST_SUITE=api-slow | 43 | - env: TEST_SUITE=api-slow |
44 | - env: TEST_SUITE=cli | 44 | - env: TEST_SUITE=cli |
diff --git a/scripts/travis.sh b/scripts/travis.sh index e0a59806a..f24aac885 100755 --- a/scripts/travis.sh +++ b/scripts/travis.sh | |||
@@ -5,9 +5,9 @@ if [ $# -eq 0 ]; then | |||
5 | exit -1 | 5 | exit -1 |
6 | fi | 6 | fi |
7 | 7 | ||
8 | if [ "$1" = "client" ]; then | 8 | if [ "$1" = "misc" ]; then |
9 | npm run build | 9 | npm run build |
10 | mocha --exit --require ts-node/register --bail server/tests/client.ts | 10 | mocha --exit --require ts-node/register --bail server/tests/client.ts server/tests/activitypub.ts |
11 | elif [ "$1" = "api" ]; then | 11 | elif [ "$1" = "api" ]; then |
12 | npm run build:server | 12 | npm run build:server |
13 | mocha --exit --require ts-node/register --bail server/tests/api/index.ts | 13 | mocha --exit --require ts-node/register --bail server/tests/api/index.ts |
diff --git a/scripts/update-host.ts b/scripts/update-host.ts index 4410e1ff7..759443623 100755 --- a/scripts/update-host.ts +++ b/scripts/update-host.ts | |||
@@ -6,7 +6,7 @@ db.init(true) | |||
6 | return getServerAccount() | 6 | return getServerAccount() |
7 | }) | 7 | }) |
8 | .then(serverAccount => { | 8 | .then(serverAccount => { |
9 | return db.AccountFollow.listAcceptedFollowingUrlsForApi([ serverAccount.id ]) | 9 | return db.AccountFollow.listAcceptedFollowingUrlsForApi([ serverAccount.id ], undefined) |
10 | }) | 10 | }) |
11 | .then(res => { | 11 | .then(res => { |
12 | return res.total > 0 | 12 | return res.total > 0 |
@@ -129,7 +129,11 @@ app.use('/', staticRouter) | |||
129 | 129 | ||
130 | // Always serve index client page (the client is a single page application, let it handle routing) | 130 | // Always serve index client page (the client is a single page application, let it handle routing) |
131 | app.use('/*', function (req, res) { | 131 | app.use('/*', function (req, res) { |
132 | res.sendFile(path.join(__dirname, '../client/dist/index.html')) | 132 | if (req.accepts('html')) { |
133 | return res.sendFile(path.join(__dirname, '../client/dist/index.html')) | ||
134 | } | ||
135 | |||
136 | return res.status(404).end() | ||
133 | }) | 137 | }) |
134 | 138 | ||
135 | // ----------- Errors ----------- | 139 | // ----------- Errors ----------- |
diff --git a/server/controllers/activitypub/client.ts b/server/controllers/activitypub/client.ts index 62cde1fc7..a478acd14 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.Re | |||
73 | const page = req.query.page || 1 | 73 | const page = req.query.page || 1 |
74 | const { start, count } = pageToStartAndCount(page, ACTIVITY_PUB.COLLECTION_ITEMS_PER_PAGE) | 74 | const { start, count } = pageToStartAndCount(page, ACTIVITY_PUB.COLLECTION_ITEMS_PER_PAGE) |
75 | 75 | ||
76 | const result = await db.AccountFollow.listAcceptedFollowerUrlsForApi([ account.id ], start, count) | 76 | const result = await db.AccountFollow.listAcceptedFollowerUrlsForApi([ account.id ], undefined, start, count) |
77 | const activityPubResult = activityPubCollectionPagination(CONFIG.WEBSERVER.URL + req.url, page, result) | 77 | const activityPubResult = activityPubCollectionPagination(CONFIG.WEBSERVER.URL + req.url, page, result) |
78 | 78 | ||
79 | return res.json(activityPubResult) | 79 | return res.json(activityPubResult) |
@@ -85,7 +85,7 @@ async function accountFollowingController (req: express.Request, res: express.Re | |||
85 | const page = req.query.page || 1 | 85 | const page = req.query.page || 1 |
86 | const { start, count } = pageToStartAndCount(page, ACTIVITY_PUB.COLLECTION_ITEMS_PER_PAGE) | 86 | const { start, count } = pageToStartAndCount(page, ACTIVITY_PUB.COLLECTION_ITEMS_PER_PAGE) |
87 | 87 | ||
88 | const result = await db.AccountFollow.listAcceptedFollowingUrlsForApi([ account.id ], start, count) | 88 | const result = await db.AccountFollow.listAcceptedFollowingUrlsForApi([ account.id ], undefined, start, count) |
89 | const activityPubResult = activityPubCollectionPagination(CONFIG.WEBSERVER.URL + req.url, page, result) | 89 | const activityPubResult = activityPubCollectionPagination(CONFIG.WEBSERVER.URL + req.url, page, result) |
90 | 90 | ||
91 | return res.json(activityPubResult) | 91 | return res.json(activityPubResult) |
diff --git a/server/controllers/activitypub/outbox.ts b/server/controllers/activitypub/outbox.ts index e2c4e9b1e..5a2d43f3d 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, ne | |||
38 | const videoObject = video.toActivityPubObject() | 38 | const videoObject = video.toActivityPubObject() |
39 | 39 | ||
40 | // This is a shared video | 40 | // This is a shared video |
41 | const videoChannel = video.VideoChannel | ||
41 | if (video.VideoShares !== undefined && video.VideoShares.length !== 0) { | 42 | if (video.VideoShares !== undefined && video.VideoShares.length !== 0) { |
42 | const addActivity = await addActivityData(video.url, video.VideoChannel.Account, video, video.VideoChannel.url, videoObject) | 43 | const addActivity = await addActivityData(video.url, videoChannel.Account, video, videoChannel.url, videoObject, undefined) |
43 | 44 | ||
44 | const url = getAnnounceActivityPubUrl(video.url, account) | 45 | const url = getAnnounceActivityPubUrl(video.url, account) |
45 | const announceActivity = await announceActivityData(url, account, addActivity) | 46 | const announceActivity = await announceActivityData(url, account, addActivity, undefined) |
46 | 47 | ||
47 | activities.push(announceActivity) | 48 | activities.push(announceActivity) |
48 | } else { | 49 | } else { |
49 | const addActivity = await addActivityData(video.url, account, video, video.VideoChannel.url, videoObject) | 50 | const addActivity = await addActivityData(video.url, account, video, videoChannel.url, videoObject, undefined) |
50 | 51 | ||
51 | activities.push(addActivity) | 52 | activities.push(addActivity) |
52 | } | 53 | } |
diff --git a/server/lib/activitypub/send/send-delete.ts b/server/lib/activitypub/send/send-delete.ts index c49cda04f..8193790b3 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) { | |||
27 | } | 27 | } |
28 | 28 | ||
29 | async function sendDeleteAccount (account: AccountInstance, t: Transaction) { | 29 | async function sendDeleteAccount (account: AccountInstance, t: Transaction) { |
30 | const data = await deleteActivityData(account.url, account) | 30 | const data = deleteActivityData(account.url, account) |
31 | 31 | ||
32 | return broadcastToFollowers(data, account, [ account ], t) | 32 | return broadcastToFollowers(data, account, [ account ], t) |
33 | } | 33 | } |
diff --git a/server/middlewares/validators/video-channels.ts b/server/middlewares/validators/video-channels.ts index 4683c91e1..3d31a7e52 100644 --- a/server/middlewares/validators/video-channels.ts +++ b/server/middlewares/validators/video-channels.ts | |||
@@ -109,7 +109,7 @@ const videoChannelsShareValidator = [ | |||
109 | if (areValidationErrors(req, res)) return | 109 | if (areValidationErrors(req, res)) return |
110 | if (!await isVideoChannelExist(req.params.id, res)) return | 110 | if (!await isVideoChannelExist(req.params.id, res)) return |
111 | 111 | ||
112 | const share = await db.VideoChannelShare.load(res.locals.video.id, req.params.accountId) | 112 | const share = await db.VideoChannelShare.load(res.locals.video.id, req.params.accountId, undefined) |
113 | if (!share) { | 113 | if (!share) { |
114 | return res.status(404) | 114 | return res.status(404) |
115 | .end() | 115 | .end() |
diff --git a/server/middlewares/validators/videos.ts b/server/middlewares/validators/videos.ts index 52b4475ce..f21680aa0 100644 --- a/server/middlewares/validators/videos.ts +++ b/server/middlewares/validators/videos.ts | |||
@@ -222,7 +222,7 @@ const videosShareValidator = [ | |||
222 | if (areValidationErrors(req, res)) return | 222 | if (areValidationErrors(req, res)) return |
223 | if (!await isVideoExist(req.params.id, res)) return | 223 | if (!await isVideoExist(req.params.id, res)) return |
224 | 224 | ||
225 | const share = await db.VideoShare.load(req.params.accountId, res.locals.video.id) | 225 | const share = await db.VideoShare.load(req.params.accountId, res.locals.video.id, undefined) |
226 | if (!share) { | 226 | if (!share) { |
227 | return res.status(404) | 227 | return res.status(404) |
228 | .end() | 228 | .end() |
diff --git a/server/models/video/video-channel-share-interface.ts b/server/models/video/video-channel-share-interface.ts index 0482e8297..2fff41a1b 100644 --- a/server/models/video/video-channel-share-interface.ts +++ b/server/models/video/video-channel-share-interface.ts | |||
@@ -1,12 +1,11 @@ | |||
1 | import * as Bluebird from 'bluebird' | 1 | import * as Bluebird from 'bluebird' |
2 | import * as Sequelize from 'sequelize' | 2 | import * as Sequelize from 'sequelize' |
3 | import { Transaction } from 'sequelize' | ||
4 | import { AccountInstance } from '../account/account-interface' | 3 | import { AccountInstance } from '../account/account-interface' |
5 | import { VideoChannelInstance } from './video-channel-interface' | 4 | import { VideoChannelInstance } from './video-channel-interface' |
6 | 5 | ||
7 | export namespace VideoChannelShareMethods { | 6 | export namespace VideoChannelShareMethods { |
8 | export type LoadAccountsByShare = (videoChannelId: number, t: Transaction) => Bluebird<AccountInstance[]> | 7 | export type LoadAccountsByShare = (videoChannelId: number, t: Sequelize.Transaction) => Bluebird<AccountInstance[]> |
9 | export type Load = (accountId: number, videoId: number, t: Transaction) => Bluebird<VideoChannelShareInstance> | 8 | export type Load = (accountId: number, videoId: number, t: Sequelize.Transaction) => Bluebird<VideoChannelShareInstance> |
10 | } | 9 | } |
11 | 10 | ||
12 | export interface VideoChannelShareClass { | 11 | export interface VideoChannelShareClass { |
diff --git a/server/models/video/video-share-interface.ts b/server/models/video/video-share-interface.ts index 8ad10e095..3946303f1 100644 --- a/server/models/video/video-share-interface.ts +++ b/server/models/video/video-share-interface.ts | |||
@@ -1,12 +1,11 @@ | |||
1 | import * as Bluebird from 'bluebird' | 1 | import * as Bluebird from 'bluebird' |
2 | import * as Sequelize from 'sequelize' | 2 | import * as Sequelize from 'sequelize' |
3 | import { Transaction } from 'sequelize' | ||
4 | import { AccountInstance } from '../account/account-interface' | 3 | import { AccountInstance } from '../account/account-interface' |
5 | import { VideoInstance } from './video-interface' | 4 | import { VideoInstance } from './video-interface' |
6 | 5 | ||
7 | export namespace VideoShareMethods { | 6 | export namespace VideoShareMethods { |
8 | export type LoadAccountsByShare = (videoId: number, t: Transaction) => Bluebird<AccountInstance[]> | 7 | export type LoadAccountsByShare = (videoId: number, t: Sequelize.Transaction) => Bluebird<AccountInstance[]> |
9 | export type Load = (accountId: number, videoId: number, t: Transaction) => Bluebird<VideoShareInstance> | 8 | export type Load = (accountId: number, videoId: number, t: Sequelize.Transaction) => Bluebird<VideoShareInstance> |
10 | } | 9 | } |
11 | 10 | ||
12 | export interface VideoShareClass { | 11 | export interface VideoShareClass { |
diff --git a/server/tests/client.ts b/server/tests/client.ts index 0d70e3451..8c4334c53 100644 --- a/server/tests/client.ts +++ b/server/tests/client.ts | |||
@@ -41,8 +41,9 @@ describe('Test a client controllers', function () { | |||
41 | 41 | ||
42 | it('Should have valid Open Graph tags on the watch page with video id', async function () { | 42 | it('Should have valid Open Graph tags on the watch page with video id', async function () { |
43 | const res = await request(server.url) | 43 | const res = await request(server.url) |
44 | .get('/videos/watch/' + server.video.id) | 44 | .get('/videos/watch/' + server.video.id) |
45 | .expect(200) | 45 | .set('Accept', 'text/html') |
46 | .expect(200) | ||
46 | 47 | ||
47 | expect(res.text).to.contain('<meta property="og:title" content="my super name for server 1" />') | 48 | expect(res.text).to.contain('<meta property="og:title" content="my super name for server 1" />') |
48 | expect(res.text).to.contain('<meta property="og:description" content="my super description for server 1" />') | 49 | 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 () { | |||
50 | 51 | ||
51 | it('Should have valid Open Graph tags on the watch page with video uuid', async function () { | 52 | it('Should have valid Open Graph tags on the watch page with video uuid', async function () { |
52 | const res = await request(server.url) | 53 | const res = await request(server.url) |
53 | .get('/videos/watch/' + server.video.uuid) | 54 | .get('/videos/watch/' + server.video.uuid) |
54 | .expect(200) | 55 | .set('Accept', 'text/html') |
56 | .expect(200) | ||
55 | 57 | ||
56 | expect(res.text).to.contain('<meta property="og:title" content="my super name for server 1" />') | 58 | expect(res.text).to.contain('<meta property="og:title" content="my super name for server 1" />') |
57 | expect(res.text).to.contain('<meta property="og:description" content="my super description for server 1" />') | 59 | 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 () { | |||
61 | const path = '/videos/watch/' + server.video.uuid | 63 | const path = '/videos/watch/' + server.video.uuid |
62 | const res = await request(server.url) | 64 | const res = await request(server.url) |
63 | .get(path) | 65 | .get(path) |
66 | .set('Accept', 'text/html') | ||
64 | .expect(200) | 67 | .expect(200) |
65 | 68 | ||
66 | const expectedLink = '<link rel="alternate" type="application/json+oembed" href="http://localhost:9001/services/oembed?' + | 69 | 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.ts index a7dd0d824..755fb2604 100644 --- a/server/tests/index.ts +++ b/server/tests/index.ts | |||
@@ -1,4 +1,5 @@ | |||
1 | // Order of the tests we want to execute | 1 | // Order of the tests we want to execute |
2 | import './client' | 2 | import './client' |
3 | import './activitypub' | ||
3 | import './api/' | 4 | import './api/' |
4 | import './cli/' | 5 | import './cli/' |
diff --git a/server/tests/utils/index.ts b/server/tests/utils/index.ts index 4308fd49a..b918ee83d 100644 --- a/server/tests/utils/index.ts +++ b/server/tests/utils/index.ts | |||
@@ -1,3 +1,4 @@ | |||
1 | export * from './activitypub' | ||
1 | export * from './cli' | 2 | export * from './cli' |
2 | export * from './clients' | 3 | export * from './clients' |
3 | export * from './config' | 4 | export * from './config' |