diff options
author | Chocobozzz <me@florianbigard.com> | 2020-01-31 16:56:52 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-02-03 08:31:02 +0100 |
commit | a15871560f80e07386c1dabb8370cd2664ecfd1f (patch) | |
tree | 44440e140c9e43b0d7f97ade777a76e649e0553d /shared | |
parent | a22046d166805222ca76060e471b6cb3d419a32d (diff) | |
download | PeerTube-a15871560f80e07386c1dabb8370cd2664ecfd1f.tar.gz PeerTube-a15871560f80e07386c1dabb8370cd2664ecfd1f.tar.zst PeerTube-a15871560f80e07386c1dabb8370cd2664ecfd1f.zip |
Move to eslintcontain
Diffstat (limited to 'shared')
44 files changed, 333 insertions, 299 deletions
diff --git a/shared/core-utils/miscs/miscs.ts b/shared/core-utils/miscs/miscs.ts index 5de024c08..1eee22d82 100644 --- a/shared/core-utils/miscs/miscs.ts +++ b/shared/core-utils/miscs/miscs.ts | |||
@@ -11,7 +11,7 @@ function compareSemVer (a: string, b: string) { | |||
11 | const l = Math.min(segmentsA.length, segmentsB.length) | 11 | const l = Math.min(segmentsA.length, segmentsB.length) |
12 | 12 | ||
13 | for (let i = 0; i < l; i++) { | 13 | for (let i = 0; i < l; i++) { |
14 | const diff = parseInt(segmentsA[ i ], 10) - parseInt(segmentsB[ i ], 10) | 14 | const diff = parseInt(segmentsA[i], 10) - parseInt(segmentsB[i], 10) |
15 | 15 | ||
16 | if (diff) return diff | 16 | if (diff) return diff |
17 | } | 17 | } |
diff --git a/shared/extra-utils/instances-index/mock-instances-index.ts b/shared/extra-utils/instances-index/mock-instances-index.ts index cfa4523c1..c58e8bcf8 100644 --- a/shared/extra-utils/instances-index/mock-instances-index.ts +++ b/shared/extra-utils/instances-index/mock-instances-index.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | 2 | ||
3 | export class MockInstancesIndex { | 3 | export class MockInstancesIndex { |
4 | private indexInstances: { host: string, createdAt: string }[] = [] | 4 | private readonly indexInstances: { host: string, createdAt: string }[] = [] |
5 | 5 | ||
6 | initialize () { | 6 | initialize () { |
7 | return new Promise(res => { | 7 | return new Promise(res => { |
diff --git a/shared/extra-utils/miscs/miscs.ts b/shared/extra-utils/miscs/miscs.ts index d04003988..f4e86b85a 100644 --- a/shared/extra-utils/miscs/miscs.ts +++ b/shared/extra-utils/miscs/miscs.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import * as chai from 'chai' | 3 | import * as chai from 'chai' |
4 | import { basename, dirname, isAbsolute, join, resolve } from 'path' | 4 | import { basename, dirname, isAbsolute, join, resolve } from 'path' |
@@ -10,11 +10,11 @@ import * as ffmpeg from 'fluent-ffmpeg' | |||
10 | const expect = chai.expect | 10 | const expect = chai.expect |
11 | let webtorrent: WebTorrent.Instance | 11 | let webtorrent: WebTorrent.Instance |
12 | 12 | ||
13 | function immutableAssign <T, U> (target: T, source: U) { | 13 | function immutableAssign<T, U> (target: T, source: U) { |
14 | return Object.assign<{}, T, U>({}, target, source) | 14 | return Object.assign<{}, T, U>({}, target, source) |
15 | } | 15 | } |
16 | 16 | ||
17 | // Default interval -> 5 minutes | 17 | // Default interval -> 5 minutes |
18 | function dateIsValid (dateString: string, interval = 300000) { | 18 | function dateIsValid (dateString: string, interval = 300000) { |
19 | const dateToCheck = new Date(dateString) | 19 | const dateToCheck = new Date(dateString) |
20 | const now = new Date() | 20 | const now = new Date() |
@@ -89,7 +89,7 @@ async function generateHighBitrateVideo () { | |||
89 | // a large file in the repo. The video needs to have a certain minimum length so | 89 | // a large file in the repo. The video needs to have a certain minimum length so |
90 | // that FFmpeg properly applies bitrate limits. | 90 | // that FFmpeg properly applies bitrate limits. |
91 | // https://stackoverflow.com/a/15795112 | 91 | // https://stackoverflow.com/a/15795112 |
92 | return new Promise<string>(async (res, rej) => { | 92 | return new Promise<string>((res, rej) => { |
93 | ffmpeg() | 93 | ffmpeg() |
94 | .outputOptions([ '-f rawvideo', '-video_size 1920x1080', '-i /dev/urandom' ]) | 94 | .outputOptions([ '-f rawvideo', '-video_size 1920x1080', '-i /dev/urandom' ]) |
95 | .outputOptions([ '-ac 2', '-f s16le', '-i /dev/urandom', '-t 10' ]) | 95 | .outputOptions([ '-ac 2', '-f s16le', '-i /dev/urandom', '-t 10' ]) |
@@ -111,7 +111,7 @@ async function generateVideoWithFramerate (fps = 60) { | |||
111 | 111 | ||
112 | const exists = await pathExists(tempFixturePath) | 112 | const exists = await pathExists(tempFixturePath) |
113 | if (!exists) { | 113 | if (!exists) { |
114 | return new Promise<string>(async (res, rej) => { | 114 | return new Promise<string>((res, rej) => { |
115 | ffmpeg() | 115 | ffmpeg() |
116 | .outputOptions([ '-f rawvideo', '-video_size 1280x720', '-i /dev/urandom' ]) | 116 | .outputOptions([ '-f rawvideo', '-video_size 1280x720', '-i /dev/urandom' ]) |
117 | .outputOptions([ '-ac 2', '-f s16le', '-i /dev/urandom', '-t 10' ]) | 117 | .outputOptions([ '-ac 2', '-f s16le', '-i /dev/urandom', '-t 10' ]) |
diff --git a/shared/extra-utils/miscs/sql.ts b/shared/extra-utils/miscs/sql.ts index 42599c20e..5bd5d5d8a 100644 --- a/shared/extra-utils/miscs/sql.ts +++ b/shared/extra-utils/miscs/sql.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import { QueryTypes, Sequelize } from 'sequelize' | 1 | import { QueryTypes, Sequelize } from 'sequelize' |
2 | import { ServerInfo } from '../server/servers' | 2 | import { ServerInfo } from '../server/servers' |
3 | 3 | ||
4 | let sequelizes: { [ id: number ]: Sequelize } = {} | 4 | const sequelizes: { [ id: number ]: Sequelize } = {} |
5 | 5 | ||
6 | function getSequelize (internalServerNumber: number) { | 6 | function getSequelize (internalServerNumber: number) { |
7 | if (sequelizes[internalServerNumber]) return sequelizes[internalServerNumber] | 7 | if (sequelizes[internalServerNumber]) return sequelizes[internalServerNumber] |
@@ -52,7 +52,8 @@ async function countVideoViewsOf (internalServerNumber: number, uuid: string) { | |||
52 | const seq = getSequelize(internalServerNumber) | 52 | const seq = getSequelize(internalServerNumber) |
53 | 53 | ||
54 | // tslint:disable | 54 | // tslint:disable |
55 | const query = `SELECT SUM("videoView"."views") AS "total" FROM "videoView" INNER JOIN "video" ON "video"."id" = "videoView"."videoId" WHERE "video"."uuid" = '${uuid}'` | 55 | const query = 'SELECT SUM("videoView"."views") AS "total" FROM "videoView" ' + |
56 | `INNER JOIN "video" ON "video"."id" = "videoView"."videoId" WHERE "video"."uuid" = '${uuid}'` | ||
56 | 57 | ||
57 | const options = { type: QueryTypes.SELECT as QueryTypes.SELECT } | 58 | const options = { type: QueryTypes.SELECT as QueryTypes.SELECT } |
58 | const [ { total } ] = await seq.query<{ total: number }>(query, options) | 59 | const [ { total } ] = await seq.query<{ total: number }>(query, options) |
@@ -64,9 +65,10 @@ async function countVideoViewsOf (internalServerNumber: number, uuid: string) { | |||
64 | 65 | ||
65 | async function closeAllSequelize (servers: ServerInfo[]) { | 66 | async function closeAllSequelize (servers: ServerInfo[]) { |
66 | for (const server of servers) { | 67 | for (const server of servers) { |
67 | if (sequelizes[ server.internalServerNumber ]) { | 68 | if (sequelizes[server.internalServerNumber]) { |
68 | await sequelizes[ server.internalServerNumber ].close() | 69 | await sequelizes[server.internalServerNumber].close() |
69 | delete sequelizes[ server.internalServerNumber ] | 70 | // eslint-disable-next-line |
71 | delete sequelizes[server.internalServerNumber] | ||
70 | } | 72 | } |
71 | } | 73 | } |
72 | } | 74 | } |
diff --git a/shared/extra-utils/requests/requests.ts b/shared/extra-utils/requests/requests.ts index 3532fb429..61167f212 100644 --- a/shared/extra-utils/requests/requests.ts +++ b/shared/extra-utils/requests/requests.ts | |||
@@ -1,25 +1,27 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/no-floating-promises */ | ||
2 | |||
1 | import * as request from 'supertest' | 3 | import * as request from 'supertest' |
2 | import { buildAbsoluteFixturePath, root } from '../miscs/miscs' | 4 | import { buildAbsoluteFixturePath, root } from '../miscs/miscs' |
3 | import { isAbsolute, join } from 'path' | 5 | import { isAbsolute, join } from 'path' |
4 | import { parse } from 'url' | 6 | import { URL } from 'url' |
5 | 7 | ||
6 | function get4KFileUrl () { | 8 | function get4KFileUrl () { |
7 | return 'https://download.cpy.re/peertube/4k_file.txt' | 9 | return 'https://download.cpy.re/peertube/4k_file.txt' |
8 | } | 10 | } |
9 | 11 | ||
10 | function makeRawRequest (url: string, statusCodeExpected?: number, range?: string) { | 12 | function makeRawRequest (url: string, statusCodeExpected?: number, range?: string) { |
11 | const { host, protocol, pathname } = parse(url) | 13 | const { host, protocol, pathname } = new URL(url) |
12 | 14 | ||
13 | return makeGetRequest({ url: `${protocol}//${host}`, path: pathname, statusCodeExpected, range }) | 15 | return makeGetRequest({ url: `${protocol}//${host}`, path: pathname, statusCodeExpected, range }) |
14 | } | 16 | } |
15 | 17 | ||
16 | function makeGetRequest (options: { | 18 | function makeGetRequest (options: { |
17 | url: string, | 19 | url: string |
18 | path?: string, | 20 | path?: string |
19 | query?: any, | 21 | query?: any |
20 | token?: string, | 22 | token?: string |
21 | statusCodeExpected?: number, | 23 | statusCodeExpected?: number |
22 | contentType?: string, | 24 | contentType?: string |
23 | range?: string | 25 | range?: string |
24 | }) { | 26 | }) { |
25 | if (!options.statusCodeExpected) options.statusCodeExpected = 400 | 27 | if (!options.statusCodeExpected) options.statusCodeExpected = 400 |
@@ -36,9 +38,9 @@ function makeGetRequest (options: { | |||
36 | } | 38 | } |
37 | 39 | ||
38 | function makeDeleteRequest (options: { | 40 | function makeDeleteRequest (options: { |
39 | url: string, | 41 | url: string |
40 | path: string, | 42 | path: string |
41 | token?: string, | 43 | token?: string |
42 | statusCodeExpected?: number | 44 | statusCodeExpected?: number |
43 | }) { | 45 | }) { |
44 | if (!options.statusCodeExpected) options.statusCodeExpected = 400 | 46 | if (!options.statusCodeExpected) options.statusCodeExpected = 400 |
@@ -53,12 +55,12 @@ function makeDeleteRequest (options: { | |||
53 | } | 55 | } |
54 | 56 | ||
55 | function makeUploadRequest (options: { | 57 | function makeUploadRequest (options: { |
56 | url: string, | 58 | url: string |
57 | method?: 'POST' | 'PUT', | 59 | method?: 'POST' | 'PUT' |
58 | path: string, | 60 | path: string |
59 | token?: string, | 61 | token?: string |
60 | fields: { [ fieldName: string ]: any }, | 62 | fields: { [ fieldName: string ]: any } |
61 | attaches: { [ attachName: string ]: any | any[] }, | 63 | attaches: { [ attachName: string ]: any | any[] } |
62 | statusCodeExpected?: number | 64 | statusCodeExpected?: number |
63 | }) { | 65 | }) { |
64 | if (!options.statusCodeExpected) options.statusCodeExpected = 400 | 66 | if (!options.statusCodeExpected) options.statusCodeExpected = 400 |
@@ -101,10 +103,10 @@ function makeUploadRequest (options: { | |||
101 | } | 103 | } |
102 | 104 | ||
103 | function makePostBodyRequest (options: { | 105 | function makePostBodyRequest (options: { |
104 | url: string, | 106 | url: string |
105 | path: string, | 107 | path: string |
106 | token?: string, | 108 | token?: string |
107 | fields?: { [ fieldName: string ]: any }, | 109 | fields?: { [ fieldName: string ]: any } |
108 | statusCodeExpected?: number | 110 | statusCodeExpected?: number |
109 | }) { | 111 | }) { |
110 | if (!options.fields) options.fields = {} | 112 | if (!options.fields) options.fields = {} |
@@ -121,10 +123,10 @@ function makePostBodyRequest (options: { | |||
121 | } | 123 | } |
122 | 124 | ||
123 | function makePutBodyRequest (options: { | 125 | function makePutBodyRequest (options: { |
124 | url: string, | 126 | url: string |
125 | path: string, | 127 | path: string |
126 | token?: string, | 128 | token?: string |
127 | fields: { [ fieldName: string ]: any }, | 129 | fields: { [ fieldName: string ]: any } |
128 | statusCodeExpected?: number | 130 | statusCodeExpected?: number |
129 | }) { | 131 | }) { |
130 | if (!options.statusCodeExpected) options.statusCodeExpected = 400 | 132 | if (!options.statusCodeExpected) options.statusCodeExpected = 400 |
@@ -147,9 +149,9 @@ function makeHTMLRequest (url: string, path: string) { | |||
147 | } | 149 | } |
148 | 150 | ||
149 | function updateAvatarRequest (options: { | 151 | function updateAvatarRequest (options: { |
150 | url: string, | 152 | url: string |
151 | path: string, | 153 | path: string |
152 | accessToken: string, | 154 | accessToken: string |
153 | fixture: string | 155 | fixture: string |
154 | }) { | 156 | }) { |
155 | let filePath = '' | 157 | let filePath = '' |
diff --git a/shared/extra-utils/search/videos.ts b/shared/extra-utils/search/videos.ts index da806e692..4c52ea11c 100644 --- a/shared/extra-utils/search/videos.ts +++ b/shared/extra-utils/search/videos.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import * as request from 'supertest' | 3 | import * as request from 'supertest' |
4 | import { VideosSearchQuery } from '../../models/search' | 4 | import { VideosSearchQuery } from '../../models/search' |
diff --git a/shared/extra-utils/server/clients.ts b/shared/extra-utils/server/clients.ts index 273aac747..dc631e823 100644 --- a/shared/extra-utils/server/clients.ts +++ b/shared/extra-utils/server/clients.ts | |||
@@ -1,12 +1,12 @@ | |||
1 | import * as request from 'supertest' | 1 | import * as request from 'supertest' |
2 | import * as urlUtil from 'url' | 2 | import { URL } from 'url' |
3 | 3 | ||
4 | function getClient (url: string) { | 4 | function getClient (url: string) { |
5 | const path = '/api/v1/oauth-clients/local' | 5 | const path = '/api/v1/oauth-clients/local' |
6 | 6 | ||
7 | return request(url) | 7 | return request(url) |
8 | .get(path) | 8 | .get(path) |
9 | .set('Host', urlUtil.parse(url).host) | 9 | .set('Host', new URL(url).host) |
10 | .set('Accept', 'application/json') | 10 | .set('Accept', 'application/json') |
11 | .expect(200) | 11 | .expect(200) |
12 | .expect('Content-Type', /json/) | 12 | .expect('Content-Type', /json/) |
diff --git a/shared/extra-utils/server/contact-form.ts b/shared/extra-utils/server/contact-form.ts index e002e03dd..d50f83241 100644 --- a/shared/extra-utils/server/contact-form.ts +++ b/shared/extra-utils/server/contact-form.ts | |||
@@ -2,11 +2,11 @@ import * as request from 'supertest' | |||
2 | import { ContactForm } from '../../models/server' | 2 | import { ContactForm } from '../../models/server' |
3 | 3 | ||
4 | function sendContactForm (options: { | 4 | function sendContactForm (options: { |
5 | url: string, | 5 | url: string |
6 | fromEmail: string, | 6 | fromEmail: string |
7 | fromName: string, | 7 | fromName: string |
8 | subject: string, | 8 | subject: string |
9 | body: string, | 9 | body: string |
10 | expectedStatus?: number | 10 | expectedStatus?: number |
11 | }) { | 11 | }) { |
12 | const path = '/api/v1/server/contact' | 12 | const path = '/api/v1/server/contact' |
diff --git a/shared/extra-utils/server/follows.ts b/shared/extra-utils/server/follows.ts index 3f7729c20..006d59199 100644 --- a/shared/extra-utils/server/follows.ts +++ b/shared/extra-utils/server/follows.ts | |||
@@ -5,12 +5,12 @@ import { makePostBodyRequest } from '../requests/requests' | |||
5 | import { ActivityPubActorType, FollowState } from '@shared/models' | 5 | import { ActivityPubActorType, FollowState } from '@shared/models' |
6 | 6 | ||
7 | function getFollowersListPaginationAndSort (options: { | 7 | function getFollowersListPaginationAndSort (options: { |
8 | url: string, | 8 | url: string |
9 | start: number, | 9 | start: number |
10 | count: number, | 10 | count: number |
11 | sort: string, | 11 | sort: string |
12 | search?: string, | 12 | search?: string |
13 | actorType?: ActivityPubActorType, | 13 | actorType?: ActivityPubActorType |
14 | state?: FollowState | 14 | state?: FollowState |
15 | }) { | 15 | }) { |
16 | const { url, start, count, sort, search, state, actorType } = options | 16 | const { url, start, count, sort, search, state, actorType } = options |
@@ -56,12 +56,12 @@ function rejectFollower (url: string, token: string, follower: string, statusCod | |||
56 | } | 56 | } |
57 | 57 | ||
58 | function getFollowingListPaginationAndSort (options: { | 58 | function getFollowingListPaginationAndSort (options: { |
59 | url: string, | 59 | url: string |
60 | start: number, | 60 | start: number |
61 | count: number, | 61 | count: number |
62 | sort: string, | 62 | sort: string |
63 | search?: string, | 63 | search?: string |
64 | actorType?: ActivityPubActorType, | 64 | actorType?: ActivityPubActorType |
65 | state?: FollowState | 65 | state?: FollowState |
66 | }) { | 66 | }) { |
67 | const { url, start, count, sort, search, state, actorType } = options | 67 | const { url, start, count, sort, search, state, actorType } = options |
@@ -92,7 +92,7 @@ function follow (follower: string, following: string[], accessToken: string, exp | |||
92 | .post(path) | 92 | .post(path) |
93 | .set('Accept', 'application/json') | 93 | .set('Accept', 'application/json') |
94 | .set('Authorization', 'Bearer ' + accessToken) | 94 | .set('Authorization', 'Bearer ' + accessToken) |
95 | .send({ 'hosts': followingHosts }) | 95 | .send({ hosts: followingHosts }) |
96 | .expect(expectedStatus) | 96 | .expect(expectedStatus) |
97 | } | 97 | } |
98 | 98 | ||
diff --git a/shared/extra-utils/server/jobs.ts b/shared/extra-utils/server/jobs.ts index 56fe5fa2a..d984b3d1e 100644 --- a/shared/extra-utils/server/jobs.ts +++ b/shared/extra-utils/server/jobs.ts | |||
@@ -8,20 +8,20 @@ function getJobsList (url: string, accessToken: string, state: JobState) { | |||
8 | const path = '/api/v1/jobs/' + state | 8 | const path = '/api/v1/jobs/' + state |
9 | 9 | ||
10 | return request(url) | 10 | return request(url) |
11 | .get(path) | 11 | .get(path) |
12 | .set('Accept', 'application/json') | 12 | .set('Accept', 'application/json') |
13 | .set('Authorization', 'Bearer ' + accessToken) | 13 | .set('Authorization', 'Bearer ' + accessToken) |
14 | .expect(200) | 14 | .expect(200) |
15 | .expect('Content-Type', /json/) | 15 | .expect('Content-Type', /json/) |
16 | } | 16 | } |
17 | 17 | ||
18 | function getJobsListPaginationAndSort (options: { | 18 | function getJobsListPaginationAndSort (options: { |
19 | url: string, | 19 | url: string |
20 | accessToken: string, | 20 | accessToken: string |
21 | state: JobState, | 21 | state: JobState |
22 | start: number, | 22 | start: number |
23 | count: number, | 23 | count: number |
24 | sort: string, | 24 | sort: string |
25 | jobType?: JobType | 25 | jobType?: JobType |
26 | }) { | 26 | }) { |
27 | const { url, accessToken, state, start, count, sort, jobType } = options | 27 | const { url, accessToken, state, start, count, sort, jobType } = options |
diff --git a/shared/extra-utils/server/plugins.ts b/shared/extra-utils/server/plugins.ts index 5c0d1e511..2d02d823d 100644 --- a/shared/extra-utils/server/plugins.ts +++ b/shared/extra-utils/server/plugins.ts | |||
@@ -7,13 +7,13 @@ import { root } from '../miscs/miscs' | |||
7 | import { join } from 'path' | 7 | import { join } from 'path' |
8 | 8 | ||
9 | function listPlugins (parameters: { | 9 | function listPlugins (parameters: { |
10 | url: string, | 10 | url: string |
11 | accessToken: string, | 11 | accessToken: string |
12 | start?: number, | 12 | start?: number |
13 | count?: number, | 13 | count?: number |
14 | sort?: string, | 14 | sort?: string |
15 | pluginType?: PluginType, | 15 | pluginType?: PluginType |
16 | uninstalled?: boolean, | 16 | uninstalled?: boolean |
17 | expectedStatus?: number | 17 | expectedStatus?: number |
18 | }) { | 18 | }) { |
19 | const { url, accessToken, start, count, sort, pluginType, uninstalled, expectedStatus = 200 } = parameters | 19 | const { url, accessToken, start, count, sort, pluginType, uninstalled, expectedStatus = 200 } = parameters |
@@ -35,13 +35,13 @@ function listPlugins (parameters: { | |||
35 | } | 35 | } |
36 | 36 | ||
37 | function listAvailablePlugins (parameters: { | 37 | function listAvailablePlugins (parameters: { |
38 | url: string, | 38 | url: string |
39 | accessToken: string, | 39 | accessToken: string |
40 | start?: number, | 40 | start?: number |
41 | count?: number, | 41 | count?: number |
42 | sort?: string, | 42 | sort?: string |
43 | pluginType?: PluginType, | 43 | pluginType?: PluginType |
44 | currentPeerTubeEngine?: string, | 44 | currentPeerTubeEngine?: string |
45 | search?: string | 45 | search?: string |
46 | expectedStatus?: number | 46 | expectedStatus?: number |
47 | }) { | 47 | }) { |
@@ -67,9 +67,9 @@ function listAvailablePlugins (parameters: { | |||
67 | } | 67 | } |
68 | 68 | ||
69 | function getPlugin (parameters: { | 69 | function getPlugin (parameters: { |
70 | url: string, | 70 | url: string |
71 | accessToken: string, | 71 | accessToken: string |
72 | npmName: string, | 72 | npmName: string |
73 | expectedStatus?: number | 73 | expectedStatus?: number |
74 | }) { | 74 | }) { |
75 | const { url, accessToken, npmName, expectedStatus = 200 } = parameters | 75 | const { url, accessToken, npmName, expectedStatus = 200 } = parameters |
@@ -84,10 +84,10 @@ function getPlugin (parameters: { | |||
84 | } | 84 | } |
85 | 85 | ||
86 | function updatePluginSettings (parameters: { | 86 | function updatePluginSettings (parameters: { |
87 | url: string, | 87 | url: string |
88 | accessToken: string, | 88 | accessToken: string |
89 | npmName: string, | 89 | npmName: string |
90 | settings: any, | 90 | settings: any |
91 | expectedStatus?: number | 91 | expectedStatus?: number |
92 | }) { | 92 | }) { |
93 | const { url, accessToken, npmName, settings, expectedStatus = 204 } = parameters | 93 | const { url, accessToken, npmName, settings, expectedStatus = 204 } = parameters |
@@ -103,9 +103,9 @@ function updatePluginSettings (parameters: { | |||
103 | } | 103 | } |
104 | 104 | ||
105 | function getPluginRegisteredSettings (parameters: { | 105 | function getPluginRegisteredSettings (parameters: { |
106 | url: string, | 106 | url: string |
107 | accessToken: string, | 107 | accessToken: string |
108 | npmName: string, | 108 | npmName: string |
109 | expectedStatus?: number | 109 | expectedStatus?: number |
110 | }) { | 110 | }) { |
111 | const { url, accessToken, npmName, expectedStatus = 200 } = parameters | 111 | const { url, accessToken, npmName, expectedStatus = 200 } = parameters |
@@ -120,8 +120,8 @@ function getPluginRegisteredSettings (parameters: { | |||
120 | } | 120 | } |
121 | 121 | ||
122 | function getPublicSettings (parameters: { | 122 | function getPublicSettings (parameters: { |
123 | url: string, | 123 | url: string |
124 | npmName: string, | 124 | npmName: string |
125 | expectedStatus?: number | 125 | expectedStatus?: number |
126 | }) { | 126 | }) { |
127 | const { url, npmName, expectedStatus = 200 } = parameters | 127 | const { url, npmName, expectedStatus = 200 } = parameters |
@@ -135,8 +135,8 @@ function getPublicSettings (parameters: { | |||
135 | } | 135 | } |
136 | 136 | ||
137 | function getPluginTranslations (parameters: { | 137 | function getPluginTranslations (parameters: { |
138 | url: string, | 138 | url: string |
139 | locale: string, | 139 | locale: string |
140 | expectedStatus?: number | 140 | expectedStatus?: number |
141 | }) { | 141 | }) { |
142 | const { url, locale, expectedStatus = 200 } = parameters | 142 | const { url, locale, expectedStatus = 200 } = parameters |
@@ -150,9 +150,9 @@ function getPluginTranslations (parameters: { | |||
150 | } | 150 | } |
151 | 151 | ||
152 | function installPlugin (parameters: { | 152 | function installPlugin (parameters: { |
153 | url: string, | 153 | url: string |
154 | accessToken: string, | 154 | accessToken: string |
155 | path?: string, | 155 | path?: string |
156 | npmName?: string | 156 | npmName?: string |
157 | expectedStatus?: number | 157 | expectedStatus?: number |
158 | }) { | 158 | }) { |
@@ -169,9 +169,9 @@ function installPlugin (parameters: { | |||
169 | } | 169 | } |
170 | 170 | ||
171 | function updatePlugin (parameters: { | 171 | function updatePlugin (parameters: { |
172 | url: string, | 172 | url: string |
173 | accessToken: string, | 173 | accessToken: string |
174 | path?: string, | 174 | path?: string |
175 | npmName?: string | 175 | npmName?: string |
176 | expectedStatus?: number | 176 | expectedStatus?: number |
177 | }) { | 177 | }) { |
@@ -188,8 +188,8 @@ function updatePlugin (parameters: { | |||
188 | } | 188 | } |
189 | 189 | ||
190 | function uninstallPlugin (parameters: { | 190 | function uninstallPlugin (parameters: { |
191 | url: string, | 191 | url: string |
192 | accessToken: string, | 192 | accessToken: string |
193 | npmName: string | 193 | npmName: string |
194 | expectedStatus?: number | 194 | expectedStatus?: number |
195 | }) { | 195 | }) { |
diff --git a/shared/extra-utils/server/redundancy.ts b/shared/extra-utils/server/redundancy.ts index 7b488e23e..08467e4c0 100644 --- a/shared/extra-utils/server/redundancy.ts +++ b/shared/extra-utils/server/redundancy.ts | |||
@@ -15,11 +15,11 @@ function updateRedundancy (url: string, accessToken: string, host: string, redun | |||
15 | 15 | ||
16 | function listVideoRedundancies (options: { | 16 | function listVideoRedundancies (options: { |
17 | url: string | 17 | url: string |
18 | accessToken: string, | 18 | accessToken: string |
19 | target: VideoRedundanciesTarget, | 19 | target: VideoRedundanciesTarget |
20 | start?: number, | 20 | start?: number |
21 | count?: number, | 21 | count?: number |
22 | sort?: string, | 22 | sort?: string |
23 | statusCodeExpected?: number | 23 | statusCodeExpected?: number |
24 | }) { | 24 | }) { |
25 | const path = '/api/v1/server/redundancy/videos' | 25 | const path = '/api/v1/server/redundancy/videos' |
@@ -41,8 +41,8 @@ function listVideoRedundancies (options: { | |||
41 | } | 41 | } |
42 | 42 | ||
43 | function addVideoRedundancy (options: { | 43 | function addVideoRedundancy (options: { |
44 | url: string, | 44 | url: string |
45 | accessToken: string, | 45 | accessToken: string |
46 | videoId: number | 46 | videoId: number |
47 | }) { | 47 | }) { |
48 | const path = '/api/v1/server/redundancy/videos' | 48 | const path = '/api/v1/server/redundancy/videos' |
@@ -58,8 +58,8 @@ function addVideoRedundancy (options: { | |||
58 | } | 58 | } |
59 | 59 | ||
60 | function removeVideoRedundancy (options: { | 60 | function removeVideoRedundancy (options: { |
61 | url: string, | 61 | url: string |
62 | accessToken: string, | 62 | accessToken: string |
63 | redundancyId: number | 63 | redundancyId: number |
64 | }) { | 64 | }) { |
65 | const { url, accessToken, redundancyId } = options | 65 | const { url, accessToken, redundancyId } = options |
diff --git a/shared/extra-utils/server/servers.ts b/shared/extra-utils/server/servers.ts index a0720d778..a0f0ce9c9 100644 --- a/shared/extra-utils/server/servers.ts +++ b/shared/extra-utils/server/servers.ts | |||
@@ -1,16 +1,15 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/no-floating-promises */ |
2 | 2 | ||
3 | import { ChildProcess, exec, fork } from 'child_process' | 3 | import { ChildProcess, exec, fork } from 'child_process' |
4 | import { join } from 'path' | 4 | import { join } from 'path' |
5 | import { root, wait } from '../miscs/miscs' | 5 | import { root, wait } from '../miscs/miscs' |
6 | import { copy, pathExists, readdir, readFile, remove } from 'fs-extra' | 6 | import { copy, pathExists, readdir, readFile, remove } from 'fs-extra' |
7 | import { existsSync } from 'fs' | ||
8 | import { expect } from 'chai' | 7 | import { expect } from 'chai' |
9 | import { VideoChannel } from '../../models/videos' | 8 | import { VideoChannel } from '../../models/videos' |
10 | import { randomInt } from '../../core-utils/miscs/miscs' | 9 | import { randomInt } from '../../core-utils/miscs/miscs' |
11 | 10 | ||
12 | interface ServerInfo { | 11 | interface ServerInfo { |
13 | app: ChildProcess, | 12 | app: ChildProcess |
14 | url: string | 13 | url: string |
15 | host: string | 14 | host: string |
16 | 15 | ||
@@ -20,13 +19,13 @@ interface ServerInfo { | |||
20 | serverNumber: number | 19 | serverNumber: number |
21 | 20 | ||
22 | client: { | 21 | client: { |
23 | id: string, | 22 | id: string |
24 | secret: string | 23 | secret: string |
25 | } | 24 | } |
26 | 25 | ||
27 | user: { | 26 | user: { |
28 | username: string, | 27 | username: string |
29 | password: string, | 28 | password: string |
30 | email?: string | 29 | email?: string |
31 | } | 30 | } |
32 | 31 | ||
@@ -57,7 +56,7 @@ function parallelTests () { | |||
57 | } | 56 | } |
58 | 57 | ||
59 | function flushAndRunMultipleServers (totalServers: number, configOverride?: Object) { | 58 | function flushAndRunMultipleServers (totalServers: number, configOverride?: Object) { |
60 | let apps = [] | 59 | const apps = [] |
61 | let i = 0 | 60 | let i = 0 |
62 | 61 | ||
63 | return new Promise<ServerInfo[]>(res => { | 62 | return new Promise<ServerInfo[]>(res => { |
@@ -203,20 +202,20 @@ async function runServer (server: ServerInfo, configOverrideArg?: any, args = [] | |||
203 | 202 | ||
204 | // Capture things if we want to | 203 | // Capture things if we want to |
205 | for (const key of Object.keys(regexps)) { | 204 | for (const key of Object.keys(regexps)) { |
206 | const regexp = regexps[ key ] | 205 | const regexp = regexps[key] |
207 | const matches = data.toString().match(regexp) | 206 | const matches = data.toString().match(regexp) |
208 | if (matches !== null) { | 207 | if (matches !== null) { |
209 | if (key === 'client_id') server.client.id = matches[ 1 ] | 208 | if (key === 'client_id') server.client.id = matches[1] |
210 | else if (key === 'client_secret') server.client.secret = matches[ 1 ] | 209 | else if (key === 'client_secret') server.client.secret = matches[1] |
211 | else if (key === 'user_username') server.user.username = matches[ 1 ] | 210 | else if (key === 'user_username') server.user.username = matches[1] |
212 | else if (key === 'user_password') server.user.password = matches[ 1 ] | 211 | else if (key === 'user_password') server.user.password = matches[1] |
213 | } | 212 | } |
214 | } | 213 | } |
215 | 214 | ||
216 | // Check if all required sentences are here | 215 | // Check if all required sentences are here |
217 | for (const key of Object.keys(serverRunString)) { | 216 | for (const key of Object.keys(serverRunString)) { |
218 | if (data.toString().indexOf(key) !== -1) serverRunString[ key ] = true | 217 | if (data.toString().indexOf(key) !== -1) serverRunString[key] = true |
219 | if (serverRunString[ key ] === false) dontContinue = true | 218 | if (serverRunString[key] === false) dontContinue = true |
220 | } | 219 | } |
221 | 220 | ||
222 | // If no, there is maybe one thing not already initialized (client/user credentials generation...) | 221 | // If no, there is maybe one thing not already initialized (client/user credentials generation...) |
diff --git a/shared/extra-utils/users/accounts.ts b/shared/extra-utils/users/accounts.ts index 627e17cc3..f87706f6a 100644 --- a/shared/extra-utils/users/accounts.ts +++ b/shared/extra-utils/users/accounts.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import * as request from 'supertest' | 3 | import * as request from 'supertest' |
4 | import { expect } from 'chai' | 4 | import { expect } from 'chai' |
diff --git a/shared/extra-utils/users/blocklist.ts b/shared/extra-utils/users/blocklist.ts index 5feb84179..39e720b42 100644 --- a/shared/extra-utils/users/blocklist.ts +++ b/shared/extra-utils/users/blocklist.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import { makeGetRequest, makeDeleteRequest, makePostBodyRequest } from '../requests/requests' | 3 | import { makeGetRequest, makeDeleteRequest, makePostBodyRequest } from '../requests/requests' |
4 | 4 | ||
diff --git a/shared/extra-utils/users/login.ts b/shared/extra-utils/users/login.ts index f9bfb3cb3..4fe54a74a 100644 --- a/shared/extra-utils/users/login.ts +++ b/shared/extra-utils/users/login.ts | |||
@@ -60,7 +60,7 @@ function setAccessTokensToServers (servers: ServerInfo[]) { | |||
60 | const tasks: Promise<any>[] = [] | 60 | const tasks: Promise<any>[] = [] |
61 | 61 | ||
62 | for (const server of servers) { | 62 | for (const server of servers) { |
63 | const p = serverLogin(server).then(t => server.accessToken = t) | 63 | const p = serverLogin(server).then(t => { server.accessToken = t }) |
64 | tasks.push(p) | 64 | tasks.push(p) |
65 | } | 65 | } |
66 | 66 | ||
diff --git a/shared/extra-utils/users/user-notifications.ts b/shared/extra-utils/users/user-notifications.ts index 9a5fd7e86..f949878e4 100644 --- a/shared/extra-utils/users/user-notifications.ts +++ b/shared/extra-utils/users/user-notifications.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import { makeGetRequest, makePostBodyRequest, makePutBodyRequest } from '../requests/requests' | 3 | import { makeGetRequest, makePostBodyRequest, makePutBodyRequest } from '../requests/requests' |
4 | import { UserNotification, UserNotificationSetting, UserNotificationType } from '../../models/users' | 4 | import { UserNotification, UserNotificationSetting, UserNotificationType } from '../../models/users' |
@@ -54,6 +54,7 @@ function markAsReadNotifications (url: string, token: string, ids: number[], sta | |||
54 | statusCodeExpected | 54 | statusCodeExpected |
55 | }) | 55 | }) |
56 | } | 56 | } |
57 | |||
57 | function markAsReadAllNotifications (url: string, token: string, statusCodeExpected = 204) { | 58 | function markAsReadAllNotifications (url: string, token: string, statusCodeExpected = 204) { |
58 | const path = '/api/v1/users/me/notifications/read-all' | 59 | const path = '/api/v1/users/me/notifications/read-all' |
59 | 60 | ||
@@ -77,7 +78,7 @@ type CheckerBaseParams = { | |||
77 | server: ServerInfo | 78 | server: ServerInfo |
78 | emails: object[] | 79 | emails: object[] |
79 | socketNotifications: UserNotification[] | 80 | socketNotifications: UserNotification[] |
80 | token: string, | 81 | token: string |
81 | check?: { web: boolean, mail: boolean } | 82 | check?: { web: boolean, mail: boolean } |
82 | } | 83 | } |
83 | 84 | ||
@@ -172,7 +173,7 @@ async function checkNewVideoFromSubscription (base: CheckerBaseParams, videoName | |||
172 | } | 173 | } |
173 | 174 | ||
174 | function emailFinder (email: object) { | 175 | function emailFinder (email: object) { |
175 | const text = email[ 'text' ] | 176 | const text = email['text'] |
176 | return text.indexOf(videoUUID) !== -1 && text.indexOf('Your subscription') !== -1 | 177 | return text.indexOf(videoUUID) !== -1 && text.indexOf('Your subscription') !== -1 |
177 | } | 178 | } |
178 | 179 | ||
@@ -195,7 +196,7 @@ async function checkVideoIsPublished (base: CheckerBaseParams, videoName: string | |||
195 | } | 196 | } |
196 | 197 | ||
197 | function emailFinder (email: object) { | 198 | function emailFinder (email: object) { |
198 | const text: string = email[ 'text' ] | 199 | const text: string = email['text'] |
199 | return text.includes(videoUUID) && text.includes('Your video') | 200 | return text.includes(videoUUID) && text.includes('Your video') |
200 | } | 201 | } |
201 | 202 | ||
@@ -226,7 +227,7 @@ async function checkMyVideoImportIsFinished ( | |||
226 | } | 227 | } |
227 | 228 | ||
228 | function emailFinder (email: object) { | 229 | function emailFinder (email: object) { |
229 | const text: string = email[ 'text' ] | 230 | const text: string = email['text'] |
230 | const toFind = success ? ' finished' : ' error' | 231 | const toFind = success ? ' finished' : ' error' |
231 | 232 | ||
232 | return text.includes(url) && text.includes(toFind) | 233 | return text.includes(url) && text.includes(toFind) |
@@ -251,7 +252,7 @@ async function checkUserRegistered (base: CheckerBaseParams, username: string, t | |||
251 | } | 252 | } |
252 | 253 | ||
253 | function emailFinder (email: object) { | 254 | function emailFinder (email: object) { |
254 | const text: string = email[ 'text' ] | 255 | const text: string = email['text'] |
255 | 256 | ||
256 | return text.includes(' registered ') && text.includes(username) | 257 | return text.includes(' registered ') && text.includes(username) |
257 | } | 258 | } |
@@ -291,7 +292,7 @@ async function checkNewActorFollow ( | |||
291 | } | 292 | } |
292 | 293 | ||
293 | function emailFinder (email: object) { | 294 | function emailFinder (email: object) { |
294 | const text: string = email[ 'text' ] | 295 | const text: string = email['text'] |
295 | 296 | ||
296 | return text.includes('Your ' + followType) && text.includes(followingDisplayName) && text.includes(followerDisplayName) | 297 | return text.includes('Your ' + followType) && text.includes(followingDisplayName) && text.includes(followerDisplayName) |
297 | } | 298 | } |
@@ -320,7 +321,7 @@ async function checkNewInstanceFollower (base: CheckerBaseParams, followerHost: | |||
320 | } | 321 | } |
321 | 322 | ||
322 | function emailFinder (email: object) { | 323 | function emailFinder (email: object) { |
323 | const text: string = email[ 'text' ] | 324 | const text: string = email['text'] |
324 | 325 | ||
325 | return text.includes('instance has a new follower') && text.includes(followerHost) | 326 | return text.includes('instance has a new follower') && text.includes(followerHost) |
326 | } | 327 | } |
@@ -351,7 +352,7 @@ async function checkAutoInstanceFollowing (base: CheckerBaseParams, followerHost | |||
351 | } | 352 | } |
352 | 353 | ||
353 | function emailFinder (email: object) { | 354 | function emailFinder (email: object) { |
354 | const text: string = email[ 'text' ] | 355 | const text: string = email['text'] |
355 | 356 | ||
356 | return text.includes(' automatically followed a new instance') && text.includes(followingHost) | 357 | return text.includes(' automatically followed a new instance') && text.includes(followingHost) |
357 | } | 358 | } |
@@ -385,7 +386,7 @@ async function checkCommentMention ( | |||
385 | } | 386 | } |
386 | 387 | ||
387 | function emailFinder (email: object) { | 388 | function emailFinder (email: object) { |
388 | const text: string = email[ 'text' ] | 389 | const text: string = email['text'] |
389 | 390 | ||
390 | return text.includes(' mentioned ') && text.includes(uuid) && text.includes(byAccountDisplayName) | 391 | return text.includes(' mentioned ') && text.includes(uuid) && text.includes(byAccountDisplayName) |
391 | } | 392 | } |
@@ -394,6 +395,7 @@ async function checkCommentMention ( | |||
394 | } | 395 | } |
395 | 396 | ||
396 | let lastEmailCount = 0 | 397 | let lastEmailCount = 0 |
398 | |||
397 | async function checkNewCommentOnMyVideo (base: CheckerBaseParams, uuid: string, commentId: number, threadId: number, type: CheckerType) { | 399 | async function checkNewCommentOnMyVideo (base: CheckerBaseParams, uuid: string, commentId: number, threadId: number, type: CheckerType) { |
398 | const notificationType = UserNotificationType.NEW_COMMENT_ON_MY_VIDEO | 400 | const notificationType = UserNotificationType.NEW_COMMENT_ON_MY_VIDEO |
399 | 401 | ||
@@ -413,8 +415,9 @@ async function checkNewCommentOnMyVideo (base: CheckerBaseParams, uuid: string, | |||
413 | } | 415 | } |
414 | 416 | ||
415 | const commentUrl = `http://localhost:${base.server.port}/videos/watch/${uuid};threadId=${threadId}` | 417 | const commentUrl = `http://localhost:${base.server.port}/videos/watch/${uuid};threadId=${threadId}` |
418 | |||
416 | function emailFinder (email: object) { | 419 | function emailFinder (email: object) { |
417 | return email[ 'text' ].indexOf(commentUrl) !== -1 | 420 | return email['text'].indexOf(commentUrl) !== -1 |
418 | } | 421 | } |
419 | 422 | ||
420 | await checkNotification(base, notificationChecker, emailFinder, type) | 423 | await checkNotification(base, notificationChecker, emailFinder, type) |
@@ -444,7 +447,7 @@ async function checkNewVideoAbuseForModerators (base: CheckerBaseParams, videoUU | |||
444 | } | 447 | } |
445 | 448 | ||
446 | function emailFinder (email: object) { | 449 | function emailFinder (email: object) { |
447 | const text = email[ 'text' ] | 450 | const text = email['text'] |
448 | return text.indexOf(videoUUID) !== -1 && text.indexOf('abuse') !== -1 | 451 | return text.indexOf(videoUUID) !== -1 && text.indexOf('abuse') !== -1 |
449 | } | 452 | } |
450 | 453 | ||
@@ -469,8 +472,8 @@ async function checkVideoAutoBlacklistForModerators (base: CheckerBaseParams, vi | |||
469 | } | 472 | } |
470 | 473 | ||
471 | function emailFinder (email: object) { | 474 | function emailFinder (email: object) { |
472 | const text = email[ 'text' ] | 475 | const text = email['text'] |
473 | return text.indexOf(videoUUID) !== -1 && email[ 'text' ].indexOf('video-auto-blacklist/list') !== -1 | 476 | return text.indexOf(videoUUID) !== -1 && email['text'].indexOf('video-auto-blacklist/list') !== -1 |
474 | } | 477 | } |
475 | 478 | ||
476 | await checkNotification(base, notificationChecker, emailFinder, type) | 479 | await checkNotification(base, notificationChecker, emailFinder, type) |
@@ -496,7 +499,7 @@ async function checkNewBlacklistOnMyVideo ( | |||
496 | } | 499 | } |
497 | 500 | ||
498 | function emailFinder (email: object) { | 501 | function emailFinder (email: object) { |
499 | const text = email[ 'text' ] | 502 | const text = email['text'] |
500 | return text.indexOf(videoUUID) !== -1 && text.indexOf(' ' + blacklistType) !== -1 | 503 | return text.indexOf(videoUUID) !== -1 && text.indexOf(' ' + blacklistType) !== -1 |
501 | } | 504 | } |
502 | 505 | ||
diff --git a/shared/extra-utils/users/users.ts b/shared/extra-utils/users/users.ts index 2fe0e55c2..248af2d6e 100644 --- a/shared/extra-utils/users/users.ts +++ b/shared/extra-utils/users/users.ts | |||
@@ -9,14 +9,14 @@ import { UserUpdateMe } from '../../models/users' | |||
9 | import { omit } from 'lodash' | 9 | import { omit } from 'lodash' |
10 | 10 | ||
11 | type CreateUserArgs = { | 11 | type CreateUserArgs = { |
12 | url: string, | 12 | url: string |
13 | accessToken: string, | 13 | accessToken: string |
14 | username: string, | 14 | username: string |
15 | password: string, | 15 | password: string |
16 | videoQuota?: number, | 16 | videoQuota?: number |
17 | videoQuotaDaily?: number, | 17 | videoQuotaDaily?: number |
18 | role?: UserRole, | 18 | role?: UserRole |
19 | adminFlags?: UserAdminFlag, | 19 | adminFlags?: UserAdminFlag |
20 | specialStatus?: number | 20 | specialStatus?: number |
21 | } | 21 | } |
22 | function createUser (parameters: CreateUserArgs) { | 22 | function createUser (parameters: CreateUserArgs) { |
@@ -74,8 +74,8 @@ function registerUser (url: string, username: string, password: string, specialS | |||
74 | } | 74 | } |
75 | 75 | ||
76 | function registerUserWithChannel (options: { | 76 | function registerUserWithChannel (options: { |
77 | url: string, | 77 | url: string |
78 | user: { username: string, password: string, displayName?: string }, | 78 | user: { username: string, password: string, displayName?: string } |
79 | channel: { name: string, displayName: string } | 79 | channel: { name: string, displayName: string } |
80 | }) { | 80 | }) { |
81 | const path = '/api/v1/users/register' | 81 | const path = '/api/v1/users/register' |
@@ -230,8 +230,8 @@ function updateMyUser (options: { url: string, accessToken: string } & UserUpdat | |||
230 | } | 230 | } |
231 | 231 | ||
232 | function updateMyAvatar (options: { | 232 | function updateMyAvatar (options: { |
233 | url: string, | 233 | url: string |
234 | accessToken: string, | 234 | accessToken: string |
235 | fixture: string | 235 | fixture: string |
236 | }) { | 236 | }) { |
237 | const path = '/api/v1/users/me/avatar/pick' | 237 | const path = '/api/v1/users/me/avatar/pick' |
@@ -241,14 +241,14 @@ function updateMyAvatar (options: { | |||
241 | 241 | ||
242 | function updateUser (options: { | 242 | function updateUser (options: { |
243 | url: string | 243 | url: string |
244 | userId: number, | 244 | userId: number |
245 | accessToken: string, | 245 | accessToken: string |
246 | email?: string, | 246 | email?: string |
247 | emailVerified?: boolean, | 247 | emailVerified?: boolean |
248 | videoQuota?: number, | 248 | videoQuota?: number |
249 | videoQuotaDaily?: number, | 249 | videoQuotaDaily?: number |
250 | password?: string, | 250 | password?: string |
251 | adminFlags?: UserAdminFlag, | 251 | adminFlags?: UserAdminFlag |
252 | role?: UserRole | 252 | role?: UserRole |
253 | }) { | 253 | }) { |
254 | const path = '/api/v1/users/' + options.userId | 254 | const path = '/api/v1/users/' + options.userId |
diff --git a/shared/extra-utils/videos/video-blacklist.ts b/shared/extra-utils/videos/video-blacklist.ts index e25a292fc..ba139ef95 100644 --- a/shared/extra-utils/videos/video-blacklist.ts +++ b/shared/extra-utils/videos/video-blacklist.ts | |||
@@ -13,11 +13,11 @@ function addVideoToBlacklist ( | |||
13 | const path = '/api/v1/videos/' + videoId + '/blacklist' | 13 | const path = '/api/v1/videos/' + videoId + '/blacklist' |
14 | 14 | ||
15 | return request(url) | 15 | return request(url) |
16 | .post(path) | 16 | .post(path) |
17 | .send({ reason, unfederate }) | 17 | .send({ reason, unfederate }) |
18 | .set('Accept', 'application/json') | 18 | .set('Accept', 'application/json') |
19 | .set('Authorization', 'Bearer ' + token) | 19 | .set('Authorization', 'Bearer ' + token) |
20 | .expect(specialStatus) | 20 | .expect(specialStatus) |
21 | } | 21 | } |
22 | 22 | ||
23 | function updateVideoBlacklist (url: string, token: string, videoId: number, reason?: string, specialStatus = 204) { | 23 | function updateVideoBlacklist (url: string, token: string, videoId: number, reason?: string, specialStatus = 204) { |
@@ -35,20 +35,20 @@ function removeVideoFromBlacklist (url: string, token: string, videoId: number | | |||
35 | const path = '/api/v1/videos/' + videoId + '/blacklist' | 35 | const path = '/api/v1/videos/' + videoId + '/blacklist' |
36 | 36 | ||
37 | return request(url) | 37 | return request(url) |
38 | .delete(path) | 38 | .delete(path) |
39 | .set('Accept', 'application/json') | 39 | .set('Accept', 'application/json') |
40 | .set('Authorization', 'Bearer ' + token) | 40 | .set('Authorization', 'Bearer ' + token) |
41 | .expect(specialStatus) | 41 | .expect(specialStatus) |
42 | } | 42 | } |
43 | 43 | ||
44 | function getBlacklistedVideosList (parameters: { | 44 | function getBlacklistedVideosList (parameters: { |
45 | url: string, | 45 | url: string |
46 | token: string, | 46 | token: string |
47 | sort?: string, | 47 | sort?: string |
48 | type?: VideoBlacklistType, | 48 | type?: VideoBlacklistType |
49 | specialStatus?: number | 49 | specialStatus?: number |
50 | }) { | 50 | }) { |
51 | let { url, token, sort, type, specialStatus = 200 } = parameters | 51 | const { url, token, sort, type, specialStatus = 200 } = parameters |
52 | const path = '/api/v1/videos/blacklist/' | 52 | const path = '/api/v1/videos/blacklist/' |
53 | 53 | ||
54 | const query = { sort, type } | 54 | const query = { sort, type } |
diff --git a/shared/extra-utils/videos/video-captions.ts b/shared/extra-utils/videos/video-captions.ts index 8d67f617b..5bd533bba 100644 --- a/shared/extra-utils/videos/video-captions.ts +++ b/shared/extra-utils/videos/video-captions.ts | |||
@@ -6,12 +6,12 @@ import { buildAbsoluteFixturePath } from '../miscs/miscs' | |||
6 | const expect = chai.expect | 6 | const expect = chai.expect |
7 | 7 | ||
8 | function createVideoCaption (args: { | 8 | function createVideoCaption (args: { |
9 | url: string, | 9 | url: string |
10 | accessToken: string | 10 | accessToken: string |
11 | videoId: string | number | 11 | videoId: string | number |
12 | language: string | 12 | language: string |
13 | fixture: string, | 13 | fixture: string |
14 | mimeType?: string, | 14 | mimeType?: string |
15 | statusCodeExpected?: number | 15 | statusCodeExpected?: number |
16 | }) { | 16 | }) { |
17 | const path = '/api/v1/videos/' + args.videoId + '/captions/' + args.language | 17 | const path = '/api/v1/videos/' + args.videoId + '/captions/' + args.language |
diff --git a/shared/extra-utils/videos/video-channels.ts b/shared/extra-utils/videos/video-channels.ts index 053842331..51d433940 100644 --- a/shared/extra-utils/videos/video-channels.ts +++ b/shared/extra-utils/videos/video-channels.ts | |||
@@ -1,3 +1,5 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-floating-promises */ | ||
2 | |||
1 | import * as request from 'supertest' | 3 | import * as request from 'supertest' |
2 | import { VideoChannelUpdate } from '../../models/videos/channel/video-channel-update.model' | 4 | import { VideoChannelUpdate } from '../../models/videos/channel/video-channel-update.model' |
3 | import { VideoChannelCreate } from '../../models/videos/channel/video-channel-create.model' | 5 | import { VideoChannelCreate } from '../../models/videos/channel/video-channel-create.model' |
@@ -22,11 +24,11 @@ function getVideoChannelsList (url: string, start: number, count: number, sort?: | |||
22 | } | 24 | } |
23 | 25 | ||
24 | function getAccountVideoChannelsList (parameters: { | 26 | function getAccountVideoChannelsList (parameters: { |
25 | url: string, | 27 | url: string |
26 | accountName: string, | 28 | accountName: string |
27 | start?: number, | 29 | start?: number |
28 | count?: number, | 30 | count?: number |
29 | sort?: string, | 31 | sort?: string |
30 | specialStatus?: number | 32 | specialStatus?: number |
31 | }) { | 33 | }) { |
32 | const { url, accountName, start, count, sort = 'createdAt', specialStatus = 200 } = parameters | 34 | const { url, accountName, start, count, sort = 'createdAt', specialStatus = 200 } = parameters |
@@ -113,9 +115,9 @@ function getVideoChannel (url: string, channelName: string) { | |||
113 | } | 115 | } |
114 | 116 | ||
115 | function updateVideoChannelAvatar (options: { | 117 | function updateVideoChannelAvatar (options: { |
116 | url: string, | 118 | url: string |
117 | accessToken: string, | 119 | accessToken: string |
118 | fixture: string, | 120 | fixture: string |
119 | videoChannelName: string | number | 121 | videoChannelName: string | number |
120 | }) { | 122 | }) { |
121 | 123 | ||
@@ -129,7 +131,7 @@ function setDefaultVideoChannel (servers: ServerInfo[]) { | |||
129 | 131 | ||
130 | for (const server of servers) { | 132 | for (const server of servers) { |
131 | const p = getMyUserInformation(server.url, server.accessToken) | 133 | const p = getMyUserInformation(server.url, server.accessToken) |
132 | .then(res => server.videoChannel = (res.body as User).videoChannels[0]) | 134 | .then(res => { server.videoChannel = (res.body as User).videoChannels[0] }) |
133 | 135 | ||
134 | tasks.push(p) | 136 | tasks.push(p) |
135 | } | 137 | } |
diff --git a/shared/extra-utils/videos/video-comments.ts b/shared/extra-utils/videos/video-comments.ts index 0ebf69ced..81c48412d 100644 --- a/shared/extra-utils/videos/video-comments.ts +++ b/shared/extra-utils/videos/video-comments.ts | |||
@@ -1,3 +1,5 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-floating-promises */ | ||
2 | |||
1 | import * as request from 'supertest' | 3 | import * as request from 'supertest' |
2 | import { makeDeleteRequest } from '../requests/requests' | 4 | import { makeDeleteRequest } from '../requests/requests' |
3 | 5 | ||
diff --git a/shared/extra-utils/videos/video-imports.ts b/shared/extra-utils/videos/video-imports.ts index 150cc94ed..8e5abd2f5 100644 --- a/shared/extra-utils/videos/video-imports.ts +++ b/shared/extra-utils/videos/video-imports.ts | |||
@@ -7,7 +7,7 @@ function getYoutubeVideoUrl () { | |||
7 | } | 7 | } |
8 | 8 | ||
9 | function getMagnetURI () { | 9 | function getMagnetURI () { |
10 | // tslint:disable:max-line-length | 10 | // eslint-disable-next-line max-len |
11 | return 'magnet:?xs=https%3A%2F%2Fpeertube2.cpy.re%2Fstatic%2Ftorrents%2Fb209ca00-c8bb-4b2b-b421-1ede169f3dbc-720.torrent&xt=urn:btih:0f498834733e8057ed5c6f2ee2b4efd8d84a76ee&dn=super+peertube2+video&tr=wss%3A%2F%2Fpeertube2.cpy.re%3A443%2Ftracker%2Fsocket&tr=https%3A%2F%2Fpeertube2.cpy.re%2Ftracker%2Fannounce&ws=https%3A%2F%2Fpeertube2.cpy.re%2Fstatic%2Fwebseed%2Fb209ca00-c8bb-4b2b-b421-1ede169f3dbc-720.mp4' | 11 | return 'magnet:?xs=https%3A%2F%2Fpeertube2.cpy.re%2Fstatic%2Ftorrents%2Fb209ca00-c8bb-4b2b-b421-1ede169f3dbc-720.torrent&xt=urn:btih:0f498834733e8057ed5c6f2ee2b4efd8d84a76ee&dn=super+peertube2+video&tr=wss%3A%2F%2Fpeertube2.cpy.re%3A443%2Ftracker%2Fsocket&tr=https%3A%2F%2Fpeertube2.cpy.re%2Ftracker%2Fannounce&ws=https%3A%2F%2Fpeertube2.cpy.re%2Fstatic%2Fwebseed%2Fb209ca00-c8bb-4b2b-b421-1ede169f3dbc-720.mp4' |
12 | } | 12 | } |
13 | 13 | ||
diff --git a/shared/extra-utils/videos/video-playlists.ts b/shared/extra-utils/videos/video-playlists.ts index 6762c5973..5bcc02570 100644 --- a/shared/extra-utils/videos/video-playlists.ts +++ b/shared/extra-utils/videos/video-playlists.ts | |||
@@ -123,9 +123,9 @@ function deleteVideoPlaylist (url: string, token: string, playlistId: number | s | |||
123 | } | 123 | } |
124 | 124 | ||
125 | function createVideoPlaylist (options: { | 125 | function createVideoPlaylist (options: { |
126 | url: string, | 126 | url: string |
127 | token: string, | 127 | token: string |
128 | playlistAttrs: VideoPlaylistCreate, | 128 | playlistAttrs: VideoPlaylistCreate |
129 | expectedStatus?: number | 129 | expectedStatus?: number |
130 | }) { | 130 | }) { |
131 | const path = '/api/v1/video-playlists' | 131 | const path = '/api/v1/video-playlists' |
@@ -148,10 +148,10 @@ function createVideoPlaylist (options: { | |||
148 | } | 148 | } |
149 | 149 | ||
150 | function updateVideoPlaylist (options: { | 150 | function updateVideoPlaylist (options: { |
151 | url: string, | 151 | url: string |
152 | token: string, | 152 | token: string |
153 | playlistAttrs: VideoPlaylistUpdate, | 153 | playlistAttrs: VideoPlaylistUpdate |
154 | playlistId: number | string, | 154 | playlistId: number | string |
155 | expectedStatus?: number | 155 | expectedStatus?: number |
156 | }) { | 156 | }) { |
157 | const path = '/api/v1/video-playlists/' + options.playlistId | 157 | const path = '/api/v1/video-playlists/' + options.playlistId |
@@ -174,9 +174,9 @@ function updateVideoPlaylist (options: { | |||
174 | } | 174 | } |
175 | 175 | ||
176 | async function addVideoInPlaylist (options: { | 176 | async function addVideoInPlaylist (options: { |
177 | url: string, | 177 | url: string |
178 | token: string, | 178 | token: string |
179 | playlistId: number | string, | 179 | playlistId: number | string |
180 | elementAttrs: VideoPlaylistElementCreate | { videoId: string } | 180 | elementAttrs: VideoPlaylistElementCreate | { videoId: string } |
181 | expectedStatus?: number | 181 | expectedStatus?: number |
182 | }) { | 182 | }) { |
@@ -194,11 +194,11 @@ async function addVideoInPlaylist (options: { | |||
194 | } | 194 | } |
195 | 195 | ||
196 | function updateVideoPlaylistElement (options: { | 196 | function updateVideoPlaylistElement (options: { |
197 | url: string, | 197 | url: string |
198 | token: string, | 198 | token: string |
199 | playlistId: number | string, | 199 | playlistId: number | string |
200 | playlistElementId: number | string, | 200 | playlistElementId: number | string |
201 | elementAttrs: VideoPlaylistElementUpdate, | 201 | elementAttrs: VideoPlaylistElementUpdate |
202 | expectedStatus?: number | 202 | expectedStatus?: number |
203 | }) { | 203 | }) { |
204 | const path = '/api/v1/video-playlists/' + options.playlistId + '/videos/' + options.playlistElementId | 204 | const path = '/api/v1/video-playlists/' + options.playlistId + '/videos/' + options.playlistElementId |
@@ -213,10 +213,10 @@ function updateVideoPlaylistElement (options: { | |||
213 | } | 213 | } |
214 | 214 | ||
215 | function removeVideoFromPlaylist (options: { | 215 | function removeVideoFromPlaylist (options: { |
216 | url: string, | 216 | url: string |
217 | token: string, | 217 | token: string |
218 | playlistId: number | string, | 218 | playlistId: number | string |
219 | playlistElementId: number, | 219 | playlistElementId: number |
220 | expectedStatus?: number | 220 | expectedStatus?: number |
221 | }) { | 221 | }) { |
222 | const path = '/api/v1/video-playlists/' + options.playlistId + '/videos/' + options.playlistElementId | 222 | const path = '/api/v1/video-playlists/' + options.playlistId + '/videos/' + options.playlistElementId |
@@ -230,14 +230,14 @@ function removeVideoFromPlaylist (options: { | |||
230 | } | 230 | } |
231 | 231 | ||
232 | function reorderVideosPlaylist (options: { | 232 | function reorderVideosPlaylist (options: { |
233 | url: string, | 233 | url: string |
234 | token: string, | 234 | token: string |
235 | playlistId: number | string, | 235 | playlistId: number | string |
236 | elementAttrs: { | 236 | elementAttrs: { |
237 | startPosition: number, | 237 | startPosition: number |
238 | insertAfterPosition: number, | 238 | insertAfterPosition: number |
239 | reorderLength?: number | 239 | reorderLength?: number |
240 | }, | 240 | } |
241 | expectedStatus?: number | 241 | expectedStatus?: number |
242 | }) { | 242 | }) { |
243 | const path = '/api/v1/video-playlists/' + options.playlistId + '/videos/reorder' | 243 | const path = '/api/v1/video-playlists/' + options.playlistId + '/videos/reorder' |
diff --git a/shared/extra-utils/videos/video-streaming-playlists.ts b/shared/extra-utils/videos/video-streaming-playlists.ts index eb25011cb..e54da84aa 100644 --- a/shared/extra-utils/videos/video-streaming-playlists.ts +++ b/shared/extra-utils/videos/video-streaming-playlists.ts | |||
@@ -37,7 +37,7 @@ async function checkSegmentHash ( | |||
37 | 37 | ||
38 | const resSha = await getSegmentSha256(hlsPlaylist.segmentsSha256Url) | 38 | const resSha = await getSegmentSha256(hlsPlaylist.segmentsSha256Url) |
39 | 39 | ||
40 | const sha256Server = resSha.body[ videoName ][range] | 40 | const sha256Server = resSha.body[videoName][range] |
41 | expect(sha256(res2.body)).to.equal(sha256Server) | 41 | expect(sha256(res2.body)).to.equal(sha256Server) |
42 | } | 42 | } |
43 | 43 | ||
diff --git a/shared/extra-utils/videos/videos.ts b/shared/extra-utils/videos/videos.ts index aa13273ae..39a06b0d7 100644 --- a/shared/extra-utils/videos/videos.ts +++ b/shared/extra-utils/videos/videos.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/no-floating-promises */ |
2 | 2 | ||
3 | import { expect } from 'chai' | 3 | import { expect } from 'chai' |
4 | import { pathExists, readdir, readFile } from 'fs-extra' | 4 | import { pathExists, readdir, readFile } from 'fs-extra' |
@@ -488,7 +488,7 @@ async function completeVideoCheck ( | |||
488 | description: string | 488 | description: string |
489 | publishedAt?: string | 489 | publishedAt?: string |
490 | support: string | 490 | support: string |
491 | originallyPublishedAt?: string, | 491 | originallyPublishedAt?: string |
492 | account: { | 492 | account: { |
493 | name: string | 493 | name: string |
494 | host: string | 494 | host: string |
@@ -509,7 +509,7 @@ async function completeVideoCheck ( | |||
509 | files: { | 509 | files: { |
510 | resolution: number | 510 | resolution: number |
511 | size: number | 511 | size: number |
512 | }[], | 512 | }[] |
513 | thumbnailfile?: string | 513 | thumbnailfile?: string |
514 | previewfile?: string | 514 | previewfile?: string |
515 | } | 515 | } |
@@ -583,9 +583,10 @@ async function completeVideoCheck ( | |||
583 | 583 | ||
584 | const minSize = attributeFile.size - ((10 * attributeFile.size) / 100) | 584 | const minSize = attributeFile.size - ((10 * attributeFile.size) / 100) |
585 | const maxSize = attributeFile.size + ((10 * attributeFile.size) / 100) | 585 | const maxSize = attributeFile.size + ((10 * attributeFile.size) / 100) |
586 | expect(file.size, | 586 | expect( |
587 | 'File size for resolution ' + file.resolution.label + ' outside confidence interval (' + minSize + '> size <' + maxSize + ')') | 587 | file.size, |
588 | .to.be.above(minSize).and.below(maxSize) | 588 | 'File size for resolution ' + file.resolution.label + ' outside confidence interval (' + minSize + '> size <' + maxSize + ')' |
589 | ).to.be.above(minSize).and.below(maxSize) | ||
589 | 590 | ||
590 | const torrent = await webtorrentAdd(file.magnetUri, true) | 591 | const torrent = await webtorrentAdd(file.magnetUri, true) |
591 | expect(torrent.files).to.be.an('array') | 592 | expect(torrent.files).to.be.an('array') |
@@ -608,10 +609,10 @@ async function videoUUIDToId (url: string, id: number | string) { | |||
608 | } | 609 | } |
609 | 610 | ||
610 | async function uploadVideoAndGetId (options: { | 611 | async function uploadVideoAndGetId (options: { |
611 | server: ServerInfo, | 612 | server: ServerInfo |
612 | videoName: string, | 613 | videoName: string |
613 | nsfw?: boolean, | 614 | nsfw?: boolean |
614 | privacy?: VideoPrivacy, | 615 | privacy?: VideoPrivacy |
615 | token?: string | 616 | token?: string |
616 | }) { | 617 | }) { |
617 | const videoAttrs: any = { name: options.videoName } | 618 | const videoAttrs: any = { name: options.videoName } |
diff --git a/shared/models/activitypub/activity.ts b/shared/models/activitypub/activity.ts index 492b672c7..20ecf176c 100644 --- a/shared/models/activitypub/activity.ts +++ b/shared/models/activitypub/activity.ts | |||
@@ -8,12 +8,33 @@ import { ViewObject } from './objects/view-object' | |||
8 | import { APObject } from './objects/object.model' | 8 | import { APObject } from './objects/object.model' |
9 | import { PlaylistObject } from './objects/playlist-object' | 9 | import { PlaylistObject } from './objects/playlist-object' |
10 | 10 | ||
11 | export type Activity = ActivityCreate | ActivityUpdate | | 11 | export type Activity = |
12 | ActivityDelete | ActivityFollow | ActivityAccept | ActivityAnnounce | | 12 | ActivityCreate | |
13 | ActivityUndo | ActivityLike | ActivityReject | ActivityView | ActivityDislike | ActivityFlag | 13 | ActivityUpdate | |
14 | 14 | ActivityDelete | | |
15 | export type ActivityType = 'Create' | 'Update' | 'Delete' | 'Follow' | 'Accept' | 'Announce' | 'Undo' | 'Like' | 'Reject' | | 15 | ActivityFollow | |
16 | 'View' | 'Dislike' | 'Flag' | 16 | ActivityAccept | |
17 | ActivityAnnounce | | ||
18 | ActivityUndo | | ||
19 | ActivityLike | | ||
20 | ActivityReject | | ||
21 | ActivityView | | ||
22 | ActivityDislike | | ||
23 | ActivityFlag | ||
24 | |||
25 | export type ActivityType = | ||
26 | 'Create' | | ||
27 | 'Update' | | ||
28 | 'Delete' | | ||
29 | 'Follow' | | ||
30 | 'Accept' | | ||
31 | 'Announce' | | ||
32 | 'Undo' | | ||
33 | 'Like' | | ||
34 | 'Reject' | | ||
35 | 'View' | | ||
36 | 'Dislike' | | ||
37 | 'Flag' | ||
17 | 38 | ||
18 | export interface ActivityAudience { | 39 | export interface ActivityAudience { |
19 | to: string[] | 40 | to: string[] |
@@ -66,17 +87,17 @@ export interface ActivityAnnounce extends BaseActivity { | |||
66 | } | 87 | } |
67 | 88 | ||
68 | export interface ActivityUndo extends BaseActivity { | 89 | export interface ActivityUndo extends BaseActivity { |
69 | type: 'Undo', | 90 | type: 'Undo' |
70 | object: ActivityFollow | ActivityLike | ActivityDislike | ActivityCreate | ActivityAnnounce | 91 | object: ActivityFollow | ActivityLike | ActivityDislike | ActivityCreate | ActivityAnnounce |
71 | } | 92 | } |
72 | 93 | ||
73 | export interface ActivityLike extends BaseActivity { | 94 | export interface ActivityLike extends BaseActivity { |
74 | type: 'Like', | 95 | type: 'Like' |
75 | object: APObject | 96 | object: APObject |
76 | } | 97 | } |
77 | 98 | ||
78 | export interface ActivityView extends BaseActivity { | 99 | export interface ActivityView extends BaseActivity { |
79 | type: 'View', | 100 | type: 'View' |
80 | actor: string | 101 | actor: string |
81 | object: APObject | 102 | object: APObject |
82 | } | 103 | } |
@@ -89,7 +110,7 @@ export interface ActivityDislike extends BaseActivity { | |||
89 | } | 110 | } |
90 | 111 | ||
91 | export interface ActivityFlag extends BaseActivity { | 112 | export interface ActivityFlag extends BaseActivity { |
92 | type: 'Flag', | 113 | type: 'Flag' |
93 | content: string, | 114 | content: string |
94 | object: APObject | APObject[] | 115 | object: APObject | APObject[] |
95 | } | 116 | } |
diff --git a/shared/models/activitypub/activitypub-actor.ts b/shared/models/activitypub/activitypub-actor.ts index b8a2dc925..f022f3d02 100644 --- a/shared/models/activitypub/activitypub-actor.ts +++ b/shared/models/activitypub/activitypub-actor.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { ActivityPubAttributedTo } from './objects/common-objects' | 1 | import { ActivityIconObject, ActivityPubAttributedTo } from './objects/common-objects' |
2 | 2 | ||
3 | export type ActivityPubActorType = 'Person' | 'Application' | 'Group' | 'Service' | 'Organization' | 3 | export type ActivityPubActorType = 'Person' | 'Application' | 'Group' | 'Service' | 'Organization' |
4 | 4 | ||
@@ -27,9 +27,5 @@ export interface ActivityPubActor { | |||
27 | publicKeyPem: string | 27 | publicKeyPem: string |
28 | } | 28 | } |
29 | 29 | ||
30 | icon: { | 30 | icon: ActivityIconObject |
31 | type: 'Image' | ||
32 | mediaType: 'image/png' | ||
33 | url: string | ||
34 | } | ||
35 | } | 31 | } |
diff --git a/shared/models/activitypub/activitypub-signature.ts b/shared/models/activitypub/activitypub-signature.ts index 1d9f4b3b3..fafdc246d 100644 --- a/shared/models/activitypub/activitypub-signature.ts +++ b/shared/models/activitypub/activitypub-signature.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | export interface ActivityPubSignature { | 1 | export interface ActivityPubSignature { |
2 | type: 'GraphSignature2012' | 2 | type: string |
3 | created: Date, | 3 | created: Date |
4 | creator: string | 4 | creator: string |
5 | signatureValue: string | 5 | signatureValue: string |
6 | } | 6 | } |
diff --git a/shared/models/activitypub/objects/cache-file-object.ts b/shared/models/activitypub/objects/cache-file-object.ts index 4b0a3a724..19a817582 100644 --- a/shared/models/activitypub/objects/cache-file-object.ts +++ b/shared/models/activitypub/objects/cache-file-object.ts | |||
@@ -2,7 +2,7 @@ import { ActivityVideoUrlObject, ActivityPlaylistUrlObject } from './common-obje | |||
2 | 2 | ||
3 | export interface CacheFileObject { | 3 | export interface CacheFileObject { |
4 | id: string | 4 | id: string |
5 | type: 'CacheFile', | 5 | type: 'CacheFile' |
6 | object: string | 6 | object: string |
7 | expires: string | 7 | expires: string |
8 | url: ActivityVideoUrlObject | ActivityPlaylistUrlObject | 8 | url: ActivityVideoUrlObject | ActivityPlaylistUrlObject |
diff --git a/shared/models/activitypub/objects/common-objects.ts b/shared/models/activitypub/objects/common-objects.ts index bab3ce366..e94d05429 100644 --- a/shared/models/activitypub/objects/common-objects.ts +++ b/shared/models/activitypub/objects/common-objects.ts | |||
@@ -7,9 +7,9 @@ export interface ActivityIdentifierObject { | |||
7 | export interface ActivityIconObject { | 7 | export interface ActivityIconObject { |
8 | type: 'Image' | 8 | type: 'Image' |
9 | url: string | 9 | url: string |
10 | mediaType: 'image/jpeg' | 10 | mediaType: 'image/jpeg' | 'image/png' |
11 | width: number | 11 | width?: number |
12 | height: number | 12 | height?: number |
13 | } | 13 | } |
14 | 14 | ||
15 | export type ActivityVideoUrlObject = { | 15 | export type ActivityVideoUrlObject = { |
@@ -72,19 +72,21 @@ export interface ActivityMentionObject { | |||
72 | name: string | 72 | name: string |
73 | } | 73 | } |
74 | 74 | ||
75 | export type ActivityTagObject = ActivityPlaylistSegmentHashesObject | | 75 | export type ActivityTagObject = |
76 | ActivityPlaylistInfohashesObject | | 76 | ActivityPlaylistSegmentHashesObject |
77 | ActivityVideoUrlObject | | 77 | | ActivityPlaylistInfohashesObject |
78 | ActivityHashTagObject | | 78 | | ActivityVideoUrlObject |
79 | ActivityMentionObject | | 79 | | ActivityHashTagObject |
80 | ActivityBitTorrentUrlObject | | 80 | | ActivityMentionObject |
81 | ActivityMagnetUrlObject | 81 | | ActivityBitTorrentUrlObject |
82 | | ActivityMagnetUrlObject | ||
82 | 83 | ||
83 | export type ActivityUrlObject = ActivityVideoUrlObject | | 84 | export type ActivityUrlObject = |
84 | ActivityPlaylistUrlObject | | 85 | ActivityVideoUrlObject |
85 | ActivityBitTorrentUrlObject | | 86 | | ActivityPlaylistUrlObject |
86 | ActivityMagnetUrlObject | | 87 | | ActivityBitTorrentUrlObject |
87 | ActivityHtmlUrlObject | 88 | | ActivityMagnetUrlObject |
89 | | ActivityHtmlUrlObject | ||
88 | 90 | ||
89 | export interface ActivityPubAttributedTo { | 91 | export interface ActivityPubAttributedTo { |
90 | type: 'Group' | 'Person' | 92 | type: 'Group' | 'Person' |
diff --git a/shared/models/activitypub/objects/video-abuse-object.ts b/shared/models/activitypub/objects/video-abuse-object.ts index 5f1264a76..d9622b414 100644 --- a/shared/models/activitypub/objects/video-abuse-object.ts +++ b/shared/models/activitypub/objects/video-abuse-object.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | export interface VideoAbuseObject { | 1 | export interface VideoAbuseObject { |
2 | type: 'Flag', | 2 | type: 'Flag' |
3 | content: string | 3 | content: string |
4 | object: string | string[] | 4 | object: string | string[] |
5 | } | 5 | } |
diff --git a/shared/models/activitypub/objects/video-torrent-object.ts b/shared/models/activitypub/objects/video-torrent-object.ts index cadd0ea49..11de8fc56 100644 --- a/shared/models/activitypub/objects/video-torrent-object.ts +++ b/shared/models/activitypub/objects/video-torrent-object.ts | |||
@@ -20,8 +20,8 @@ export interface VideoTorrentObject { | |||
20 | subtitleLanguage: ActivityIdentifierObject[] | 20 | subtitleLanguage: ActivityIdentifierObject[] |
21 | views: number | 21 | views: number |
22 | sensitive: boolean | 22 | sensitive: boolean |
23 | commentsEnabled: boolean, | 23 | commentsEnabled: boolean |
24 | downloadEnabled: boolean, | 24 | downloadEnabled: boolean |
25 | waitTranscoding: boolean | 25 | waitTranscoding: boolean |
26 | state: VideoState | 26 | state: VideoState |
27 | published: string | 27 | published: string |
diff --git a/shared/models/activitypub/objects/view-object.ts b/shared/models/activitypub/objects/view-object.ts index 00348116a..4dd21ce8e 100644 --- a/shared/models/activitypub/objects/view-object.ts +++ b/shared/models/activitypub/objects/view-object.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | export interface ViewObject { | 1 | export interface ViewObject { |
2 | type: 'View', | 2 | type: 'View' |
3 | actor: string | 3 | actor: string |
4 | object: string | 4 | object: string |
5 | } | 5 | } |
diff --git a/shared/models/i18n/i18n.ts b/shared/models/i18n/i18n.ts index 032944281..9ae175df9 100644 --- a/shared/models/i18n/i18n.ts +++ b/shared/models/i18n/i18n.ts | |||
@@ -56,6 +56,8 @@ export function isDefaultLocale (locale: string) { | |||
56 | } | 56 | } |
57 | 57 | ||
58 | export function peertubeTranslate (str: string, translations?: { [ id: string ]: string }) { | 58 | export function peertubeTranslate (str: string, translations?: { [ id: string ]: string }) { |
59 | // FIXME: remove disable rule when the client is upgraded to typescript 3.7 | ||
60 | // eslint-disable-next-line | ||
59 | return translations && translations[str] ? translations[str] : str | 61 | return translations && translations[str] ? translations[str] : str |
60 | } | 62 | } |
61 | 63 | ||
diff --git a/shared/models/nodeinfo/index.d.ts b/shared/models/nodeinfo/index.d.ts index 0a2d0492e..336cb66d2 100644 --- a/shared/models/nodeinfo/index.d.ts +++ b/shared/models/nodeinfo/index.d.ts | |||
@@ -98,7 +98,7 @@ export interface HttpNodeinfoDiasporaSoftwareNsSchema20 { | |||
98 | * The amount of users that signed in at least once in the last 30 days. | 98 | * The amount of users that signed in at least once in the last 30 days. |
99 | */ | 99 | */ |
100 | activeMonth?: number | 100 | activeMonth?: number |
101 | }; | 101 | } |
102 | /** | 102 | /** |
103 | * The amount of posts that were made by users that are registered on this server. | 103 | * The amount of posts that were made by users that are registered on this server. |
104 | */ | 104 | */ |
diff --git a/shared/models/plugins/peertube-plugin-latest-version.model.ts b/shared/models/plugins/peertube-plugin-latest-version.model.ts index dec4618fa..811a64429 100644 --- a/shared/models/plugins/peertube-plugin-latest-version.model.ts +++ b/shared/models/plugins/peertube-plugin-latest-version.model.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | export interface PeertubePluginLatestVersionRequest { | 1 | export interface PeertubePluginLatestVersionRequest { |
2 | currentPeerTubeEngine?: string, | 2 | currentPeerTubeEngine?: string |
3 | 3 | ||
4 | npmNames: string[] | 4 | npmNames: string[] |
5 | } | 5 | } |
diff --git a/shared/models/plugins/plugin-package-json.model.ts b/shared/models/plugins/plugin-package-json.model.ts index 3f3077671..c26e9ae5b 100644 --- a/shared/models/plugins/plugin-package-json.model.ts +++ b/shared/models/plugins/plugin-package-json.model.ts | |||
@@ -5,7 +5,7 @@ export type PluginTranslationPaths = { | |||
5 | } | 5 | } |
6 | 6 | ||
7 | export type ClientScript = { | 7 | export type ClientScript = { |
8 | script: string, | 8 | script: string |
9 | scopes: PluginClientScope[] | 9 | scopes: PluginClientScope[] |
10 | } | 10 | } |
11 | 11 | ||
@@ -13,12 +13,12 @@ export type PluginPackageJson = { | |||
13 | name: string | 13 | name: string |
14 | version: string | 14 | version: string |
15 | description: string | 15 | description: string |
16 | engine: { peertube: string }, | 16 | engine: { peertube: string } |
17 | 17 | ||
18 | homepage: string, | 18 | homepage: string |
19 | author: string, | 19 | author: string |
20 | bugs: string, | 20 | bugs: string |
21 | library: string, | 21 | library: string |
22 | 22 | ||
23 | staticDirs: { [ name: string ]: string } | 23 | staticDirs: { [ name: string ]: string } |
24 | css: string[] | 24 | css: string[] |
diff --git a/shared/models/plugins/server-hook.model.ts b/shared/models/plugins/server-hook.model.ts index 80ecd9e24..20f89b86d 100644 --- a/shared/models/plugins/server-hook.model.ts +++ b/shared/models/plugins/server-hook.model.ts | |||
@@ -70,7 +70,7 @@ export const serverActionHookObject = { | |||
70 | // Fired when a user is updated by an admin/moderator | 70 | // Fired when a user is updated by an admin/moderator |
71 | 'action:api.user.updated': true, | 71 | 'action:api.user.updated': true, |
72 | 72 | ||
73 | // Fired when a user got a new oauth2 token | 73 | // Fired when a user got a new oauth2 token |
74 | 'action:api.user.oauth2-got-token': true | 74 | 'action:api.user.oauth2-got-token': true |
75 | } | 75 | } |
76 | 76 | ||
diff --git a/shared/models/redundancy/video-redundancy.model.ts b/shared/models/redundancy/video-redundancy.model.ts index 014f69634..fa6e05832 100644 --- a/shared/models/redundancy/video-redundancy.model.ts +++ b/shared/models/redundancy/video-redundancy.model.ts | |||
@@ -24,10 +24,12 @@ interface RedundancyInformation { | |||
24 | size: number | 24 | size: number |
25 | } | 25 | } |
26 | 26 | ||
27 | // eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
27 | export interface FileRedundancyInformation extends RedundancyInformation { | 28 | export interface FileRedundancyInformation extends RedundancyInformation { |
28 | 29 | ||
29 | } | 30 | } |
30 | 31 | ||
32 | // eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
31 | export interface StreamingPlaylistRedundancyInformation extends RedundancyInformation { | 33 | export interface StreamingPlaylistRedundancyInformation extends RedundancyInformation { |
32 | 34 | ||
33 | } | 35 | } |
diff --git a/shared/models/server/custom-config.model.ts b/shared/models/server/custom-config.model.ts index 032b91a29..07e17bda2 100644 --- a/shared/models/server/custom-config.model.ts +++ b/shared/models/server/custom-config.model.ts | |||
@@ -97,7 +97,7 @@ export interface CustomConfig { | |||
97 | videos: { | 97 | videos: { |
98 | http: { | 98 | http: { |
99 | enabled: boolean | 99 | enabled: boolean |
100 | }, | 100 | } |
101 | torrent: { | 101 | torrent: { |
102 | enabled: boolean | 102 | enabled: boolean |
103 | } | 103 | } |
@@ -114,7 +114,7 @@ export interface CustomConfig { | |||
114 | 114 | ||
115 | followers: { | 115 | followers: { |
116 | instance: { | 116 | instance: { |
117 | enabled: boolean, | 117 | enabled: boolean |
118 | manualApproval: boolean | 118 | manualApproval: boolean |
119 | } | 119 | } |
120 | } | 120 | } |
diff --git a/shared/models/server/job.model.ts b/shared/models/server/job.model.ts index 19fd4c659..cf29d20d4 100644 --- a/shared/models/server/job.model.ts +++ b/shared/models/server/job.model.ts | |||
@@ -1,23 +1,24 @@ | |||
1 | export type JobState = 'active' | 'completed' | 'failed' | 'waiting' | 'delayed' | 1 | export type JobState = 'active' | 'completed' | 'failed' | 'waiting' | 'delayed' |
2 | 2 | ||
3 | export type JobType = 'activitypub-http-unicast' | | 3 | export type JobType = |
4 | 'activitypub-http-broadcast' | | 4 | | 'activitypub-http-unicast' |
5 | 'activitypub-http-fetcher' | | 5 | | 'activitypub-http-broadcast' |
6 | 'activitypub-follow' | | 6 | | 'activitypub-http-fetcher' |
7 | 'video-file-import' | | 7 | | 'activitypub-follow' |
8 | 'video-transcoding' | | 8 | | 'video-file-import' |
9 | 'email' | | 9 | | 'video-transcoding' |
10 | 'video-import' | | 10 | | 'email' |
11 | 'videos-views' | | 11 | | 'video-import' |
12 | 'activitypub-refresher' | | 12 | | 'videos-views' |
13 | 'video-redundancy' | 13 | | 'activitypub-refresher' |
14 | | 'video-redundancy' | ||
14 | 15 | ||
15 | export interface Job { | 16 | export interface Job { |
16 | id: number | 17 | id: number |
17 | state: JobState | 18 | state: JobState |
18 | type: JobType | 19 | type: JobType |
19 | data: any, | 20 | data: any |
20 | error: any, | 21 | error: any |
21 | createdAt: Date | string | 22 | createdAt: Date | string |
22 | finishedOn: Date | string | 23 | finishedOn: Date | string |
23 | processedOn: Date | string | 24 | processedOn: Date | string |
diff --git a/shared/models/server/server-config.model.ts b/shared/models/server/server-config.model.ts index f1bb2153c..76e0d6f2d 100644 --- a/shared/models/server/server-config.model.ts +++ b/shared/models/server/server-config.model.ts | |||
@@ -46,7 +46,7 @@ export interface ServerConfig { | |||
46 | } | 46 | } |
47 | 47 | ||
48 | signup: { | 48 | signup: { |
49 | allowed: boolean, | 49 | allowed: boolean |
50 | allowedForCurrentIP: boolean | 50 | allowedForCurrentIP: boolean |
51 | requiresEmailVerification: boolean | 51 | requiresEmailVerification: boolean |
52 | } | 52 | } |
@@ -97,7 +97,7 @@ export interface ServerConfig { | |||
97 | max: number | 97 | max: number |
98 | } | 98 | } |
99 | extensions: string[] | 99 | extensions: string[] |
100 | }, | 100 | } |
101 | file: { | 101 | file: { |
102 | extensions: string[] | 102 | extensions: string[] |
103 | } | 103 | } |
@@ -107,7 +107,7 @@ export interface ServerConfig { | |||
107 | file: { | 107 | file: { |
108 | size: { | 108 | size: { |
109 | max: number | 109 | max: number |
110 | }, | 110 | } |
111 | extensions: string[] | 111 | extensions: string[] |
112 | } | 112 | } |
113 | } | 113 | } |
diff --git a/shared/models/users/user.model.ts b/shared/models/users/user.model.ts index 168851196..efb451014 100644 --- a/shared/models/users/user.model.ts +++ b/shared/models/users/user.model.ts | |||
@@ -1,6 +1,5 @@ | |||
1 | import { Account } from '../actors' | 1 | import { Account } from '../actors' |
2 | import { VideoChannel } from '../videos/channel/video-channel.model' | 2 | import { VideoChannel } from '../videos/channel/video-channel.model' |
3 | import { VideoPlaylist } from '../videos/playlist/video-playlist.model' | ||
4 | import { UserRole } from './user-role' | 3 | import { UserRole } from './user-role' |
5 | import { NSFWPolicyType } from '../videos/nsfw-policy.type' | 4 | import { NSFWPolicyType } from '../videos/nsfw-policy.type' |
6 | import { UserNotificationSetting } from './user-notification-setting.model' | 5 | import { UserNotificationSetting } from './user-notification-setting.model' |