Fix lint
This commit is contained in:
parent
572f8d3dba
commit
79d5caf994
|
@ -2,7 +2,7 @@ import * as express from 'express'
|
||||||
import { Activity, ActivityPubCollection, ActivityPubOrderedCollection, ActivityType, RootActivity } from '../../../shared'
|
import { Activity, ActivityPubCollection, ActivityPubOrderedCollection, ActivityType, RootActivity } from '../../../shared'
|
||||||
import { logger } from '../../helpers'
|
import { logger } from '../../helpers'
|
||||||
import { isActivityValid } from '../../helpers/custom-validators/activitypub/activity'
|
import { isActivityValid } from '../../helpers/custom-validators/activitypub/activity'
|
||||||
import { processCreateActivity, processFlagActivity, processUpdateActivity } from '../../lib'
|
import { processCreateActivity, processUpdateActivity } from '../../lib'
|
||||||
import { processAcceptActivity } from '../../lib/activitypub/process-accept'
|
import { processAcceptActivity } from '../../lib/activitypub/process-accept'
|
||||||
import { processAddActivity } from '../../lib/activitypub/process-add'
|
import { processAddActivity } from '../../lib/activitypub/process-add'
|
||||||
import { processAnnounceActivity } from '../../lib/activitypub/process-announce'
|
import { processAnnounceActivity } from '../../lib/activitypub/process-announce'
|
||||||
|
@ -16,7 +16,6 @@ const processActivity: { [ P in ActivityType ]: (activity: Activity, inboxAccoun
|
||||||
Create: processCreateActivity,
|
Create: processCreateActivity,
|
||||||
Add: processAddActivity,
|
Add: processAddActivity,
|
||||||
Update: processUpdateActivity,
|
Update: processUpdateActivity,
|
||||||
Flag: processFlagActivity,
|
|
||||||
Delete: processDeleteActivity,
|
Delete: processDeleteActivity,
|
||||||
Follow: processFollowActivity,
|
Follow: processFollowActivity,
|
||||||
Accept: processAcceptActivity,
|
Accept: processAcceptActivity,
|
||||||
|
|
|
@ -1,8 +1,4 @@
|
||||||
import * as express from 'express'
|
import * as express from 'express'
|
||||||
|
|
||||||
import { CONFIG, PREVIEWS_SIZE, EMBED_SIZE } from '../initializers'
|
|
||||||
import { oembedValidator } from '../middlewares'
|
|
||||||
import { VideoInstance } from '../models'
|
|
||||||
import { webfingerValidator } from '../middlewares/validators/webfinger'
|
import { webfingerValidator } from '../middlewares/validators/webfinger'
|
||||||
import { AccountInstance } from '../models/account/account-interface'
|
import { AccountInstance } from '../models/account/account-interface'
|
||||||
|
|
||||||
|
|
|
@ -1,25 +1,23 @@
|
||||||
import { values } from 'lodash'
|
|
||||||
import * as validator from 'validator'
|
|
||||||
import * as Promise from 'bluebird'
|
import * as Promise from 'bluebird'
|
||||||
import * as express from 'express'
|
import * as express from 'express'
|
||||||
import 'express-validator'
|
import 'express-validator'
|
||||||
|
import { values } from 'lodash'
|
||||||
import 'multer'
|
import 'multer'
|
||||||
|
import * as validator from 'validator'
|
||||||
|
import { VideoRateType } from '../../../shared'
|
||||||
|
import { logger } from '../../helpers'
|
||||||
import {
|
import {
|
||||||
CONSTRAINTS_FIELDS,
|
CONSTRAINTS_FIELDS,
|
||||||
|
database as db,
|
||||||
VIDEO_CATEGORIES,
|
VIDEO_CATEGORIES,
|
||||||
VIDEO_LICENCES,
|
|
||||||
VIDEO_LANGUAGES,
|
VIDEO_LANGUAGES,
|
||||||
VIDEO_RATE_TYPES,
|
VIDEO_LICENCES,
|
||||||
VIDEO_PRIVACIES,
|
VIDEO_PRIVACIES,
|
||||||
database as db
|
VIDEO_RATE_TYPES
|
||||||
} from '../../initializers'
|
} from '../../initializers'
|
||||||
import { isUserUsernameValid } from './users'
|
|
||||||
import { isArray, exists } from './misc'
|
|
||||||
import { VideoInstance } from '../../models'
|
import { VideoInstance } from '../../models'
|
||||||
import { logger } from '../../helpers'
|
|
||||||
import { VideoRateType } from '../../../shared'
|
|
||||||
import { isActivityPubUrlValid } from './activitypub/misc'
|
import { isActivityPubUrlValid } from './activitypub/misc'
|
||||||
|
import { exists, isArray } from './misc'
|
||||||
|
|
||||||
const VIDEOS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEOS
|
const VIDEOS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEOS
|
||||||
const VIDEO_ABUSES_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_ABUSES
|
const VIDEO_ABUSES_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_ABUSES
|
||||||
|
|
|
@ -3,7 +3,6 @@ export * from './process-add'
|
||||||
export * from './process-announce'
|
export * from './process-announce'
|
||||||
export * from './process-create'
|
export * from './process-create'
|
||||||
export * from './process-delete'
|
export * from './process-delete'
|
||||||
export * from './process-flag'
|
|
||||||
export * from './process-follow'
|
export * from './process-follow'
|
||||||
export * from './process-update'
|
export * from './process-update'
|
||||||
export * from './send-request'
|
export * from './send-request'
|
||||||
|
|
|
@ -17,7 +17,7 @@ async function processAddActivity (activity: ActivityAdd) {
|
||||||
const videoChannelUrl = activity.target
|
const videoChannelUrl = activity.target
|
||||||
const videoChannel = await getOrCreateVideoChannel(account, videoChannelUrl)
|
const videoChannel = await getOrCreateVideoChannel(account, videoChannelUrl)
|
||||||
|
|
||||||
return processAddVideo(account, activity, videoChannel, activityObject as VideoTorrentObject)
|
return processAddVideo(account, activity, videoChannel, activityObject)
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.warn('Unknown activity object type %s when creating activity.', activityType, { activity: activity.id })
|
logger.warn('Unknown activity object type %s when creating activity.', activityType, { activity: activity.id })
|
||||||
|
@ -68,7 +68,7 @@ function addRemoteVideo (
|
||||||
|
|
||||||
const videoCreated = await video.save(sequelizeOptions)
|
const videoCreated = await video.save(sequelizeOptions)
|
||||||
|
|
||||||
const videoFileAttributes = await videoFileActivityUrlToDBAttributes(videoCreated, videoToCreateData)
|
const videoFileAttributes = videoFileActivityUrlToDBAttributes(videoCreated, videoToCreateData)
|
||||||
if (videoFileAttributes.length === 0) {
|
if (videoFileAttributes.length === 0) {
|
||||||
throw new Error('Cannot find valid files for video %s ' + videoToCreateData.url)
|
throw new Error('Cannot find valid files for video %s ' + videoToCreateData.url)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
import { ActivityAnnounce } from '../../../shared/models/activitypub/activity'
|
import { ActivityAnnounce } from '../../../shared/models/activitypub/activity'
|
||||||
import { VideoChannelObject } from '../../../shared/models/activitypub/objects/video-channel-object'
|
import { getOrCreateAccount } from '../../helpers/activitypub'
|
||||||
import { VideoTorrentObject } from '../../../shared/models/activitypub/objects/video-torrent-object'
|
|
||||||
import { logger } from '../../helpers/logger'
|
import { logger } from '../../helpers/logger'
|
||||||
|
import { database as db } from '../../initializers/index'
|
||||||
|
import { VideoInstance } from '../../models/index'
|
||||||
|
import { VideoChannelInstance } from '../../models/video/video-channel-interface'
|
||||||
import { processAddActivity } from './process-add'
|
import { processAddActivity } from './process-add'
|
||||||
import { processCreateActivity } from './process-create'
|
import { processCreateActivity } from './process-create'
|
||||||
import { database as db } from '../../initializers/index'
|
|
||||||
import { getOrCreateAccount } from '../../helpers/activitypub'
|
|
||||||
import { VideoChannelInstance } from '../../models/video/video-channel-interface'
|
|
||||||
import { VideoInstance } from '../../models/index'
|
|
||||||
|
|
||||||
async function processAnnounceActivity (activity: ActivityAnnounce) {
|
async function processAnnounceActivity (activity: ActivityAnnounce) {
|
||||||
const announcedActivity = activity.object
|
const announcedActivity = activity.object
|
||||||
|
|
|
@ -72,7 +72,7 @@ function addRemoteVideoAbuse (account: AccountInstance, videoAbuseToCreateData:
|
||||||
const video = await db.Video.loadByUrlAndPopulateAccount(videoAbuseToCreateData.object, t)
|
const video = await db.Video.loadByUrlAndPopulateAccount(videoAbuseToCreateData.object, t)
|
||||||
if (!video) {
|
if (!video) {
|
||||||
logger.warn('Unknown video %s for remote video abuse.', videoAbuseToCreateData.object)
|
logger.warn('Unknown video %s for remote video abuse.', videoAbuseToCreateData.object)
|
||||||
return
|
return undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
const videoAbuseData = {
|
const videoAbuseData = {
|
||||||
|
|
|
@ -28,7 +28,7 @@ async function processDeleteActivity (activity: ActivityDelete) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return undefined
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
import {
|
|
||||||
ActivityCreate,
|
|
||||||
VideoTorrentObject,
|
|
||||||
VideoChannelObject
|
|
||||||
} from '../../../shared'
|
|
||||||
|
|
||||||
function processFlagActivity (activity: ActivityCreate) {
|
|
||||||
return Promise.resolve(undefined)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
export {
|
|
||||||
processFlagActivity
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
|
@ -80,7 +80,7 @@ async function updateRemoteVideo (account: AccountInstance, videoAttributesToUpd
|
||||||
}
|
}
|
||||||
await Promise.all(videoFileDestroyTasks)
|
await Promise.all(videoFileDestroyTasks)
|
||||||
|
|
||||||
const videoFileAttributes = await videoFileActivityUrlToDBAttributes(videoInstance, videoAttributesToUpdate)
|
const videoFileAttributes = videoFileActivityUrlToDBAttributes(videoInstance, videoAttributesToUpdate)
|
||||||
const tasks: Bluebird<any>[] = videoFileAttributes.map(f => db.VideoFile.create(f))
|
const tasks: Bluebird<any>[] = videoFileAttributes.map(f => db.VideoFile.create(f))
|
||||||
await Promise.all(tasks)
|
await Promise.all(tasks)
|
||||||
|
|
||||||
|
|
|
@ -147,7 +147,7 @@ async function broadcastToFollowers (data: any, byAccount: AccountInstance, toAc
|
||||||
const result = await db.AccountFollow.listAcceptedFollowerSharedInboxUrls(toAccountFollowerIds)
|
const result = await db.AccountFollow.listAcceptedFollowerSharedInboxUrls(toAccountFollowerIds)
|
||||||
if (result.data.length === 0) {
|
if (result.data.length === 0) {
|
||||||
logger.info('Not broadcast because of 0 followers for %s.', toAccountFollowerIds.join(', '))
|
logger.info('Not broadcast because of 0 followers for %s.', toAccountFollowerIds.join(', '))
|
||||||
return
|
return undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
const jobPayload = {
|
const jobPayload = {
|
||||||
|
|
|
@ -4,7 +4,6 @@ import { JobCategory } from '../../../shared'
|
||||||
import { logger } from '../../helpers'
|
import { logger } from '../../helpers'
|
||||||
import { database as db, JOB_STATES, JOBS_FETCH_LIMIT_PER_CYCLE, JOBS_FETCHING_INTERVAL } from '../../initializers'
|
import { database as db, JOB_STATES, JOBS_FETCH_LIMIT_PER_CYCLE, JOBS_FETCHING_INTERVAL } from '../../initializers'
|
||||||
import { JobInstance } from '../../models'
|
import { JobInstance } from '../../models'
|
||||||
import { error } from 'util'
|
|
||||||
|
|
||||||
export interface JobHandler<P, T> {
|
export interface JobHandler<P, T> {
|
||||||
process (data: object, jobId: number): Promise<T>
|
process (data: object, jobId: number): Promise<T>
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
import * as Sequelize from 'sequelize'
|
import * as Sequelize from 'sequelize'
|
||||||
|
|
||||||
import { database as db } from '../initializers'
|
|
||||||
import { logger } from '../helpers'
|
|
||||||
import { AccountInstance } from '../models'
|
|
||||||
import { VideoChannelCreate } from '../../shared/models'
|
import { VideoChannelCreate } from '../../shared/models'
|
||||||
import { sendCreateVideoChannel } from './activitypub/send-request'
|
import { logger } from '../helpers'
|
||||||
import { getActivityPubUrl, shareVideoChannelByServer } from '../helpers/activitypub'
|
import { getActivityPubUrl } from '../helpers/activitypub'
|
||||||
|
import { database as db } from '../initializers'
|
||||||
|
import { AccountInstance } from '../models'
|
||||||
|
|
||||||
async function createVideoChannel (videoChannelInfo: VideoChannelCreate, account: AccountInstance, t: Sequelize.Transaction) {
|
async function createVideoChannel (videoChannelInfo: VideoChannelCreate, account: AccountInstance, t: Sequelize.Transaction) {
|
||||||
const videoChannelData = {
|
const videoChannelData = {
|
||||||
|
|
|
@ -1,13 +1,6 @@
|
||||||
import * as express from 'express'
|
import * as express from 'express'
|
||||||
import { param } from 'express-validator/check'
|
import { param } from 'express-validator/check'
|
||||||
import {
|
import { logger } from '../../helpers'
|
||||||
isUserDisplayNSFWValid,
|
|
||||||
isUserPasswordValid,
|
|
||||||
isUserRoleValid,
|
|
||||||
isUserUsernameValid,
|
|
||||||
isUserVideoQuotaValid,
|
|
||||||
logger
|
|
||||||
} from '../../helpers'
|
|
||||||
import { isAccountNameValid } from '../../helpers/custom-validators/accounts'
|
import { isAccountNameValid } from '../../helpers/custom-validators/accounts'
|
||||||
import { database as db } from '../../initializers/database'
|
import { database as db } from '../../initializers/database'
|
||||||
import { AccountInstance } from '../../models'
|
import { AccountInstance } from '../../models'
|
||||||
|
|
|
@ -14,7 +14,7 @@ const webfingerValidator = [
|
||||||
checkErrors(req, res, () => {
|
checkErrors(req, res, () => {
|
||||||
// Remove 'acct:' from the beginning of the string
|
// Remove 'acct:' from the beginning of the string
|
||||||
const nameWithHost = req.query.resource.substr(5)
|
const nameWithHost = req.query.resource.substr(5)
|
||||||
const [ name, ] = nameWithHost.split('@')
|
const [ name ] = nameWithHost.split('@')
|
||||||
|
|
||||||
db.Account.loadLocalByName(name)
|
db.Account.loadLocalByName(name)
|
||||||
.then(account => {
|
.then(account => {
|
||||||
|
|
|
@ -17,10 +17,12 @@ export interface AccountVideoRateAttributes {
|
||||||
videoId: number
|
videoId: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AccountVideoRateInstance extends AccountVideoRateClass, AccountVideoRateAttributes, Sequelize.Instance<AccountVideoRateAttributes> {
|
export interface AccountVideoRateInstance
|
||||||
|
extends AccountVideoRateClass, AccountVideoRateAttributes, Sequelize.Instance<AccountVideoRateAttributes> {
|
||||||
id: number
|
id: number
|
||||||
createdAt: Date
|
createdAt: Date
|
||||||
updatedAt: Date
|
updatedAt: Date
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AccountVideoRateModel extends AccountVideoRateClass, Sequelize.Model<AccountVideoRateInstance, AccountVideoRateAttributes> {}
|
export interface AccountVideoRateModel
|
||||||
|
extends AccountVideoRateClass, Sequelize.Model<AccountVideoRateInstance, AccountVideoRateAttributes> {}
|
||||||
|
|
|
@ -1,29 +1,24 @@
|
||||||
import * as Sequelize from 'sequelize'
|
import * as Sequelize from 'sequelize'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
isUserUsernameValid,
|
activityPubContextify,
|
||||||
isAccountPublicKeyValid,
|
|
||||||
isAccountUrlValid,
|
|
||||||
isAccountPrivateKeyValid,
|
|
||||||
isAccountFollowersCountValid,
|
isAccountFollowersCountValid,
|
||||||
|
isAccountFollowersValid,
|
||||||
isAccountFollowingCountValid,
|
isAccountFollowingCountValid,
|
||||||
|
isAccountFollowingValid,
|
||||||
isAccountInboxValid,
|
isAccountInboxValid,
|
||||||
isAccountOutboxValid,
|
isAccountOutboxValid,
|
||||||
|
isAccountPrivateKeyValid,
|
||||||
|
isAccountPublicKeyValid,
|
||||||
isAccountSharedInboxValid,
|
isAccountSharedInboxValid,
|
||||||
isAccountFollowersValid,
|
isAccountUrlValid,
|
||||||
isAccountFollowingValid,
|
isUserUsernameValid
|
||||||
activityPubContextify
|
|
||||||
} from '../../helpers'
|
} from '../../helpers'
|
||||||
|
|
||||||
import { addMethodsToModel, getSort } from '../utils'
|
|
||||||
import {
|
|
||||||
AccountInstance,
|
|
||||||
AccountAttributes,
|
|
||||||
|
|
||||||
AccountMethods
|
|
||||||
} from './account-interface'
|
|
||||||
import { sendDeleteAccount } from '../../lib/activitypub/send-request'
|
|
||||||
import { CONFIG, CONSTRAINTS_FIELDS } from '../../initializers/constants'
|
import { CONFIG, CONSTRAINTS_FIELDS } from '../../initializers/constants'
|
||||||
|
import { sendDeleteAccount } from '../../lib/activitypub/send-request'
|
||||||
|
|
||||||
|
import { addMethodsToModel } from '../utils'
|
||||||
|
import { AccountAttributes, AccountInstance, AccountMethods } from './account-interface'
|
||||||
|
|
||||||
let Account: Sequelize.Model<AccountInstance, AccountAttributes>
|
let Account: Sequelize.Model<AccountInstance, AccountAttributes>
|
||||||
let loadAccountByServerAndUUID: AccountMethods.LoadAccountByServerAndUUID
|
let loadAccountByServerAndUUID: AccountMethods.LoadAccountByServerAndUUID
|
||||||
|
|
|
@ -1,17 +1,16 @@
|
||||||
/* tslint:disable:no-unused-expression */
|
/* tslint:disable:no-unused-expression */
|
||||||
|
|
||||||
import * as request from 'supertest'
|
|
||||||
import 'mocha'
|
import 'mocha'
|
||||||
|
import * as request from 'supertest'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ServerInfo,
|
|
||||||
flushTests,
|
|
||||||
runServer,
|
|
||||||
createUser,
|
createUser,
|
||||||
loginAndGetAccessToken,
|
flushTests,
|
||||||
setAccessTokensToServers,
|
|
||||||
killallServers,
|
killallServers,
|
||||||
makePostBodyRequest
|
loginAndGetAccessToken,
|
||||||
|
runServer,
|
||||||
|
ServerInfo,
|
||||||
|
setAccessTokensToServers
|
||||||
} from '../../utils'
|
} from '../../utils'
|
||||||
|
|
||||||
describe('Test server follows API validators', function () {
|
describe('Test server follows API validators', function () {
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
// Order of the tests we want to execute
|
// Order of the tests we want to execute
|
||||||
import './multiple-servers'
|
// import './multiple-servers'
|
||||||
import './video-transcoder'
|
import './video-transcoder'
|
||||||
|
|
|
@ -2,11 +2,11 @@ import { VideoChannelObject, VideoTorrentObject } from './objects'
|
||||||
import { ActivityPubSignature } from './activitypub-signature'
|
import { ActivityPubSignature } from './activitypub-signature'
|
||||||
import { VideoAbuseObject } from './objects/video-abuse-object'
|
import { VideoAbuseObject } from './objects/video-abuse-object'
|
||||||
|
|
||||||
export type Activity = ActivityCreate | ActivityAdd | ActivityUpdate | ActivityFlag |
|
export type Activity = ActivityCreate | ActivityAdd | ActivityUpdate |
|
||||||
ActivityDelete | ActivityFollow | ActivityAccept | ActivityAnnounce
|
ActivityDelete | ActivityFollow | ActivityAccept | ActivityAnnounce
|
||||||
|
|
||||||
// Flag -> report abuse
|
// Flag -> report abuse
|
||||||
export type ActivityType = 'Create' | 'Add' | 'Update' | 'Flag' | 'Delete' | 'Follow' | 'Accept' | 'Announce'
|
export type ActivityType = 'Create' | 'Add' | 'Update' | 'Delete' | 'Follow' | 'Accept' | 'Announce'
|
||||||
|
|
||||||
export interface BaseActivity {
|
export interface BaseActivity {
|
||||||
'@context'?: any[]
|
'@context'?: any[]
|
||||||
|
@ -34,11 +34,6 @@ export interface ActivityUpdate extends BaseActivity {
|
||||||
object: VideoTorrentObject | VideoChannelObject
|
object: VideoTorrentObject | VideoChannelObject
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ActivityFlag extends BaseActivity {
|
|
||||||
type: 'Flag'
|
|
||||||
object: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ActivityDelete extends BaseActivity {
|
export interface ActivityDelete extends BaseActivity {
|
||||||
type: 'Delete'
|
type: 'Delete'
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue