aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-11-17 15:52:26 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-11-27 19:40:52 +0100
commit79d5caf994edd87ad721994490f10677be277497 (patch)
tree0db45893d8b78e34ce3d59849d0a331977a63d4b /server
parent572f8d3dba44ba874f5c51023214273e3f5b643c (diff)
downloadPeerTube-79d5caf994edd87ad721994490f10677be277497.tar.gz
PeerTube-79d5caf994edd87ad721994490f10677be277497.tar.zst
PeerTube-79d5caf994edd87ad721994490f10677be277497.zip
Fix lint
Diffstat (limited to 'server')
-rw-r--r--server/controllers/activitypub/inbox.ts3
-rw-r--r--server/controllers/webfinger.ts4
-rw-r--r--server/helpers/custom-validators/videos.ts18
-rw-r--r--server/lib/activitypub/index.ts1
-rw-r--r--server/lib/activitypub/process-add.ts4
-rw-r--r--server/lib/activitypub/process-announce.ts10
-rw-r--r--server/lib/activitypub/process-create.ts2
-rw-r--r--server/lib/activitypub/process-delete.ts2
-rw-r--r--server/lib/activitypub/process-flag.ts17
-rw-r--r--server/lib/activitypub/process-update.ts2
-rw-r--r--server/lib/activitypub/send-request.ts2
-rw-r--r--server/lib/jobs/job-scheduler.ts1
-rw-r--r--server/lib/video-channel.ts8
-rw-r--r--server/middlewares/validators/account.ts9
-rw-r--r--server/middlewares/validators/webfinger.ts2
-rw-r--r--server/models/account/account-video-rate-interface.ts6
-rw-r--r--server/models/account/account.ts27
-rw-r--r--server/tests/api/check-params/follows.ts13
-rw-r--r--server/tests/api/index-slow.ts2
19 files changed, 46 insertions, 87 deletions
diff --git a/server/controllers/activitypub/inbox.ts b/server/controllers/activitypub/inbox.ts
index 5f47648df..fd3695886 100644
--- a/server/controllers/activitypub/inbox.ts
+++ b/server/controllers/activitypub/inbox.ts
@@ -2,7 +2,7 @@ import * as express from 'express'
2import { Activity, ActivityPubCollection, ActivityPubOrderedCollection, ActivityType, RootActivity } from '../../../shared' 2import { Activity, ActivityPubCollection, ActivityPubOrderedCollection, ActivityType, RootActivity } from '../../../shared'
3import { logger } from '../../helpers' 3import { logger } from '../../helpers'
4import { isActivityValid } from '../../helpers/custom-validators/activitypub/activity' 4import { isActivityValid } from '../../helpers/custom-validators/activitypub/activity'
5import { processCreateActivity, processFlagActivity, processUpdateActivity } from '../../lib' 5import { processCreateActivity, processUpdateActivity } from '../../lib'
6import { processAcceptActivity } from '../../lib/activitypub/process-accept' 6import { processAcceptActivity } from '../../lib/activitypub/process-accept'
7import { processAddActivity } from '../../lib/activitypub/process-add' 7import { processAddActivity } from '../../lib/activitypub/process-add'
8import { processAnnounceActivity } from '../../lib/activitypub/process-announce' 8import { processAnnounceActivity } from '../../lib/activitypub/process-announce'
@@ -16,7 +16,6 @@ const processActivity: { [ P in ActivityType ]: (activity: Activity, inboxAccoun
16 Create: processCreateActivity, 16 Create: processCreateActivity,
17 Add: processAddActivity, 17 Add: processAddActivity,
18 Update: processUpdateActivity, 18 Update: processUpdateActivity,
19 Flag: processFlagActivity,
20 Delete: processDeleteActivity, 19 Delete: processDeleteActivity,
21 Follow: processFollowActivity, 20 Follow: processFollowActivity,
22 Accept: processAcceptActivity, 21 Accept: processAcceptActivity,
diff --git a/server/controllers/webfinger.ts b/server/controllers/webfinger.ts
index 102ac0937..cc28a8909 100644
--- a/server/controllers/webfinger.ts
+++ b/server/controllers/webfinger.ts
@@ -1,8 +1,4 @@
1import * as express from 'express' 1import * as express from 'express'
2
3import { CONFIG, PREVIEWS_SIZE, EMBED_SIZE } from '../initializers'
4import { oembedValidator } from '../middlewares'
5import { VideoInstance } from '../models'
6import { webfingerValidator } from '../middlewares/validators/webfinger' 2import { webfingerValidator } from '../middlewares/validators/webfinger'
7import { AccountInstance } from '../models/account/account-interface' 3import { AccountInstance } from '../models/account/account-interface'
8 4
diff --git a/server/helpers/custom-validators/videos.ts b/server/helpers/custom-validators/videos.ts
index c97c9a2ad..07aadadb1 100644
--- a/server/helpers/custom-validators/videos.ts
+++ b/server/helpers/custom-validators/videos.ts
@@ -1,25 +1,23 @@
1import { values } from 'lodash'
2import * as validator from 'validator'
3import * as Promise from 'bluebird' 1import * as Promise from 'bluebird'
4import * as express from 'express' 2import * as express from 'express'
5import 'express-validator' 3import 'express-validator'
4import { values } from 'lodash'
6import 'multer' 5import 'multer'
7 6import * as validator from 'validator'
7import { VideoRateType } from '../../../shared'
8import { logger } from '../../helpers'
8import { 9import {
9 CONSTRAINTS_FIELDS, 10 CONSTRAINTS_FIELDS,
11 database as db,
10 VIDEO_CATEGORIES, 12 VIDEO_CATEGORIES,
11 VIDEO_LICENCES,
12 VIDEO_LANGUAGES, 13 VIDEO_LANGUAGES,
13 VIDEO_RATE_TYPES, 14 VIDEO_LICENCES,
14 VIDEO_PRIVACIES, 15 VIDEO_PRIVACIES,
15 database as db 16 VIDEO_RATE_TYPES
16} from '../../initializers' 17} from '../../initializers'
17import { isUserUsernameValid } from './users'
18import { isArray, exists } from './misc'
19import { VideoInstance } from '../../models' 18import { VideoInstance } from '../../models'
20import { logger } from '../../helpers'
21import { VideoRateType } from '../../../shared'
22import { isActivityPubUrlValid } from './activitypub/misc' 19import { isActivityPubUrlValid } from './activitypub/misc'
20import { exists, isArray } from './misc'
23 21
24const VIDEOS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEOS 22const VIDEOS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEOS
25const VIDEO_ABUSES_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_ABUSES 23const VIDEO_ABUSES_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_ABUSES
diff --git a/server/lib/activitypub/index.ts b/server/lib/activitypub/index.ts
index dca446fd4..e08108aac 100644
--- a/server/lib/activitypub/index.ts
+++ b/server/lib/activitypub/index.ts
@@ -3,7 +3,6 @@ export * from './process-add'
3export * from './process-announce' 3export * from './process-announce'
4export * from './process-create' 4export * from './process-create'
5export * from './process-delete' 5export * from './process-delete'
6export * from './process-flag'
7export * from './process-follow' 6export * from './process-follow'
8export * from './process-update' 7export * from './process-update'
9export * from './send-request' 8export * from './send-request'
diff --git a/server/lib/activitypub/process-add.ts b/server/lib/activitypub/process-add.ts
index c83d9e98e..e1769bee8 100644
--- a/server/lib/activitypub/process-add.ts
+++ b/server/lib/activitypub/process-add.ts
@@ -17,7 +17,7 @@ async function processAddActivity (activity: ActivityAdd) {
17 const videoChannelUrl = activity.target 17 const videoChannelUrl = activity.target
18 const videoChannel = await getOrCreateVideoChannel(account, videoChannelUrl) 18 const videoChannel = await getOrCreateVideoChannel(account, videoChannelUrl)
19 19
20 return processAddVideo(account, activity, videoChannel, activityObject as VideoTorrentObject) 20 return processAddVideo(account, activity, videoChannel, activityObject)
21 } 21 }
22 22
23 logger.warn('Unknown activity object type %s when creating activity.', activityType, { activity: activity.id }) 23 logger.warn('Unknown activity object type %s when creating activity.', activityType, { activity: activity.id })
@@ -68,7 +68,7 @@ function addRemoteVideo (
68 68
69 const videoCreated = await video.save(sequelizeOptions) 69 const videoCreated = await video.save(sequelizeOptions)
70 70
71 const videoFileAttributes = await videoFileActivityUrlToDBAttributes(videoCreated, videoToCreateData) 71 const videoFileAttributes = videoFileActivityUrlToDBAttributes(videoCreated, videoToCreateData)
72 if (videoFileAttributes.length === 0) { 72 if (videoFileAttributes.length === 0) {
73 throw new Error('Cannot find valid files for video %s ' + videoToCreateData.url) 73 throw new Error('Cannot find valid files for video %s ' + videoToCreateData.url)
74 } 74 }
diff --git a/server/lib/activitypub/process-announce.ts b/server/lib/activitypub/process-announce.ts
index f9674e095..eb38aecca 100644
--- a/server/lib/activitypub/process-announce.ts
+++ b/server/lib/activitypub/process-announce.ts
@@ -1,13 +1,11 @@
1import { ActivityAnnounce } from '../../../shared/models/activitypub/activity' 1import { ActivityAnnounce } from '../../../shared/models/activitypub/activity'
2import { VideoChannelObject } from '../../../shared/models/activitypub/objects/video-channel-object' 2import { getOrCreateAccount } from '../../helpers/activitypub'
3import { VideoTorrentObject } from '../../../shared/models/activitypub/objects/video-torrent-object'
4import { logger } from '../../helpers/logger' 3import { logger } from '../../helpers/logger'
5import { processAddActivity } from './process-add'
6import { processCreateActivity } from './process-create'
7import { database as db } from '../../initializers/index' 4import { database as db } from '../../initializers/index'
8import { getOrCreateAccount } from '../../helpers/activitypub'
9import { VideoChannelInstance } from '../../models/video/video-channel-interface'
10import { VideoInstance } from '../../models/index' 5import { VideoInstance } from '../../models/index'
6import { VideoChannelInstance } from '../../models/video/video-channel-interface'
7import { processAddActivity } from './process-add'
8import { processCreateActivity } from './process-create'
11 9
12async function processAnnounceActivity (activity: ActivityAnnounce) { 10async function processAnnounceActivity (activity: ActivityAnnounce) {
13 const announcedActivity = activity.object 11 const announcedActivity = activity.object
diff --git a/server/lib/activitypub/process-create.ts b/server/lib/activitypub/process-create.ts
index faea3f48a..de8e09adf 100644
--- a/server/lib/activitypub/process-create.ts
+++ b/server/lib/activitypub/process-create.ts
@@ -72,7 +72,7 @@ function addRemoteVideoAbuse (account: AccountInstance, videoAbuseToCreateData:
72 const video = await db.Video.loadByUrlAndPopulateAccount(videoAbuseToCreateData.object, t) 72 const video = await db.Video.loadByUrlAndPopulateAccount(videoAbuseToCreateData.object, t)
73 if (!video) { 73 if (!video) {
74 logger.warn('Unknown video %s for remote video abuse.', videoAbuseToCreateData.object) 74 logger.warn('Unknown video %s for remote video abuse.', videoAbuseToCreateData.object)
75 return 75 return undefined
76 } 76 }
77 77
78 const videoAbuseData = { 78 const videoAbuseData = {
diff --git a/server/lib/activitypub/process-delete.ts b/server/lib/activitypub/process-delete.ts
index d4487d2cc..0d5756e9c 100644
--- a/server/lib/activitypub/process-delete.ts
+++ b/server/lib/activitypub/process-delete.ts
@@ -28,7 +28,7 @@ async function processDeleteActivity (activity: ActivityDelete) {
28 } 28 }
29 } 29 }
30 30
31 return undefined 31 return
32} 32}
33 33
34// --------------------------------------------------------------------------- 34// ---------------------------------------------------------------------------
diff --git a/server/lib/activitypub/process-flag.ts b/server/lib/activitypub/process-flag.ts
deleted file mode 100644
index b562dce4d..000000000
--- a/server/lib/activitypub/process-flag.ts
+++ /dev/null
@@ -1,17 +0,0 @@
1import {
2 ActivityCreate,
3 VideoTorrentObject,
4 VideoChannelObject
5} from '../../../shared'
6
7function processFlagActivity (activity: ActivityCreate) {
8 return Promise.resolve(undefined)
9}
10
11// ---------------------------------------------------------------------------
12
13export {
14 processFlagActivity
15}
16
17// ---------------------------------------------------------------------------
diff --git a/server/lib/activitypub/process-update.ts b/server/lib/activitypub/process-update.ts
index b732fce33..a9aa5eeb4 100644
--- a/server/lib/activitypub/process-update.ts
+++ b/server/lib/activitypub/process-update.ts
@@ -80,7 +80,7 @@ async function updateRemoteVideo (account: AccountInstance, videoAttributesToUpd
80 } 80 }
81 await Promise.all(videoFileDestroyTasks) 81 await Promise.all(videoFileDestroyTasks)
82 82
83 const videoFileAttributes = await videoFileActivityUrlToDBAttributes(videoInstance, videoAttributesToUpdate) 83 const videoFileAttributes = videoFileActivityUrlToDBAttributes(videoInstance, videoAttributesToUpdate)
84 const tasks: Bluebird<any>[] = videoFileAttributes.map(f => db.VideoFile.create(f)) 84 const tasks: Bluebird<any>[] = videoFileAttributes.map(f => db.VideoFile.create(f))
85 await Promise.all(tasks) 85 await Promise.all(tasks)
86 86
diff --git a/server/lib/activitypub/send-request.ts b/server/lib/activitypub/send-request.ts
index 68a631a36..261ff04ab 100644
--- a/server/lib/activitypub/send-request.ts
+++ b/server/lib/activitypub/send-request.ts
@@ -147,7 +147,7 @@ async function broadcastToFollowers (data: any, byAccount: AccountInstance, toAc
147 const result = await db.AccountFollow.listAcceptedFollowerSharedInboxUrls(toAccountFollowerIds) 147 const result = await db.AccountFollow.listAcceptedFollowerSharedInboxUrls(toAccountFollowerIds)
148 if (result.data.length === 0) { 148 if (result.data.length === 0) {
149 logger.info('Not broadcast because of 0 followers for %s.', toAccountFollowerIds.join(', ')) 149 logger.info('Not broadcast because of 0 followers for %s.', toAccountFollowerIds.join(', '))
150 return 150 return undefined
151 } 151 }
152 152
153 const jobPayload = { 153 const jobPayload = {
diff --git a/server/lib/jobs/job-scheduler.ts b/server/lib/jobs/job-scheduler.ts
index 73c440279..62ce6927e 100644
--- a/server/lib/jobs/job-scheduler.ts
+++ b/server/lib/jobs/job-scheduler.ts
@@ -4,7 +4,6 @@ import { JobCategory } from '../../../shared'
4import { logger } from '../../helpers' 4import { logger } from '../../helpers'
5import { database as db, JOB_STATES, JOBS_FETCH_LIMIT_PER_CYCLE, JOBS_FETCHING_INTERVAL } from '../../initializers' 5import { database as db, JOB_STATES, JOBS_FETCH_LIMIT_PER_CYCLE, JOBS_FETCHING_INTERVAL } from '../../initializers'
6import { JobInstance } from '../../models' 6import { JobInstance } from '../../models'
7import { error } from 'util'
8 7
9export interface JobHandler<P, T> { 8export interface JobHandler<P, T> {
10 process (data: object, jobId: number): Promise<T> 9 process (data: object, jobId: number): Promise<T>
diff --git a/server/lib/video-channel.ts b/server/lib/video-channel.ts
index 6f9ae2d95..5bb1814ea 100644
--- a/server/lib/video-channel.ts
+++ b/server/lib/video-channel.ts
@@ -1,11 +1,9 @@
1import * as Sequelize from 'sequelize' 1import * as Sequelize from 'sequelize'
2 2import { VideoChannelCreate } from '../../shared/models'
3import { database as db } from '../initializers'
4import { logger } from '../helpers' 3import { logger } from '../helpers'
4import { getActivityPubUrl } from '../helpers/activitypub'
5import { database as db } from '../initializers'
5import { AccountInstance } from '../models' 6import { AccountInstance } from '../models'
6import { VideoChannelCreate } from '../../shared/models'
7import { sendCreateVideoChannel } from './activitypub/send-request'
8import { getActivityPubUrl, shareVideoChannelByServer } from '../helpers/activitypub'
9 7
10async function createVideoChannel (videoChannelInfo: VideoChannelCreate, account: AccountInstance, t: Sequelize.Transaction) { 8async function createVideoChannel (videoChannelInfo: VideoChannelCreate, account: AccountInstance, t: Sequelize.Transaction) {
11 const videoChannelData = { 9 const videoChannelData = {
diff --git a/server/middlewares/validators/account.ts b/server/middlewares/validators/account.ts
index 58eeed3cc..07ae76b63 100644
--- a/server/middlewares/validators/account.ts
+++ b/server/middlewares/validators/account.ts
@@ -1,13 +1,6 @@
1import * as express from 'express' 1import * as express from 'express'
2import { param } from 'express-validator/check' 2import { param } from 'express-validator/check'
3import { 3import { logger } from '../../helpers'
4 isUserDisplayNSFWValid,
5 isUserPasswordValid,
6 isUserRoleValid,
7 isUserUsernameValid,
8 isUserVideoQuotaValid,
9 logger
10} from '../../helpers'
11import { isAccountNameValid } from '../../helpers/custom-validators/accounts' 4import { isAccountNameValid } from '../../helpers/custom-validators/accounts'
12import { database as db } from '../../initializers/database' 5import { database as db } from '../../initializers/database'
13import { AccountInstance } from '../../models' 6import { AccountInstance } from '../../models'
diff --git a/server/middlewares/validators/webfinger.ts b/server/middlewares/validators/webfinger.ts
index 068e03ad7..3e61a6cc3 100644
--- a/server/middlewares/validators/webfinger.ts
+++ b/server/middlewares/validators/webfinger.ts
@@ -14,7 +14,7 @@ const webfingerValidator = [
14 checkErrors(req, res, () => { 14 checkErrors(req, res, () => {
15 // Remove 'acct:' from the beginning of the string 15 // Remove 'acct:' from the beginning of the string
16 const nameWithHost = req.query.resource.substr(5) 16 const nameWithHost = req.query.resource.substr(5)
17 const [ name, ] = nameWithHost.split('@') 17 const [ name ] = nameWithHost.split('@')
18 18
19 db.Account.loadLocalByName(name) 19 db.Account.loadLocalByName(name)
20 .then(account => { 20 .then(account => {
diff --git a/server/models/account/account-video-rate-interface.ts b/server/models/account/account-video-rate-interface.ts
index 82cbe38cc..316056246 100644
--- a/server/models/account/account-video-rate-interface.ts
+++ b/server/models/account/account-video-rate-interface.ts
@@ -17,10 +17,12 @@ export interface AccountVideoRateAttributes {
17 videoId: number 17 videoId: number
18} 18}
19 19
20export interface AccountVideoRateInstance extends AccountVideoRateClass, AccountVideoRateAttributes, Sequelize.Instance<AccountVideoRateAttributes> { 20export interface AccountVideoRateInstance
21 extends AccountVideoRateClass, AccountVideoRateAttributes, Sequelize.Instance<AccountVideoRateAttributes> {
21 id: number 22 id: number
22 createdAt: Date 23 createdAt: Date
23 updatedAt: Date 24 updatedAt: Date
24} 25}
25 26
26export interface AccountVideoRateModel extends AccountVideoRateClass, Sequelize.Model<AccountVideoRateInstance, AccountVideoRateAttributes> {} 27export interface AccountVideoRateModel
28 extends AccountVideoRateClass, Sequelize.Model<AccountVideoRateInstance, AccountVideoRateAttributes> {}
diff --git a/server/models/account/account.ts b/server/models/account/account.ts
index c370e1709..faf5fa841 100644
--- a/server/models/account/account.ts
+++ b/server/models/account/account.ts
@@ -1,29 +1,24 @@
1import * as Sequelize from 'sequelize' 1import * as Sequelize from 'sequelize'
2 2
3import { 3import {
4 isUserUsernameValid, 4 activityPubContextify,
5 isAccountPublicKeyValid,
6 isAccountUrlValid,
7 isAccountPrivateKeyValid,
8 isAccountFollowersCountValid, 5 isAccountFollowersCountValid,
6 isAccountFollowersValid,
9 isAccountFollowingCountValid, 7 isAccountFollowingCountValid,
8 isAccountFollowingValid,
10 isAccountInboxValid, 9 isAccountInboxValid,
11 isAccountOutboxValid, 10 isAccountOutboxValid,
11 isAccountPrivateKeyValid,
12 isAccountPublicKeyValid,
12 isAccountSharedInboxValid, 13 isAccountSharedInboxValid,
13 isAccountFollowersValid, 14 isAccountUrlValid,
14 isAccountFollowingValid, 15 isUserUsernameValid
15 activityPubContextify
16} from '../../helpers' 16} from '../../helpers'
17
18import { addMethodsToModel, getSort } from '../utils'
19import {
20 AccountInstance,
21 AccountAttributes,
22
23 AccountMethods
24} from './account-interface'
25import { sendDeleteAccount } from '../../lib/activitypub/send-request'
26import { CONFIG, CONSTRAINTS_FIELDS } from '../../initializers/constants' 17import { CONFIG, CONSTRAINTS_FIELDS } from '../../initializers/constants'
18import { sendDeleteAccount } from '../../lib/activitypub/send-request'
19
20import { addMethodsToModel } from '../utils'
21import { AccountAttributes, AccountInstance, AccountMethods } from './account-interface'
27 22
28let Account: Sequelize.Model<AccountInstance, AccountAttributes> 23let Account: Sequelize.Model<AccountInstance, AccountAttributes>
29let loadAccountByServerAndUUID: AccountMethods.LoadAccountByServerAndUUID 24let loadAccountByServerAndUUID: AccountMethods.LoadAccountByServerAndUUID
diff --git a/server/tests/api/check-params/follows.ts b/server/tests/api/check-params/follows.ts
index d742200c1..a215e7b1a 100644
--- a/server/tests/api/check-params/follows.ts
+++ b/server/tests/api/check-params/follows.ts
@@ -1,17 +1,16 @@
1/* tslint:disable:no-unused-expression */ 1/* tslint:disable:no-unused-expression */
2 2
3import * as request from 'supertest'
4import 'mocha' 3import 'mocha'
4import * as request from 'supertest'
5 5
6import { 6import {
7 ServerInfo,
8 flushTests,
9 runServer,
10 createUser, 7 createUser,
11 loginAndGetAccessToken, 8 flushTests,
12 setAccessTokensToServers,
13 killallServers, 9 killallServers,
14 makePostBodyRequest 10 loginAndGetAccessToken,
11 runServer,
12 ServerInfo,
13 setAccessTokensToServers
15} from '../../utils' 14} from '../../utils'
16 15
17describe('Test server follows API validators', function () { 16describe('Test server follows API validators', function () {
diff --git a/server/tests/api/index-slow.ts b/server/tests/api/index-slow.ts
index e554c25f8..b3c3d778c 100644
--- a/server/tests/api/index-slow.ts
+++ b/server/tests/api/index-slow.ts
@@ -1,3 +1,3 @@
1// Order of the tests we want to execute 1// Order of the tests we want to execute
2import './multiple-servers' 2// import './multiple-servers'
3import './video-transcoder' 3import './video-transcoder'