pull/128/head
Chocobozzz 2017-11-17 15:52:26 +01:00
parent 572f8d3dba
commit 79d5caf994
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
20 changed files with 49 additions and 95 deletions

View File

@ -2,7 +2,7 @@ import * as express from 'express'
import { Activity, ActivityPubCollection, ActivityPubOrderedCollection, ActivityType, RootActivity } from '../../../shared'
import { logger } from '../../helpers'
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 { processAddActivity } from '../../lib/activitypub/process-add'
import { processAnnounceActivity } from '../../lib/activitypub/process-announce'
@ -16,7 +16,6 @@ const processActivity: { [ P in ActivityType ]: (activity: Activity, inboxAccoun
Create: processCreateActivity,
Add: processAddActivity,
Update: processUpdateActivity,
Flag: processFlagActivity,
Delete: processDeleteActivity,
Follow: processFollowActivity,
Accept: processAcceptActivity,

View File

@ -1,8 +1,4 @@
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 { AccountInstance } from '../models/account/account-interface'

View File

@ -1,25 +1,23 @@
import { values } from 'lodash'
import * as validator from 'validator'
import * as Promise from 'bluebird'
import * as express from 'express'
import 'express-validator'
import { values } from 'lodash'
import 'multer'
import * as validator from 'validator'
import { VideoRateType } from '../../../shared'
import { logger } from '../../helpers'
import {
CONSTRAINTS_FIELDS,
database as db,
VIDEO_CATEGORIES,
VIDEO_LICENCES,
VIDEO_LANGUAGES,
VIDEO_RATE_TYPES,
VIDEO_LICENCES,
VIDEO_PRIVACIES,
database as db
VIDEO_RATE_TYPES
} from '../../initializers'
import { isUserUsernameValid } from './users'
import { isArray, exists } from './misc'
import { VideoInstance } from '../../models'
import { logger } from '../../helpers'
import { VideoRateType } from '../../../shared'
import { isActivityPubUrlValid } from './activitypub/misc'
import { exists, isArray } from './misc'
const VIDEOS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEOS
const VIDEO_ABUSES_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_ABUSES

View File

@ -3,7 +3,6 @@ export * from './process-add'
export * from './process-announce'
export * from './process-create'
export * from './process-delete'
export * from './process-flag'
export * from './process-follow'
export * from './process-update'
export * from './send-request'

View File

@ -17,7 +17,7 @@ async function processAddActivity (activity: ActivityAdd) {
const videoChannelUrl = activity.target
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 })
@ -68,7 +68,7 @@ function addRemoteVideo (
const videoCreated = await video.save(sequelizeOptions)
const videoFileAttributes = await videoFileActivityUrlToDBAttributes(videoCreated, videoToCreateData)
const videoFileAttributes = videoFileActivityUrlToDBAttributes(videoCreated, videoToCreateData)
if (videoFileAttributes.length === 0) {
throw new Error('Cannot find valid files for video %s ' + videoToCreateData.url)
}

View File

@ -1,13 +1,11 @@
import { ActivityAnnounce } from '../../../shared/models/activitypub/activity'
import { VideoChannelObject } from '../../../shared/models/activitypub/objects/video-channel-object'
import { VideoTorrentObject } from '../../../shared/models/activitypub/objects/video-torrent-object'
import { getOrCreateAccount } from '../../helpers/activitypub'
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 { 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) {
const announcedActivity = activity.object

View File

@ -72,7 +72,7 @@ function addRemoteVideoAbuse (account: AccountInstance, videoAbuseToCreateData:
const video = await db.Video.loadByUrlAndPopulateAccount(videoAbuseToCreateData.object, t)
if (!video) {
logger.warn('Unknown video %s for remote video abuse.', videoAbuseToCreateData.object)
return
return undefined
}
const videoAbuseData = {

View File

@ -28,7 +28,7 @@ async function processDeleteActivity (activity: ActivityDelete) {
}
}
return undefined
return
}
// ---------------------------------------------------------------------------

View File

@ -1,17 +0,0 @@
import {
ActivityCreate,
VideoTorrentObject,
VideoChannelObject
} from '../../../shared'
function processFlagActivity (activity: ActivityCreate) {
return Promise.resolve(undefined)
}
// ---------------------------------------------------------------------------
export {
processFlagActivity
}
// ---------------------------------------------------------------------------

View File

@ -80,7 +80,7 @@ async function updateRemoteVideo (account: AccountInstance, videoAttributesToUpd
}
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))
await Promise.all(tasks)

View File

@ -147,7 +147,7 @@ async function broadcastToFollowers (data: any, byAccount: AccountInstance, toAc
const result = await db.AccountFollow.listAcceptedFollowerSharedInboxUrls(toAccountFollowerIds)
if (result.data.length === 0) {
logger.info('Not broadcast because of 0 followers for %s.', toAccountFollowerIds.join(', '))
return
return undefined
}
const jobPayload = {

View File

@ -4,7 +4,6 @@ import { JobCategory } from '../../../shared'
import { logger } from '../../helpers'
import { database as db, JOB_STATES, JOBS_FETCH_LIMIT_PER_CYCLE, JOBS_FETCHING_INTERVAL } from '../../initializers'
import { JobInstance } from '../../models'
import { error } from 'util'
export interface JobHandler<P, T> {
process (data: object, jobId: number): Promise<T>

View File

@ -1,11 +1,9 @@
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 { sendCreateVideoChannel } from './activitypub/send-request'
import { getActivityPubUrl, shareVideoChannelByServer } from '../helpers/activitypub'
import { logger } from '../helpers'
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) {
const videoChannelData = {

View File

@ -1,13 +1,6 @@
import * as express from 'express'
import { param } from 'express-validator/check'
import {
isUserDisplayNSFWValid,
isUserPasswordValid,
isUserRoleValid,
isUserUsernameValid,
isUserVideoQuotaValid,
logger
} from '../../helpers'
import { logger } from '../../helpers'
import { isAccountNameValid } from '../../helpers/custom-validators/accounts'
import { database as db } from '../../initializers/database'
import { AccountInstance } from '../../models'

View File

@ -14,7 +14,7 @@ const webfingerValidator = [
checkErrors(req, res, () => {
// Remove 'acct:' from the beginning of the string
const nameWithHost = req.query.resource.substr(5)
const [ name, ] = nameWithHost.split('@')
const [ name ] = nameWithHost.split('@')
db.Account.loadLocalByName(name)
.then(account => {

View File

@ -17,10 +17,12 @@ export interface AccountVideoRateAttributes {
videoId: number
}
export interface AccountVideoRateInstance extends AccountVideoRateClass, AccountVideoRateAttributes, Sequelize.Instance<AccountVideoRateAttributes> {
export interface AccountVideoRateInstance
extends AccountVideoRateClass, AccountVideoRateAttributes, Sequelize.Instance<AccountVideoRateAttributes> {
id: number
createdAt: Date
updatedAt: Date
}
export interface AccountVideoRateModel extends AccountVideoRateClass, Sequelize.Model<AccountVideoRateInstance, AccountVideoRateAttributes> {}
export interface AccountVideoRateModel
extends AccountVideoRateClass, Sequelize.Model<AccountVideoRateInstance, AccountVideoRateAttributes> {}

View File

@ -1,29 +1,24 @@
import * as Sequelize from 'sequelize'
import {
isUserUsernameValid,
isAccountPublicKeyValid,
isAccountUrlValid,
isAccountPrivateKeyValid,
activityPubContextify,
isAccountFollowersCountValid,
isAccountFollowersValid,
isAccountFollowingCountValid,
isAccountFollowingValid,
isAccountInboxValid,
isAccountOutboxValid,
isAccountPrivateKeyValid,
isAccountPublicKeyValid,
isAccountSharedInboxValid,
isAccountFollowersValid,
isAccountFollowingValid,
activityPubContextify
isAccountUrlValid,
isUserUsernameValid
} 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 { sendDeleteAccount } from '../../lib/activitypub/send-request'
import { addMethodsToModel } from '../utils'
import { AccountAttributes, AccountInstance, AccountMethods } from './account-interface'
let Account: Sequelize.Model<AccountInstance, AccountAttributes>
let loadAccountByServerAndUUID: AccountMethods.LoadAccountByServerAndUUID

View File

@ -1,17 +1,16 @@
/* tslint:disable:no-unused-expression */
import * as request from 'supertest'
import 'mocha'
import * as request from 'supertest'
import {
ServerInfo,
flushTests,
runServer,
createUser,
loginAndGetAccessToken,
setAccessTokensToServers,
flushTests,
killallServers,
makePostBodyRequest
loginAndGetAccessToken,
runServer,
ServerInfo,
setAccessTokensToServers
} from '../../utils'
describe('Test server follows API validators', function () {

View File

@ -1,3 +1,3 @@
// Order of the tests we want to execute
import './multiple-servers'
// import './multiple-servers'
import './video-transcoder'

View File

@ -2,11 +2,11 @@ import { VideoChannelObject, VideoTorrentObject } from './objects'
import { ActivityPubSignature } from './activitypub-signature'
import { VideoAbuseObject } from './objects/video-abuse-object'
export type Activity = ActivityCreate | ActivityAdd | ActivityUpdate | ActivityFlag |
export type Activity = ActivityCreate | ActivityAdd | ActivityUpdate |
ActivityDelete | ActivityFollow | ActivityAccept | ActivityAnnounce
// 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 {
'@context'?: any[]
@ -34,11 +34,6 @@ export interface ActivityUpdate extends BaseActivity {
object: VideoTorrentObject | VideoChannelObject
}
export interface ActivityFlag extends BaseActivity {
type: 'Flag'
object: string
}
export interface ActivityDelete extends BaseActivity {
type: 'Delete'
}