Rename Pod -> Server
authorChocobozzz <florian.bigard@gmail.com>
Wed, 15 Nov 2017 10:00:25 +0000 (11:00 +0100)
committerChocobozzz <florian.bigard@gmail.com>
Mon, 27 Nov 2017 18:40:51 +0000 (19:40 +0100)
82 files changed:
client/src/app/+admin/follows/followers-list/followers-list.component.ts
client/src/app/+admin/follows/following-add/following-add.component.html
client/src/app/+admin/follows/following-add/following-add.component.ts
client/src/app/+admin/follows/following-list/following-list.component.ts
client/src/app/+admin/follows/shared/follow.service.ts
client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.html
client/src/app/videos/+video-watch/video-watch.component.html
client/src/app/videos/shared/video-details.model.ts
client/src/app/videos/shared/video.model.ts
server/controllers/activitypub/pods.ts [deleted file]
server/controllers/activitypub/videos.ts [deleted file]
server/controllers/api/application/follows.ts [deleted file]
server/controllers/api/application/index.ts [deleted file]
server/controllers/api/index.ts
server/controllers/api/server/follows.ts [new file with mode: 0644]
server/controllers/api/server/index.ts [new file with mode: 0644]
server/controllers/api/videos/abuse.ts
server/controllers/api/videos/index.ts
server/controllers/api/videos/rate.ts
server/controllers/client.ts
server/controllers/static.ts
server/helpers/activitypub.ts
server/helpers/custom-validators/accounts.ts
server/helpers/custom-validators/index.ts
server/helpers/custom-validators/pods.ts [deleted file]
server/helpers/custom-validators/servers.ts [new file with mode: 0644]
server/helpers/custom-validators/videos.ts
server/helpers/webfinger.ts
server/initializers/constants.ts
server/initializers/database.ts
server/lib/cache/videos-preview-cache.ts
server/lib/jobs/transcoding-job-scheduler/video-file-optimizer-handler.ts
server/lib/jobs/transcoding-job-scheduler/video-file-transcoder-handler.ts
server/lib/user.ts
server/lib/video-channel.ts
server/middlewares/activitypub.ts
server/middlewares/index.ts
server/middlewares/pods.ts [deleted file]
server/middlewares/servers.ts [new file with mode: 0644]
server/middlewares/sort.ts
server/middlewares/validators/index.ts
server/middlewares/validators/pods.ts [deleted file]
server/middlewares/validators/servers.ts [new file with mode: 0644]
server/middlewares/validators/video-channels.ts
server/middlewares/validators/videos.ts
server/models/account/account-follow.ts
server/models/account/account-interface.ts
server/models/account/account.ts
server/models/index.ts
server/models/pod/index.ts [deleted file]
server/models/pod/pod-interface.ts [deleted file]
server/models/pod/pod.ts [deleted file]
server/models/server/index.ts [new file with mode: 0644]
server/models/server/server-interface.ts [new file with mode: 0644]
server/models/server/server.ts [new file with mode: 0644]
server/models/video/video-abuse-interface.ts
server/models/video/video-abuse.ts
server/models/video/video-channel-interface.ts
server/models/video/video-channel.ts
server/models/video/video-interface.ts
server/models/video/video.ts
shared/models/accounts/follow.model.ts
shared/models/index.ts
shared/models/pods/index.ts [deleted file]
shared/models/pods/pod-signature.model.ts [deleted file]
shared/models/pods/pod.model.ts [deleted file]
shared/models/pods/remote-video/index.ts [deleted file]
shared/models/pods/remote-video/remote-qadu-video-request.model.ts [deleted file]
shared/models/pods/remote-video/remote-video-author-create-request.model.ts [deleted file]
shared/models/pods/remote-video/remote-video-author-remove-request.model.ts [deleted file]
shared/models/pods/remote-video/remote-video-channel-create-request.model.ts [deleted file]
shared/models/pods/remote-video/remote-video-channel-remove-request.model.ts [deleted file]
shared/models/pods/remote-video/remote-video-channel-update-request.model.ts [deleted file]
shared/models/pods/remote-video/remote-video-create-request.model.ts [deleted file]
shared/models/pods/remote-video/remote-video-event-request.model.ts [deleted file]
shared/models/pods/remote-video/remote-video-remove-request.model.ts [deleted file]
shared/models/pods/remote-video/remote-video-report-abuse-request.model.ts [deleted file]
shared/models/pods/remote-video/remote-video-request.model.ts [deleted file]
shared/models/pods/remote-video/remote-video-update-request.model.ts [deleted file]
shared/models/request-scheduler.model.ts [deleted file]
shared/models/videos/video-abuse.model.ts
shared/models/videos/video.model.ts

index 208a0c648464c82371770361b128847bac5fe98f..8dc2d9317c893d3e798d5f29e8d0a07d0bb1b900 100644 (file)
@@ -1,11 +1,9 @@
-import { Component, OnInit } from '@angular/core'
+import { Component } from '@angular/core'
 
 import { NotificationsService } from 'angular2-notifications'
 import { SortMeta } from 'primeng/primeng'
-
-import { ConfirmService } from '../../../core'
-import { RestTable, RestPagination } from '../../../shared'
-import { Pod } from '../../../../../../shared'
+import { AccountFollow } from '../../../../../../shared/models/accounts/follow.model'
+import { RestPagination, RestTable } from '../../../shared'
 import { FollowService } from '../shared'
 
 @Component({
@@ -14,7 +12,7 @@ import { FollowService } from '../shared'
   styleUrls: [ './followers-list.component.scss' ]
 })
 export class FollowersListComponent extends RestTable {
-  followers: Pod[] = []
+  followers: AccountFollow[] = []
   totalRecords = 0
   rowsPerPage = 10
   sort: SortMeta = { field: 'createdAt', order: 1 }
index 111f6a8dee62b590c5d94ca3c8ec6fbc7ba6b8b1..8e7dddc110e5432362a3e586851d05b260eb5890 100644 (file)
@@ -26,7 +26,7 @@
       </div>
 
       <div *ngIf="canMakeFriends() === false"  class="alert alert-warning">
-        It seems that you are not on a HTTPS pod. Your webserver need to have TLS activated in order to follow servers.
+        It seems that you are not on a HTTPS server. Your webserver need to have TLS activated in order to follow servers.
       </div>
 
       <input type="submit" value="Add following" class="btn btn-default" [disabled]="!isFormValid()">
index d95d6afa9b8c28ccc5304d92c127e39181bf6825..0ceb4c1dbaadd0061b0821a58f8a0f3081c1694a 100644 (file)
@@ -94,8 +94,6 @@ export class FollowingAddComponent implements OnInit {
         this.followService.follow(notEmptyHosts).subscribe(
           status => {
             this.notificationsService.success('Success', 'Follow request(s) sent!')
-            // Wait requests between pods
-            setTimeout(() => this.router.navigate([ '/admin/friends/list' ]), 1000)
           },
 
           err => this.notificationsService.error('Error', err.message)
index 7d2c5084b344b6f7e822d8deb30f8f302ea92347..a1dff1db3cef288ca4ebb99903a05e24a7bda65d 100644 (file)
@@ -1,11 +1,8 @@
-import { Component, OnInit } from '@angular/core'
-
+import { Component } from '@angular/core'
 import { NotificationsService } from 'angular2-notifications'
 import { SortMeta } from 'primeng/primeng'
-
-import { ConfirmService } from '../../../core'
-import { RestTable, RestPagination } from '../../../shared'
-import { Pod } from '../../../../../../shared'
+import { AccountFollow } from '../../../../../../shared/models/accounts/follow.model'
+import { RestPagination, RestTable } from '../../../shared'
 import { FollowService } from '../shared'
 
 @Component({
@@ -13,7 +10,7 @@ import { FollowService } from '../shared'
   templateUrl: './following-list.component.html'
 })
 export class FollowingListComponent extends RestTable {
-  following: Pod[] = []
+  following: AccountFollow[] = []
   totalRecords = 0
   rowsPerPage = 10
   sort: SortMeta = { field: 'createdAt', order: 1 }
index 622c33cea439e6fca5e2df02281a8972936b7a51..3dc91dfcae33dbc44b63e4c711a8cd68df6cab31 100644 (file)
@@ -7,7 +7,7 @@ import 'rxjs/add/operator/map'
 import { SortMeta } from 'primeng/primeng'
 
 import { RestExtractor, RestPagination, RestService } from '../../../shared'
-import { Pod, ResultList } from '../../../../../../shared'
+import { AccountFollow, ResultList } from '../../../../../../shared'
 
 @Injectable()
 export class FollowService {
@@ -19,7 +19,7 @@ export class FollowService {
     private restExtractor: RestExtractor
   ) {}
 
-  getFollowing (pagination: RestPagination, sort: SortMeta): Observable<ResultList<Pod>> {
+  getFollowing (pagination: RestPagination, sort: SortMeta): Observable<ResultList<AccountFollow>> {
     let params = new HttpParams()
     params = this.restService.addRestGetParams(params, pagination, sort)
 
@@ -28,7 +28,7 @@ export class FollowService {
                         .catch(res => this.restExtractor.handleError(res))
   }
 
-  getFollowers (pagination: RestPagination, sort: SortMeta): Observable<ResultList<Pod>> {
+  getFollowers (pagination: RestPagination, sort: SortMeta): Observable<ResultList<AccountFollow>> {
     let params = new HttpParams()
     params = this.restService.addRestGetParams(params, pagination, sort)
 
index e73f38112cba651eb7bef29ba7884f50b3d44ac4..1d8bb4d38ee903a92342185b5022f2c3e24422a4 100644 (file)
@@ -9,7 +9,7 @@
   >
     <p-column field="id" header="ID" [sortable]="true"></p-column>
     <p-column field="reason" header="Reason"></p-column>
-    <p-column field="reporterPodHost" header="Reporter pod host"></p-column>
+    <p-column field="reporterServerHost" header="Reporter server host"></p-column>
     <p-column field="reporterUsername" header="Reporter username"></p-column>
     <p-column header="Video" styleClass="action-cell">
       <ng-template pTemplate="body" let-videoAbuse="rowData">
index ee7bbec743beb1b99020d4338fbd920b9bb12d18..fd3ce2b84febc4ee3b93a5366acede0002ffa95b 100644 (file)
@@ -2,7 +2,7 @@
   <div class="alert alert-danger">
     The video load seems to be abnormally long.
     <ul>
-      <li>Maybe the server {{ video.podHost }} is down :(</li>
+      <li>Maybe the server {{ video.serverHost }} is down :(</li>
       <li>
         If not, you can report an issue on
         <a href="https://github.com/Chocobozzz/PeerTube/issues" title="Report an issue">
index f4ae64dc19f4225b69a389df31e35dd05623c5c1..64cb4f847fb528c8efaa1451537eced15cebc2df 100644 (file)
@@ -27,7 +27,7 @@ export class VideoDetails extends Video implements VideoDetailsServerModel {
   uuid: string
   isLocal: boolean
   name: string
-  podHost: string
+  serverHost: string
   tags: string[]
   thumbnailPath: string
   thumbnailUrl: string
index 2cad4a04e2b3632e75d9d11d8eff3c92392eaf29..0dd41d71b04bd51605bb5b6892e289d2b27bc7f8 100644 (file)
@@ -19,7 +19,7 @@ export class Video implements VideoServerModel {
   uuid: string
   isLocal: boolean
   name: string
-  podHost: string
+  serverHost: string
   tags: string[]
   thumbnailPath: string
   thumbnailUrl: string
@@ -32,8 +32,8 @@ export class Video implements VideoServerModel {
   dislikes: number
   nsfw: boolean
 
-  private static createByString (account: string, podHost: string) {
-    return account + '@' + podHost
+  private static createByString (account: string, serverHost: string) {
+    return account + '@' + serverHost
   }
 
   private static createDurationString (duration: number) {
@@ -67,7 +67,7 @@ export class Video implements VideoServerModel {
     this.uuid = hash.uuid
     this.isLocal = hash.isLocal
     this.name = hash.name
-    this.podHost = hash.podHost
+    this.serverHost = hash.serverHost
     this.tags = hash.tags
     this.thumbnailPath = hash.thumbnailPath
     this.thumbnailUrl = absoluteAPIUrl + hash.thumbnailPath
@@ -80,7 +80,7 @@ export class Video implements VideoServerModel {
     this.dislikes = hash.dislikes
     this.nsfw = hash.nsfw
 
-    this.by = Video.createByString(hash.account, hash.podHost)
+    this.by = Video.createByString(hash.account, hash.serverHost)
   }
 
   isVideoNSFWForUser (user: User) {
diff --git a/server/controllers/activitypub/pods.ts b/server/controllers/activitypub/pods.ts
deleted file mode 100644 (file)
index 6cce57c..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-// import * as express from 'express'
-//
-// import { database as db } from '../../../initializers/database'
-// import {
-//   checkSignature,
-//   signatureValidator,
-//   setBodyHostPort,
-//   remotePodsAddValidator,
-//   asyncMiddleware
-// } from '../../../middlewares'
-// import { sendOwnedDataToPod } from '../../../lib'
-// import { getMyPublicCert, getFormattedObjects } from '../../../helpers'
-// import { CONFIG } from '../../../initializers'
-// import { PodInstance } from '../../../models'
-// import { PodSignature, Pod as FormattedPod } from '../../../../shared'
-//
-// const remotePodsRouter = express.Router()
-//
-// remotePodsRouter.post('/remove',
-//   signatureValidator,
-//   checkSignature,
-//   asyncMiddleware(removePods)
-// )
-//
-// remotePodsRouter.post('/list',
-//   asyncMiddleware(remotePodsList)
-// )
-//
-// remotePodsRouter.post('/add',
-//   setBodyHostPort, // We need to modify the host before running the validator!
-//   remotePodsAddValidator,
-//   asyncMiddleware(addPods)
-// )
-//
-// // ---------------------------------------------------------------------------
-//
-// export {
-//   remotePodsRouter
-// }
-//
-// // ---------------------------------------------------------------------------
-//
-// async function addPods (req: express.Request, res: express.Response, next: express.NextFunction) {
-//   const information = req.body
-//
-//   const pod = db.Pod.build(information)
-//   const podCreated = await pod.save()
-//
-//   await sendOwnedDataToPod(podCreated.id)
-//
-//   const cert = await getMyPublicCert()
-//   return res.json({ cert, email: CONFIG.ADMIN.EMAIL })
-// }
-//
-// async function remotePodsList (req: express.Request, res: express.Response, next: express.NextFunction) {
-//   const pods = await db.Pod.list()
-//
-//   return res.json(getFormattedObjects<FormattedPod, PodInstance>(pods, pods.length))
-// }
-//
-// async function removePods (req: express.Request, res: express.Response, next: express.NextFunction) {
-//   const signature: PodSignature = req.body.signature
-//   const host = signature.host
-//
-//   const pod = await db.Pod.loadByHost(host)
-//   await pod.destroy()
-//
-//   return res.type('json').status(204).end()
-// }
diff --git a/server/controllers/activitypub/videos.ts b/server/controllers/activitypub/videos.ts
deleted file mode 100644 (file)
index 9889437..0000000
+++ /dev/null
@@ -1,278 +0,0 @@
-// import * as express from 'express'
-// import * as Bluebird from 'bluebird'
-// import * as Sequelize from 'sequelize'
-//
-// import { database as db } from '../../../initializers/database'
-// import {
-//   REQUEST_ENDPOINT_ACTIONS,
-//   REQUEST_ENDPOINTS,
-//   REQUEST_VIDEO_EVENT_TYPES,
-//   REQUEST_VIDEO_QADU_TYPES
-// } from '../../../initializers'
-// import {
-//   checkSignature,
-//   signatureValidator,
-//   remoteVideosValidator,
-//   remoteQaduVideosValidator,
-//   remoteEventsVideosValidator
-// } from '../../../middlewares'
-// import { logger, retryTransactionWrapper, resetSequelizeInstance } from '../../../helpers'
-// import { quickAndDirtyUpdatesVideoToFriends, fetchVideoChannelByHostAndUUID } from '../../../lib'
-// import { PodInstance, VideoFileInstance } from '../../../models'
-// import {
-//   RemoteVideoRequest,
-//   RemoteVideoCreateData,
-//   RemoteVideoUpdateData,
-//   RemoteVideoRemoveData,
-//   RemoteVideoReportAbuseData,
-//   RemoteQaduVideoRequest,
-//   RemoteQaduVideoData,
-//   RemoteVideoEventRequest,
-//   RemoteVideoEventData,
-//   RemoteVideoChannelCreateData,
-//   RemoteVideoChannelUpdateData,
-//   RemoteVideoChannelRemoveData,
-//   RemoteVideoAccountRemoveData,
-//   RemoteVideoAccountCreateData
-// } from '../../../../shared'
-// import { VideoInstance } from '../../../models/video/video-interface'
-//
-// const ENDPOINT_ACTIONS = REQUEST_ENDPOINT_ACTIONS[REQUEST_ENDPOINTS.VIDEOS]
-//
-// // Functions to call when processing a remote request
-// // FIXME: use RemoteVideoRequestType as id type
-// const functionsHash: { [ id: string ]: (...args) => Promise<any> } = {}
-// functionsHash[ENDPOINT_ACTIONS.ADD_VIDEO] = addRemoteVideoRetryWrapper
-// functionsHash[ENDPOINT_ACTIONS.UPDATE_VIDEO] = updateRemoteVideoRetryWrapper
-// functionsHash[ENDPOINT_ACTIONS.REMOVE_VIDEO] = removeRemoteVideoRetryWrapper
-// functionsHash[ENDPOINT_ACTIONS.ADD_CHANNEL] = addRemoteVideoChannelRetryWrapper
-// functionsHash[ENDPOINT_ACTIONS.UPDATE_CHANNEL] = updateRemoteVideoChannelRetryWrapper
-// functionsHash[ENDPOINT_ACTIONS.REMOVE_CHANNEL] = removeRemoteVideoChannelRetryWrapper
-// functionsHash[ENDPOINT_ACTIONS.REPORT_ABUSE] = reportAbuseRemoteVideoRetryWrapper
-// functionsHash[ENDPOINT_ACTIONS.ADD_ACCOUNT] = addRemoteVideoAccountRetryWrapper
-// functionsHash[ENDPOINT_ACTIONS.REMOVE_ACCOUNT] = removeRemoteVideoAccountRetryWrapper
-//
-// const remoteVideosRouter = express.Router()
-//
-// remoteVideosRouter.post('/',
-//   signatureValidator,
-//   checkSignature,
-//   remoteVideosValidator,
-//   remoteVideos
-// )
-//
-// remoteVideosRouter.post('/qadu',
-//   signatureValidator,
-//   checkSignature,
-//   remoteQaduVideosValidator,
-//   remoteVideosQadu
-// )
-//
-// remoteVideosRouter.post('/events',
-//   signatureValidator,
-//   checkSignature,
-//   remoteEventsVideosValidator,
-//   remoteVideosEvents
-// )
-//
-// // ---------------------------------------------------------------------------
-//
-// export {
-//   remoteVideosRouter
-// }
-//
-// // ---------------------------------------------------------------------------
-//
-// function remoteVideos (req: express.Request, res: express.Response, next: express.NextFunction) {
-//   const requests: RemoteVideoRequest[] = req.body.data
-//   const fromPod = res.locals.secure.pod
-//
-//   // We need to process in the same order to keep consistency
-//   Bluebird.each(requests, request => {
-//     const data = request.data
-//
-//     // Get the function we need to call in order to process the request
-//     const fun = functionsHash[request.type]
-//     if (fun === undefined) {
-//       logger.error('Unknown remote request type %s.', request.type)
-//       return
-//     }
-//
-//     return fun.call(this, data, fromPod)
-//   })
-//   .catch(err => logger.error('Error managing remote videos.', err))
-//
-//   // Don't block the other pod
-//   return res.type('json').status(204).end()
-// }
-//
-// function remoteVideosQadu (req: express.Request, res: express.Response, next: express.NextFunction) {
-//   const requests: RemoteQaduVideoRequest[] = req.body.data
-//   const fromPod = res.locals.secure.pod
-//
-//   Bluebird.each(requests, request => {
-//     const videoData = request.data
-//
-//     return quickAndDirtyUpdateVideoRetryWrapper(videoData, fromPod)
-//   })
-//   .catch(err => logger.error('Error managing remote videos.', err))
-//
-//   return res.type('json').status(204).end()
-// }
-//
-// function remoteVideosEvents (req: express.Request, res: express.Response, next: express.NextFunction) {
-//   const requests: RemoteVideoEventRequest[] = req.body.data
-//   const fromPod = res.locals.secure.pod
-//
-//   Bluebird.each(requests, request => {
-//     const eventData = request.data
-//
-//     return processVideosEventsRetryWrapper(eventData, fromPod)
-//   })
-//   .catch(err => logger.error('Error managing remote videos.', err))
-//
-//   return res.type('json').status(204).end()
-// }
-//
-// async function processVideosEventsRetryWrapper (eventData: RemoteVideoEventData, fromPod: PodInstance) {
-//   const options = {
-//     arguments: [ eventData, fromPod ],
-//     errorMessage: 'Cannot process videos events with many retries.'
-//   }
-//
-//   await retryTransactionWrapper(processVideosEvents, options)
-// }
-//
-// async function processVideosEvents (eventData: RemoteVideoEventData, fromPod: PodInstance) {
-//   await db.sequelize.transaction(async t => {
-//     const sequelizeOptions = { transaction: t }
-//     const videoInstance = await fetchLocalVideoByUUID(eventData.uuid, t)
-//
-//     let columnToUpdate
-//     let qaduType
-//
-//     switch (eventData.eventType) {
-//     case REQUEST_VIDEO_EVENT_TYPES.VIEWS:
-//       columnToUpdate = 'views'
-//       qaduType = REQUEST_VIDEO_QADU_TYPES.VIEWS
-//       break
-//
-//     case REQUEST_VIDEO_EVENT_TYPES.LIKES:
-//       columnToUpdate = 'likes'
-//       qaduType = REQUEST_VIDEO_QADU_TYPES.LIKES
-//       break
-//
-//     case REQUEST_VIDEO_EVENT_TYPES.DISLIKES:
-//       columnToUpdate = 'dislikes'
-//       qaduType = REQUEST_VIDEO_QADU_TYPES.DISLIKES
-//       break
-//
-//     default:
-//       throw new Error('Unknown video event type.')
-//     }
-//
-//     const query = {}
-//     query[columnToUpdate] = eventData.count
-//
-//     await videoInstance.increment(query, sequelizeOptions)
-//
-//     const qadusParams = [
-//       {
-//         videoId: videoInstance.id,
-//         type: qaduType
-//       }
-//     ]
-//     await quickAndDirtyUpdatesVideoToFriends(qadusParams, t)
-//   })
-//
-//   logger.info('Remote video event processed for video with uuid %s.', eventData.uuid)
-// }
-//
-// async function quickAndDirtyUpdateVideoRetryWrapper (videoData: RemoteQaduVideoData, fromPod: PodInstance) {
-//   const options = {
-//     arguments: [ videoData, fromPod ],
-//     errorMessage: 'Cannot update quick and dirty the remote video with many retries.'
-//   }
-//
-//   await retryTransactionWrapper(quickAndDirtyUpdateVideo, options)
-// }
-//
-// async function quickAndDirtyUpdateVideo (videoData: RemoteQaduVideoData, fromPod: PodInstance) {
-//   let videoUUID = ''
-//
-//   await db.sequelize.transaction(async t => {
-//     const videoInstance = await fetchVideoByHostAndUUID(fromPod.host, videoData.uuid, t)
-//     const sequelizeOptions = { transaction: t }
-//
-//     videoUUID = videoInstance.uuid
-//
-//     if (videoData.views) {
-//       videoInstance.set('views', videoData.views)
-//     }
-//
-//     if (videoData.likes) {
-//       videoInstance.set('likes', videoData.likes)
-//     }
-//
-//     if (videoData.dislikes) {
-//       videoInstance.set('dislikes', videoData.dislikes)
-//     }
-//
-//     await videoInstance.save(sequelizeOptions)
-//   })
-//
-//   logger.info('Remote video with uuid %s quick and dirty updated', videoUUID)
-// }
-//
-// async function reportAbuseRemoteVideoRetryWrapper (reportData: RemoteVideoReportAbuseData, fromPod: PodInstance) {
-//   const options = {
-//     arguments: [ reportData, fromPod ],
-//     errorMessage: 'Cannot create remote abuse video with many retries.'
-//   }
-//
-//   await retryTransactionWrapper(reportAbuseRemoteVideo, options)
-// }
-//
-// async function reportAbuseRemoteVideo (reportData: RemoteVideoReportAbuseData, fromPod: PodInstance) {
-//   logger.debug('Reporting remote abuse for video %s.', reportData.videoUUID)
-//
-//   await db.sequelize.transaction(async t => {
-//     const videoInstance = await fetchLocalVideoByUUID(reportData.videoUUID, t)
-//     const videoAbuseData = {
-//       reporterUsername: reportData.reporterUsername,
-//       reason: reportData.reportReason,
-//       reporterPodId: fromPod.id,
-//       videoId: videoInstance.id
-//     }
-//
-//     await db.VideoAbuse.create(videoAbuseData)
-//
-//   })
-//
-//   logger.info('Remote abuse for video uuid %s created', reportData.videoUUID)
-// }
-//
-// async function fetchLocalVideoByUUID (id: string, t: Sequelize.Transaction) {
-//   try {
-//     const video = await db.Video.loadLocalVideoByUUID(id, t)
-//
-//     if (!video) throw new Error('Video ' + id + ' not found')
-//
-//     return video
-//   } catch (err) {
-//     logger.error('Cannot load owned video from id.', { error: err.stack, id })
-//     throw err
-//   }
-// }
-//
-// async function fetchVideoByHostAndUUID (podHost: string, uuid: string, t: Sequelize.Transaction) {
-//   try {
-//     const video = await db.Video.loadByHostAndUUID(podHost, uuid, t)
-//     if (!video) throw new Error('Video not found')
-//
-//     return video
-//   } catch (err) {
-//     logger.error('Cannot load video from host and uuid.', { error: err.stack, podHost, uuid })
-//     throw err
-//   }
-// }
diff --git a/server/controllers/api/application/follows.ts b/server/controllers/api/application/follows.ts
deleted file mode 100644 (file)
index 000bbd2..0000000
+++ /dev/null
@@ -1,127 +0,0 @@
-import * as express from 'express'
-import { UserRight } from '../../../../shared/models/users/user-right.enum'
-import { getFormattedObjects } from '../../../helpers'
-import { logger } from '../../../helpers/logger'
-import { getApplicationAccount } from '../../../helpers/utils'
-import { getAccountFromWebfinger } from '../../../helpers/webfinger'
-import { SERVER_ACCOUNT_NAME } from '../../../initializers/constants'
-import { database as db } from '../../../initializers/database'
-import { sendFollow } from '../../../lib/activitypub/send-request'
-import { asyncMiddleware, paginationValidator, setFollowersSort, setPagination } from '../../../middlewares'
-import { authenticate } from '../../../middlewares/oauth'
-import { setBodyHostsPort } from '../../../middlewares/pods'
-import { setFollowingSort } from '../../../middlewares/sort'
-import { ensureUserHasRight } from '../../../middlewares/user-right'
-import { followValidator } from '../../../middlewares/validators/pods'
-import { followersSortValidator, followingSortValidator } from '../../../middlewares/validators/sort'
-
-const applicationFollowsRouter = express.Router()
-
-applicationFollowsRouter.get('/following',
-  paginationValidator,
-  followingSortValidator,
-  setFollowingSort,
-  setPagination,
-  asyncMiddleware(listFollowing)
-)
-
-applicationFollowsRouter.post('/follow',
-  authenticate,
-  ensureUserHasRight(UserRight.MANAGE_APPLICATION_FOLLOW),
-  followValidator,
-  setBodyHostsPort,
-  asyncMiddleware(follow)
-)
-
-applicationFollowsRouter.get('/followers',
-  paginationValidator,
-  followersSortValidator,
-  setFollowersSort,
-  setPagination,
-  asyncMiddleware(listFollowers)
-)
-
-// ---------------------------------------------------------------------------
-
-export {
-  applicationFollowsRouter
-}
-
-// ---------------------------------------------------------------------------
-
-async function listFollowing (req: express.Request, res: express.Response, next: express.NextFunction) {
-  const applicationAccount = await getApplicationAccount()
-  const resultList = await db.AccountFollow.listFollowingForApi(applicationAccount.id, req.query.start, req.query.count, req.query.sort)
-
-  return res.json(getFormattedObjects(resultList.data, resultList.total))
-}
-
-async function listFollowers (req: express.Request, res: express.Response, next: express.NextFunction) {
-  const applicationAccount = await getApplicationAccount()
-  const resultList = await db.AccountFollow.listFollowersForApi(applicationAccount.id, req.query.start, req.query.count, req.query.sort)
-
-  return res.json(getFormattedObjects(resultList.data, resultList.total))
-}
-
-async function follow (req: express.Request, res: express.Response, next: express.NextFunction) {
-  const hosts = req.body.hosts as string[]
-  const fromAccount = await getApplicationAccount()
-
-  const tasks: Promise<any>[] = []
-  const accountName = SERVER_ACCOUNT_NAME
-
-  for (const host of hosts) {
-
-    // We process each host in a specific transaction
-    // First, we add the follow request in the database
-    // Then we send the follow request to other account
-    const p = loadLocalOrGetAccountFromWebfinger(accountName, host)
-      .then(accountResult => {
-        let targetAccount = accountResult.account
-
-        return db.sequelize.transaction(async t => {
-          if (accountResult.loadedFromDB === false) {
-            targetAccount = await targetAccount.save({ transaction: t })
-          }
-
-          const [ accountFollow ] = await db.AccountFollow.findOrCreate({
-            where: {
-              accountId: fromAccount.id,
-              targetAccountId: targetAccount.id
-            },
-            defaults: {
-              state: 'pending',
-              accountId: fromAccount.id,
-              targetAccountId: targetAccount.id
-            },
-            transaction: t
-          })
-
-          // Send a notification to remote server
-          if (accountFollow.state === 'pending') {
-            await sendFollow(fromAccount, targetAccount, t)
-          }
-        })
-      })
-      .catch(err => logger.warn('Cannot follow server %s.', `${accountName}@${host}`, err))
-
-    tasks.push(p)
-  }
-
-  await Promise.all(tasks)
-
-  return res.status(204).end()
-}
-
-async function loadLocalOrGetAccountFromWebfinger (name: string, host: string) {
-  let loadedFromDB = true
-  let account = await db.Account.loadByNameAndHost(name, host)
-
-  if (!account) {
-    const nameWithDomain = name + '@' + host
-    account = await getAccountFromWebfinger(nameWithDomain)
-    loadedFromDB = false
-  }
-
-  return { account, loadedFromDB }
-}
diff --git a/server/controllers/api/application/index.ts b/server/controllers/api/application/index.ts
deleted file mode 100644 (file)
index 011b971..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-import * as express from 'express'
-import { applicationFollowsRouter } from './follows'
-
-const applicationRouter = express.Router()
-
-applicationRouter.use('/', applicationFollowsRouter)
-
-// ---------------------------------------------------------------------------
-
-export {
-  applicationRouter
-}
index a22c78cceb079010cbfcc09d658e7a59b33659f8..876c911c79c6ed232526fb5ad915fe1956d4715c 100644 (file)
@@ -4,7 +4,7 @@ import { badRequest } from '../../helpers'
 
 import { oauthClientsRouter } from './oauth-clients'
 import { configRouter } from './config'
-import { applicationRouter } from './application'
+import { applicationRouter } from './server'
 import { usersRouter } from './users'
 import { videosRouter } from './videos'
 
diff --git a/server/controllers/api/server/follows.ts b/server/controllers/api/server/follows.ts
new file mode 100644 (file)
index 0000000..c9775ad
--- /dev/null
@@ -0,0 +1,127 @@
+import * as express from 'express'
+import { UserRight } from '../../../../shared/models/users/user-right.enum'
+import { getFormattedObjects } from '../../../helpers'
+import { logger } from '../../../helpers/logger'
+import { getApplicationAccount } from '../../../helpers/utils'
+import { getAccountFromWebfinger } from '../../../helpers/webfinger'
+import { SERVER_ACCOUNT_NAME } from '../../../initializers/constants'
+import { database as db } from '../../../initializers/database'
+import { sendFollow } from '../../../lib/activitypub/send-request'
+import { asyncMiddleware, paginationValidator, setFollowersSort, setPagination } from '../../../middlewares'
+import { authenticate } from '../../../middlewares/oauth'
+import { setBodyHostsPort } from '../../../middlewares/servers'
+import { setFollowingSort } from '../../../middlewares/sort'
+import { ensureUserHasRight } from '../../../middlewares/user-right'
+import { followValidator } from '../../../middlewares/validators/servers'
+import { followersSortValidator, followingSortValidator } from '../../../middlewares/validators/sort'
+
+const applicationFollowsRouter = express.Router()
+
+applicationFollowsRouter.get('/following',
+  paginationValidator,
+  followingSortValidator,
+  setFollowingSort,
+  setPagination,
+  asyncMiddleware(listFollowing)
+)
+
+applicationFollowsRouter.post('/follow',
+  authenticate,
+  ensureUserHasRight(UserRight.MANAGE_APPLICATION_FOLLOW),
+  followValidator,
+  setBodyHostsPort,
+  asyncMiddleware(follow)
+)
+
+applicationFollowsRouter.get('/followers',
+  paginationValidator,
+  followersSortValidator,
+  setFollowersSort,
+  setPagination,
+  asyncMiddleware(listFollowers)
+)
+
+// ---------------------------------------------------------------------------
+
+export {
+  applicationFollowsRouter
+}
+
+// ---------------------------------------------------------------------------
+
+async function listFollowing (req: express.Request, res: express.Response, next: express.NextFunction) {
+  const applicationAccount = await getApplicationAccount()
+  const resultList = await db.AccountFollow.listFollowingForApi(applicationAccount.id, req.query.start, req.query.count, req.query.sort)
+
+  return res.json(getFormattedObjects(resultList.data, resultList.total))
+}
+
+async function listFollowers (req: express.Request, res: express.Response, next: express.NextFunction) {
+  const applicationAccount = await getApplicationAccount()
+  const resultList = await db.AccountFollow.listFollowersForApi(applicationAccount.id, req.query.start, req.query.count, req.query.sort)
+
+  return res.json(getFormattedObjects(resultList.data, resultList.total))
+}
+
+async function follow (req: express.Request, res: express.Response, next: express.NextFunction) {
+  const hosts = req.body.hosts as string[]
+  const fromAccount = await getApplicationAccount()
+
+  const tasks: Promise<any>[] = []
+  const accountName = SERVER_ACCOUNT_NAME
+
+  for (const host of hosts) {
+
+    // We process each host in a specific transaction
+    // First, we add the follow request in the database
+    // Then we send the follow request to other account
+    const p = loadLocalOrGetAccountFromWebfinger(accountName, host)
+      .then(accountResult => {
+        let targetAccount = accountResult.account
+
+        return db.sequelize.transaction(async t => {
+          if (accountResult.loadedFromDB === false) {
+            targetAccount = await targetAccount.save({ transaction: t })
+          }
+
+          const [ accountFollow ] = await db.AccountFollow.findOrCreate({
+            where: {
+              accountId: fromAccount.id,
+              targetAccountId: targetAccount.id
+            },
+            defaults: {
+              state: 'pending',
+              accountId: fromAccount.id,
+              targetAccountId: targetAccount.id
+            },
+            transaction: t
+          })
+
+          // Send a notification to remote server
+          if (accountFollow.state === 'pending') {
+            await sendFollow(fromAccount, targetAccount, t)
+          }
+        })
+      })
+      .catch(err => logger.warn('Cannot follow server %s.', `${accountName}@${host}`, err))
+
+    tasks.push(p)
+  }
+
+  await Promise.all(tasks)
+
+  return res.status(204).end()
+}
+
+async function loadLocalOrGetAccountFromWebfinger (name: string, host: string) {
+  let loadedFromDB = true
+  let account = await db.Account.loadByNameAndHost(name, host)
+
+  if (!account) {
+    const nameWithDomain = name + '@' + host
+    account = await getAccountFromWebfinger(nameWithDomain)
+    loadedFromDB = false
+  }
+
+  return { account, loadedFromDB }
+}
diff --git a/server/controllers/api/server/index.ts b/server/controllers/api/server/index.ts
new file mode 100644 (file)
index 0000000..011b971
--- /dev/null
@@ -0,0 +1,12 @@
+import * as express from 'express'
+import { applicationFollowsRouter } from './follows'
+
+const applicationRouter = express.Router()
+
+applicationRouter.use('/', applicationFollowsRouter)
+
+// ---------------------------------------------------------------------------
+
+export {
+  applicationRouter
+}
index 7a3471116f6f246f81c3f57f5e0aad69144f2163..29f901f605bb90d3b83d8a131bd790afc2fa71e9 100644 (file)
@@ -70,12 +70,12 @@ async function reportVideoAbuse (req: express.Request, res: express.Response) {
     reporterUsername,
     reason: body.reason,
     videoId: videoInstance.id,
-    reporterPodId: null // This is our pod that reported this abuse
+    reporterServerId: null // This is our server that reported this abuse
   }
 
   await db.sequelize.transaction(async t => {
     const abuse = await db.VideoAbuse.create(abuseToCreate, { transaction: t })
-    // We send the information to the destination pod
+    // We send the information to the destination server
     if (videoInstance.isOwned() === false) {
       const reportData = {
         reporterUsername,
@@ -84,7 +84,7 @@ async function reportVideoAbuse (req: express.Request, res: express.Response) {
       }
 
       // await friends.reportAbuseVideoToFriend(reportData, videoInstance, t)
-      // TODO: send abuse to origin pod
+      // TODO: send abuse to origin server
     }
   })
 
index 06383922355988ab83a3f6a52d6322a638a69db4..ebc07e17909aeed6ecca03bceb4d6faee4166136 100644 (file)
@@ -233,7 +233,7 @@ async function addVideo (req: express.Request, res: express.Response, videoPhysi
 
     // Let transcoding job send the video to friends because the video file extension might change
     if (CONFIG.TRANSCODING.ENABLED === true) return undefined
-    // Don't send video to remote pods, it is private
+    // Don't send video to remote servers, it is private
     if (video.privacy === VideoPrivacy.PRIVATE) return undefined
 
     await sendAddVideo(video, t)
@@ -287,7 +287,7 @@ async function updateVideo (req: express.Request, res: express.Response) {
         await sendUpdateVideoChannel(videoInstance, t)
       }
 
-      // Video is not private anymore, send a create action to remote pods
+      // Video is not private anymore, send a create action to remote servers
       if (wasPrivateVideo === true && videoInstance.privacy !== VideoPrivacy.PRIVATE) {
         await sendAddVideo(videoInstance, t)
       }
@@ -365,7 +365,7 @@ async function removeVideo (req: express.Request, res: express.Response) {
 }
 
 async function searchVideos (req: express.Request, res: express.Response, next: express.NextFunction) {
-  const resultList = await db.Video.searchAndPopulateAccountAndPodAndTags(
+  const resultList = await db.Video.searchAndPopulateAccountAndServerAndTags(
     req.params.value,
     req.query.field,
     req.query.start,
index 955277d2573f32220c23019d9dbfb6fc013adda6..8216dffd297c7f1dcd8d244247e64f524aa148eb 100644 (file)
@@ -83,7 +83,7 @@ async function rateVideo (req: express.Request, res: express.Response) {
     await videoInstance.increment(incrementQuery, sequelizeOptions)
 
     if (videoInstance.isOwned() === false) {
-      // TODO: Send a event to original pod
+      // TODO: Send a event to original server
     } else {
       // TODO: Send update to followers
     }
index 40dda7584b1cfde4d5fd5b915b0d807b66ac755f..045a50ef0375d49bf4b24e31cab2e6cad45111eb 100644 (file)
@@ -110,9 +110,9 @@ async function generateWatchHtmlPage (req: express.Request, res: express.Respons
 
   // Let Angular application handle errors
   if (validator.isUUID(videoId, 4)) {
-    videoPromise = db.Video.loadByUUIDAndPopulateAccountAndPodAndTags(videoId)
+    videoPromise = db.Video.loadByUUIDAndPopulateAccountAndServerAndTags(videoId)
   } else if (validator.isInt(videoId)) {
-    videoPromise = db.Video.loadAndPopulateAccountAndPodAndTags(+videoId)
+    videoPromise = db.Video.loadAndPopulateAccountAndServerAndTags(+videoId)
   } else {
     return res.sendFile(indexPath)
   }
index c7c952d6fcc86b8470debbf02ba02b6af4ff0c4d..7425fd0973d5c3b9a1fdbb06f175129fafb52f0a 100644 (file)
@@ -12,7 +12,7 @@ import { asyncMiddleware } from '../middlewares'
 const staticRouter = express.Router()
 
 /*
-  Cors is very important to let other pods access torrent and video files
+  Cors is very important to let other servers access torrent and video files
 */
 
 const torrentsPhysicalPath = CONFIG.STORAGE.TORRENTS_DIR
index b91490a0b46d756196443f2953d0ef210e51d4a8..3e77e05814a909a148dabcb2a22a9cdf7686ea24 100644 (file)
@@ -35,7 +35,7 @@ async function getOrCreateAccount (accountUrl: string) {
 
   // We don't have this account in our database, fetch it on remote
   if (!account) {
-    const res = await fetchRemoteAccountAndCreatePod(accountUrl)
+    const res = await fetchRemoteAccountAndCreateServer(accountUrl)
     if (res === undefined) throw new Error('Cannot fetch remote account.')
 
     // Save our new account in database
@@ -46,7 +46,7 @@ async function getOrCreateAccount (accountUrl: string) {
   return account
 }
 
-async function fetchRemoteAccountAndCreatePod (accountUrl: string) {
+async function fetchRemoteAccountAndCreateServer (accountUrl: string) {
   const options = {
     uri: accountUrl,
     method: 'GET',
@@ -90,7 +90,7 @@ async function fetchRemoteAccountAndCreatePod (accountUrl: string) {
   })
 
   const accountHost = url.parse(account.url).host
-  const podOptions = {
+  const serverOptions = {
     where: {
       host: accountHost
     },
@@ -98,15 +98,15 @@ async function fetchRemoteAccountAndCreatePod (accountUrl: string) {
       host: accountHost
     }
   }
-  const [ pod ] = await db.Pod.findOrCreate(podOptions)
-  account.set('podId', pod.id)
+  const [ server ] = await db.Server.findOrCreate(serverOptions)
+  account.set('serverId', server.id)
 
-  return { account, pod }
+  return { account, server }
 }
 
 function fetchRemoteVideoPreview (video: VideoInstance) {
   // FIXME: use url
-  const host = video.VideoChannel.Account.Pod.host
+  const host = video.VideoChannel.Account.Server.host
   const path = join(STATIC_PATHS.PREVIEWS, video.getPreviewName())
 
   return request.get(REMOTE_SCHEME.HTTP + '://' + host + path)
@@ -163,7 +163,7 @@ function activityPubCollectionPagination (url: string, page: number, result: Res
 // ---------------------------------------------------------------------------
 
 export {
-  fetchRemoteAccountAndCreatePod,
+  fetchRemoteAccountAndCreateServer,
   activityPubContextify,
   activityPubCollectionPagination,
   getActivityPubUrl,
index 6d6219a95f43e7041cb0238b0cbe90ab995aa70c..088d5fc8f4f90807df4157b3111c141759f90c28 100644 (file)
@@ -8,7 +8,7 @@ import { AccountInstance } from '../../models'
 import { logger } from '../logger'
 
 import { isUserUsernameValid } from './users'
-import { isHostValid } from './pods'
+import { isHostValid } from './servers'
 
 function isAccountNameValid (value: string) {
   return isUserUsernameValid(value)
index 1c475e30172bd4cc4dceaefa34e4bf1861b4be9c..d3b2f5393d2669b09f1ffb355465c996c73316d3 100644 (file)
@@ -1,7 +1,7 @@
 export * from './activitypub'
 export * from './misc'
-export * from './pods'
-export * from './pods'
+export * from './servers'
+export * from './servers'
 export * from './users'
 export * from './accounts'
 export * from './video-channels'
diff --git a/server/helpers/custom-validators/pods.ts b/server/helpers/custom-validators/pods.ts
deleted file mode 100644 (file)
index d5021bf..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-import * as validator from 'validator'
-import 'express-validator'
-
-import { isArray, exists } from './misc'
-import { isTestInstance } from '../core-utils'
-
-function isHostValid (host: string) {
-  const isURLOptions = {
-    require_host: true,
-    require_tld: true
-  }
-
-  // We validate 'localhost', so we don't have the top level domain
-  if (isTestInstance()) {
-    isURLOptions.require_tld = false
-  }
-
-  return exists(host) && validator.isURL(host, isURLOptions) && host.split('://').length === 1
-}
-
-function isEachUniqueHostValid (hosts: string[]) {
-  return isArray(hosts) &&
-    hosts.length !== 0 &&
-    hosts.every(host => {
-      return isHostValid(host) && hosts.indexOf(host) === hosts.lastIndexOf(host)
-    })
-}
-
-// ---------------------------------------------------------------------------
-
-export {
-  isEachUniqueHostValid,
-  isHostValid
-}
diff --git a/server/helpers/custom-validators/servers.ts b/server/helpers/custom-validators/servers.ts
new file mode 100644 (file)
index 0000000..d5021bf
--- /dev/null
@@ -0,0 +1,34 @@
+import * as validator from 'validator'
+import 'express-validator'
+
+import { isArray, exists } from './misc'
+import { isTestInstance } from '../core-utils'
+
+function isHostValid (host: string) {
+  const isURLOptions = {
+    require_host: true,
+    require_tld: true
+  }
+
+  // We validate 'localhost', so we don't have the top level domain
+  if (isTestInstance()) {
+    isURLOptions.require_tld = false
+  }
+
+  return exists(host) && validator.isURL(host, isURLOptions) && host.split('://').length === 1
+}
+
+function isEachUniqueHostValid (hosts: string[]) {
+  return isArray(hosts) &&
+    hosts.length !== 0 &&
+    hosts.every(host => {
+      return isHostValid(host) && hosts.indexOf(host) === hosts.lastIndexOf(host)
+    })
+}
+
+// ---------------------------------------------------------------------------
+
+export {
+  isEachUniqueHostValid,
+  isHostValid
+}
index 715119cf68d7003d1523a4ef5790c818dbaabf82..d68de66092253e1f08bd88dacf28d0bc959d095f 100644 (file)
@@ -171,9 +171,9 @@ function isVideoFileInfoHashValid (value: string) {
 function checkVideoExists (id: string, res: express.Response, callback: () => void) {
   let promise: Promise<VideoInstance>
   if (validator.isInt(id)) {
-    promise = db.Video.loadAndPopulateAccountAndPodAndTags(+id)
+    promise = db.Video.loadAndPopulateAccountAndServerAndTags(+id)
   } else { // UUID
-    promise = db.Video.loadByUUIDAndPopulateAccountAndPodAndTags(id)
+    promise = db.Video.loadByUUIDAndPopulateAccountAndServerAndTags(id)
   }
 
   promise.then(video => {
index 0155e5f3eed580c959e98bae09f0cd0cbf7d883f..31417e72883469d31d904ddcba2d63b72d2b003a 100644 (file)
@@ -3,7 +3,7 @@ import * as WebFinger from 'webfinger.js'
 import { isTestInstance } from './core-utils'
 import { isActivityPubUrlValid } from './custom-validators'
 import { WebFingerData } from '../../shared'
-import { fetchRemoteAccountAndCreatePod } from './activitypub'
+import { fetchRemoteAccountAndCreateServer } from './activitypub'
 
 const webfinger = new WebFinger({
   webfist_fallback: false,
@@ -22,8 +22,8 @@ async function getAccountFromWebfinger (nameWithHost: string) {
     throw new Error('Cannot find self link or href is not a valid URL.')
   }
 
-  const res = await fetchRemoteAccountAndCreatePod(selfLink.href)
-  if (res === undefined) throw new Error('Cannot fetch and create pod of remote account ' + selfLink.href)
+  const res = await fetchRemoteAccountAndCreateServer(selfLink.href)
+  if (res === undefined) throw new Error('Cannot fetch and create server of remote account ' + selfLink.href)
 
   return res.account
 }
index 4a49c1ab3ce065669ece8b90ace53c263e94eb1e..99da95ab95bcb5547977ae33b3f718098a0f4696 100644 (file)
@@ -6,10 +6,6 @@ import { root, isTestInstance } from '../helpers/core-utils'
 
 import {
   VideoRateType,
-  RequestEndpoint,
-  RequestVideoEventType,
-  RequestVideoQaduType,
-  RemoteVideoRequestType,
   JobState,
   JobCategory
 } from '../../shared/models'
@@ -220,7 +216,7 @@ const VIDEO_MIMETYPE_EXT = {
 
 // ---------------------------------------------------------------------------
 
-// Score a pod has when we create it as a friend
+// Score a server has when we create it as a friend
 const FRIEND_SCORE = {
   BASE: 100,
   MAX: 1000
@@ -243,7 +239,7 @@ const ACTIVITY_PUB = {
 // ---------------------------------------------------------------------------
 
 // Number of points we add/remove from a friend after a successful/bad request
-const PODS_SCORE = {
+const SERVERS_SCORE = {
   PENALTY: -10,
   BONUS: 10
 }
@@ -352,7 +348,7 @@ export {
   OAUTH_LIFETIME,
   OPENGRAPH_AND_OEMBED_COMMENT,
   PAGINATION_COUNT_DEFAULT,
-  PODS_SCORE,
+  SERVERS_SCORE,
   PREVIEWS_SIZE,
   REMOTE_SCHEME,
   ACTIVITY_PUB_ACCEPT_HEADER,
index 1383bb33ba29e451e0b87753f1feda176942e46b..19b5a0466c60ed5b6ae84a799b99c5b9897b147b 100644 (file)
@@ -18,7 +18,7 @@ import { UserModel } from '../models/account/user-interface'
 import { AccountVideoRateModel } from '../models/account/account-video-rate-interface'
 import { AccountFollowModel } from '../models/account/account-follow-interface'
 import { TagModel } from './../models/video/tag-interface'
-import { PodModel } from './../models/pod/pod-interface'
+import { ServerModel } from '../models/server/server-interface'
 import { OAuthTokenModel } from './../models/oauth/oauth-token-interface'
 import { OAuthClientModel } from './../models/oauth/oauth-client-interface'
 import { JobModel } from './../models/job/job-interface'
@@ -38,7 +38,7 @@ const database: {
   Job?: JobModel,
   OAuthClient?: OAuthClientModel,
   OAuthToken?: OAuthTokenModel,
-  Pod?: PodModel,
+  Server?: ServerModel,
   Tag?: TagModel,
   AccountVideoRate?: AccountVideoRateModel,
   AccountFollow?: AccountFollowModel,
index 776f647a048ba1e45ee7ec74edd8da8e9d74ed59..0570f51e8ec624f821f2a7db000a859e9e14c222 100644 (file)
@@ -42,7 +42,7 @@ class VideosPreviewCache {
   }
 
   private async loadPreviews (key: string) {
-    const video = await db.Video.loadByUUIDAndPopulateAccountAndPodAndTags(key)
+    const video = await db.Video.loadByUUIDAndPopulateAccountAndServerAndTags(key)
     if (!video) return undefined
 
     if (video.isOwned()) return join(CONFIG.STORAGE.PREVIEWS_DIR, video.getPreviewName())
index 47603a66c527a4e44fac0c1d12e5a2c73028a36c..d3ee886e7f535e7d394aa1088fad0b6e9739675b 100644 (file)
@@ -8,7 +8,7 @@ import { JobScheduler } from '../job-scheduler'
 import { TranscodingJobPayload } from './transcoding-job-scheduler'
 
 async function process (data: TranscodingJobPayload, jobId: number) {
-  const video = await db.Video.loadByUUIDAndPopulateAccountAndPodAndTags(data.videoUUID)
+  const video = await db.Video.loadByUUIDAndPopulateAccountAndServerAndTags(data.videoUUID)
   // No video, maybe deleted?
   if (!video) {
     logger.info('Do not process job %d, video does not exist.', jobId, { videoUUID: video.uuid })
@@ -31,7 +31,7 @@ async function onSuccess (jobId: number, video: VideoInstance, jobScheduler: Job
   logger.info('Job %d is a success.', jobId)
 
   // Maybe the video changed in database, refresh it
-  const videoDatabase = await db.Video.loadByUUIDAndPopulateAccountAndPodAndTags(video.uuid)
+  const videoDatabase = await db.Video.loadByUUIDAndPopulateAccountAndServerAndTags(video.uuid)
   // Video does not exist anymore
   if (!videoDatabase) return undefined
 
index 77e5d9f7f744cb73d13fa052d64dc79d649a0be5..4f2ce3d24015647e69447a8969d5bd4aaf520ced 100644 (file)
@@ -5,7 +5,7 @@ import { VideoInstance } from '../../../models'
 import { sendUpdateVideo } from '../../activitypub/send-request'
 
 async function process (data: { videoUUID: string, resolution: VideoResolution }, jobId: number) {
-  const video = await db.Video.loadByUUIDAndPopulateAccountAndPodAndTags(data.videoUUID)
+  const video = await db.Video.loadByUUIDAndPopulateAccountAndServerAndTags(data.videoUUID)
   // No video, maybe deleted?
   if (!video) {
     logger.info('Do not process job %d, video does not exist.', jobId, { videoUUID: video.uuid })
@@ -28,7 +28,7 @@ async function onSuccess (jobId: number, video: VideoInstance) {
   logger.info('Job %d is a success.', jobId)
 
   // Maybe the video changed in database, refresh it
-  const videoDatabase = await db.Video.loadByUUIDAndPopulateAccountAndPodAndTags(video.uuid)
+  const videoDatabase = await db.Video.loadByUUIDAndPopulateAccountAndServerAndTags(video.uuid)
   // Video does not exist anymore
   if (!videoDatabase) return undefined
 
index d2d599dfd74d935d66ac554ae4eb6697d33fa4d5..9884e566f9f5ea0a69bd0db44dd0eb8f5322f125 100644 (file)
@@ -46,7 +46,7 @@ async function createLocalAccount (name: string, userId: number, applicationId:
     followingUrl: url + '/following',
     userId,
     applicationId,
-    podId: null // It is our pod
+    serverId: null // It is our server
   })
 
   return accountInstance.save({ transaction: t })
index 13841ea33b7548348fc8c44e71db7feafbd13f66..80303fb838c62320daca6f5244517e49bd57cb74 100644 (file)
@@ -30,14 +30,14 @@ async function createVideoChannel (videoChannelInfo: VideoChannelCreate, account
   return videoChannelCreated
 }
 
-async function fetchVideoChannelByHostAndUUID (podHost: string, uuid: string, t: Sequelize.Transaction) {
+async function fetchVideoChannelByHostAndUUID (serverHost: string, uuid: string, t: Sequelize.Transaction) {
   try {
-    const videoChannel = await db.VideoChannel.loadByHostAndUUID(podHost, uuid, t)
+    const videoChannel = await db.VideoChannel.loadByHostAndUUID(serverHost, uuid, t)
     if (!videoChannel) throw new Error('Video channel not found')
 
     return videoChannel
   } catch (err) {
-    logger.error('Cannot load video channel from host and uuid.', { error: err.stack, podHost, uuid })
+    logger.error('Cannot load video channel from host and uuid.', { error: err.stack, serverHost, uuid })
     throw err
   }
 }
index bed2bfeabe444e659ecbe514d8c8b3c8056d4133..0ea522e5c3738fd2e3d2c044cd1f910414073dee 100644 (file)
@@ -1,7 +1,7 @@
 import { NextFunction, Request, Response, RequestHandler } from 'express'
 import { ActivityPubSignature } from '../../shared'
 import { isSignatureVerified, logger } from '../helpers'
-import { fetchRemoteAccountAndCreatePod } from '../helpers/activitypub'
+import { fetchRemoteAccountAndCreateServer } from '../helpers/activitypub'
 import { database as db, ACTIVITY_PUB_ACCEPT_HEADER } from '../initializers'
 import { each, eachSeries, waterfall } from 'async'
 
@@ -14,7 +14,7 @@ async function checkSignature (req: Request, res: Response, next: NextFunction)
 
   // We don't have this account in our database, fetch it on remote
   if (!account) {
-    const accountResult = await fetchRemoteAccountAndCreatePod(signatureObject.creator)
+    const accountResult = await fetchRemoteAccountAndCreateServer(signatureObject.creator)
 
     if (!accountResult) {
       return res.sendStatus(403)
index 40480450b45f73e05281934d6b3d61d9644d8654..aafcad2d943b4ef85a212005e369732c202b3a03 100644 (file)
@@ -3,7 +3,7 @@ export * from './activitypub'
 export * from './async'
 export * from './oauth'
 export * from './pagination'
-export * from './pods'
+export * from './servers'
 export * from './search'
 export * from './sort'
 export * from './user-right'
diff --git a/server/middlewares/pods.ts b/server/middlewares/pods.ts
deleted file mode 100644 (file)
index eaf9aa1..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-import 'express-validator'
-import * as express from 'express'
-
-import { REMOTE_SCHEME } from '../initializers'
-
-function setBodyHostsPort (req: express.Request, res: express.Response, next: express.NextFunction) {
-  if (!req.body.hosts) return next()
-
-  for (let i = 0; i < req.body.hosts.length; i++) {
-    const hostWithPort = getHostWithPort(req.body.hosts[i])
-
-    // Problem with the url parsing?
-    if (hostWithPort === null) {
-      return res.sendStatus(500)
-    }
-
-    req.body.hosts[i] = hostWithPort
-  }
-
-  return next()
-}
-
-function setBodyHostPort (req: express.Request, res: express.Response, next: express.NextFunction) {
-  if (!req.body.host) return next()
-
-  const hostWithPort = getHostWithPort(req.body.host)
-
-  // Problem with the url parsing?
-  if (hostWithPort === null) {
-    return res.sendStatus(500)
-  }
-
-  req.body.host = hostWithPort
-
-  return next()
-}
-
-// ---------------------------------------------------------------------------
-
-export {
-  setBodyHostsPort,
-  setBodyHostPort
-}
-
-// ---------------------------------------------------------------------------
-
-function getHostWithPort (host: string) {
-  const splitted = host.split(':')
-
-  // The port was not specified
-  if (splitted.length === 1) {
-    if (REMOTE_SCHEME.HTTP === 'https') return host + ':443'
-
-    return host + ':80'
-  }
-
-  return host
-}
diff --git a/server/middlewares/servers.ts b/server/middlewares/servers.ts
new file mode 100644 (file)
index 0000000..eaf9aa1
--- /dev/null
@@ -0,0 +1,58 @@
+import 'express-validator'
+import * as express from 'express'
+
+import { REMOTE_SCHEME } from '../initializers'
+
+function setBodyHostsPort (req: express.Request, res: express.Response, next: express.NextFunction) {
+  if (!req.body.hosts) return next()
+
+  for (let i = 0; i < req.body.hosts.length; i++) {
+    const hostWithPort = getHostWithPort(req.body.hosts[i])
+
+    // Problem with the url parsing?
+    if (hostWithPort === null) {
+      return res.sendStatus(500)
+    }
+
+    req.body.hosts[i] = hostWithPort
+  }
+
+  return next()
+}
+
+function setBodyHostPort (req: express.Request, res: express.Response, next: express.NextFunction) {
+  if (!req.body.host) return next()
+
+  const hostWithPort = getHostWithPort(req.body.host)
+
+  // Problem with the url parsing?
+  if (hostWithPort === null) {
+    return res.sendStatus(500)
+  }
+
+  req.body.host = hostWithPort
+
+  return next()
+}
+
+// ---------------------------------------------------------------------------
+
+export {
+  setBodyHostsPort,
+  setBodyHostPort
+}
+
+// ---------------------------------------------------------------------------
+
+function getHostWithPort (host: string) {
+  const splitted = host.split(':')
+
+  // The port was not specified
+  if (splitted.length === 1) {
+    if (REMOTE_SCHEME.HTTP === 'https') return host + ':443'
+
+    return host + ':80'
+  }
+
+  return host
+}
index 20ae341f0b3e6c90ffe7bf8d47ed9444d8ad1ab8..279b29e654c40d4f069f14de7d3c3024149ab6c7 100644 (file)
@@ -4,12 +4,6 @@ import * as express from 'express'
 import { SortType } from '../helpers'
 import { database } from '../initializers'
 
-function setPodsSort (req: express.Request, res: express.Response, next: express.NextFunction) {
-  if (!req.query.sort) req.query.sort = '-createdAt'
-
-  return next()
-}
-
 function setUsersSort (req: express.Request, res: express.Response, next: express.NextFunction) {
   if (!req.query.sort) req.query.sort = '-createdAt'
 
@@ -70,7 +64,6 @@ function setBlacklistSort (req: express.Request, res: express.Response, next: ex
 // ---------------------------------------------------------------------------
 
 export {
-  setPodsSort,
   setUsersSort,
   setVideoAbusesSort,
   setVideoChannelsSort,
index 92a4bad28fdf9b444945f70233961e7abbbe196b..3f5afe5b3c28eeb0cd398db74c2c5eac902590b5 100644 (file)
@@ -2,7 +2,7 @@ export * from './account'
 export * from './oembed'
 export * from './activitypub'
 export * from './pagination'
-export * from './pods'
+export * from './servers'
 export * from './sort'
 export * from './users'
 export * from './videos'
diff --git a/server/middlewares/validators/pods.ts b/server/middlewares/validators/pods.ts
deleted file mode 100644 (file)
index e17369a..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-import * as express from 'express'
-import { body } from 'express-validator/check'
-import { isEachUniqueHostValid } from '../../helpers/custom-validators/pods'
-import { isTestInstance } from '../../helpers/core-utils'
-import { CONFIG } from '../../initializers/constants'
-import { logger } from '../../helpers/logger'
-import { checkErrors } from './utils'
-
-const followValidator = [
-  body('hosts').custom(isEachUniqueHostValid).withMessage('Should have an array of unique hosts'),
-
-  (req: express.Request, res: express.Response, next: express.NextFunction) => {
-    // Force https if the administrator wants to make friends
-    if (isTestInstance() === false && CONFIG.WEBSERVER.SCHEME === 'http') {
-      return res.status(400)
-        .json({
-          error: 'Cannot follow non HTTPS web server.'
-        })
-        .end()
-    }
-
-    logger.debug('Checking follow parameters', { parameters: req.body })
-
-    checkErrors(req, res, next)
-  }
-]
-
-// ---------------------------------------------------------------------------
-
-export {
-  followValidator
-}
diff --git a/server/middlewares/validators/servers.ts b/server/middlewares/validators/servers.ts
new file mode 100644 (file)
index 0000000..95b69b7
--- /dev/null
@@ -0,0 +1,32 @@
+import * as express from 'express'
+import { body } from 'express-validator/check'
+import { isEachUniqueHostValid } from '../../helpers/custom-validators/servers'
+import { isTestInstance } from '../../helpers/core-utils'
+import { CONFIG } from '../../initializers/constants'
+import { logger } from '../../helpers/logger'
+import { checkErrors } from './utils'
+
+const followValidator = [
+  body('hosts').custom(isEachUniqueHostValid).withMessage('Should have an array of unique hosts'),
+
+  (req: express.Request, res: express.Response, next: express.NextFunction) => {
+    // Force https if the administrator wants to make friends
+    if (isTestInstance() === false && CONFIG.WEBSERVER.SCHEME === 'http') {
+      return res.status(400)
+        .json({
+          error: 'Cannot follow non HTTPS web server.'
+        })
+        .end()
+    }
+
+    logger.debug('Checking follow parameters', { parameters: req.body })
+
+    checkErrors(req, res, next)
+  }
+]
+
+// ---------------------------------------------------------------------------
+
+export {
+  followValidator
+}
index 53416a857e55f74b271d2be7088040db5218067d..f0ead24e3d5395676c21e0637c5861d45729b6b8 100644 (file)
@@ -50,7 +50,7 @@ const videoChannelsUpdateValidator = [
         // We need to make additional checks
         if (res.locals.videoChannel.isOwned() === false) {
           return res.status(403)
-            .json({ error: 'Cannot update video channel of another pod' })
+            .json({ error: 'Cannot update video channel of another server' })
             .end()
         }
 
@@ -113,7 +113,7 @@ function checkUserCanDeleteVideoChannel (res: express.Response, callback: () =>
   // Retrieve the user who did the request
   if (res.locals.videoChannel.isOwned() === false) {
     return res.status(403)
-              .json({ error: 'Cannot remove video channel of another pod.' })
+              .json({ error: 'Cannot remove video channel of another server.' })
               .end()
   }
 
index 10b426df33d29458d158120f02a20b477e2a4b84..158b475e3f8898cf97d5fc5afcc284207e4c924b 100644 (file)
@@ -127,7 +127,7 @@ const videosUpdateValidator = [
         // We need to make additional checks
         if (video.isOwned() === false) {
           return res.status(403)
-                    .json({ error: 'Cannot update video of another pod' })
+                    .json({ error: 'Cannot update video of another server' })
                     .end()
         }
 
@@ -250,7 +250,7 @@ function checkUserCanDeleteVideo (userId: number, res: express.Response, callbac
   // Retrieve the user who did the request
   if (res.locals.video.isOwned() === false) {
     return res.status(403)
-              .json({ error: 'Cannot remove video of another pod, blacklist it' })
+              .json({ error: 'Cannot remove video of another server, blacklist it' })
               .end()
   }
 
index 6d7592326d7ad3cb8fc8a6ff940ceeb352dbb9a5..c940d7cd4d3987aa8ae3be54bc8be03999aee85c 100644 (file)
@@ -101,7 +101,7 @@ listFollowingForApi = function (id: number, start: number, count: number, sort:
         model: AccountFollow['sequelize'].models.Account,
         as: 'AccountFollowing',
         required: true,
-        include: [ AccountFollow['sequelize'].models.Pod ]
+        include: [ AccountFollow['sequelize'].models.Server ]
       }
     ]
   }
@@ -125,7 +125,7 @@ listFollowersForApi = function (id: number, start: number, count: number, sort:
         model: AccountFollow[ 'sequelize' ].models.Account,
         required: true,
         as: 'AccountFollower',
-        include: [ AccountFollow['sequelize'].models.Pod ]
+        include: [ AccountFollow['sequelize'].models.Server ]
       },
       {
         model: AccountFollow['sequelize'].models.Account,
index ce1afec022b51be644167cf8da911f879e54f960..1a567fb7a8802cd1242bef0985ab5e24c8d9c638 100644 (file)
@@ -1,8 +1,7 @@
 import * as Bluebird from 'bluebird'
 import * as Sequelize from 'sequelize'
 import { Account as FormattedAccount, ActivityPubActor } from '../../../shared'
-import { ResultList } from '../../../shared/models/result-list.model'
-import { PodInstance } from '../pod/pod-interface'
+import { ServerInstance } from '../server/server-interface'
 import { VideoChannelInstance } from '../video/video-channel-interface'
 
 export namespace AccountMethods {
@@ -11,7 +10,7 @@ export namespace AccountMethods {
   export type Load = (id: number) => Bluebird<AccountInstance>
   export type LoadByUUID = (uuid: string) => Bluebird<AccountInstance>
   export type LoadByUrl = (url: string, transaction?: Sequelize.Transaction) => Bluebird<AccountInstance>
-  export type LoadAccountByPodAndUUID = (uuid: string, podId: number, transaction: Sequelize.Transaction) => Bluebird<AccountInstance>
+  export type LoadAccountByServerAndUUID = (uuid: string, serverId: number, transaction: Sequelize.Transaction) => Bluebird<AccountInstance>
   export type LoadLocalByName = (name: string) => Bluebird<AccountInstance>
   export type LoadByNameAndHost = (name: string, host: string) => Bluebird<AccountInstance>
   export type ListOwned = () => Bluebird<AccountInstance[]>
@@ -27,7 +26,7 @@ export namespace AccountMethods {
 
 export interface AccountClass {
   loadApplication: AccountMethods.LoadApplication
-  loadAccountByPodAndUUID: AccountMethods.LoadAccountByPodAndUUID
+  loadAccountByServerAndUUID: AccountMethods.LoadAccountByServerAndUUID
   load: AccountMethods.Load
   loadByUUID: AccountMethods.LoadByUUID
   loadByUrl: AccountMethods.LoadByUrl
@@ -51,7 +50,7 @@ export interface AccountAttributes {
 
   uuid?: string
 
-  podId?: number
+  serverId?: number
   userId?: number
   applicationId?: number
 }
@@ -69,7 +68,7 @@ export interface AccountInstance extends AccountClass, AccountAttributes, Sequel
   createdAt: Date
   updatedAt: Date
 
-  Pod: PodInstance
+  Server: ServerInstance
   VideoChannels: VideoChannelInstance[]
 }
 
index e90eaae5e632109bcfe0ce14d32697316125545f..ee00c5aef926471ca7a81008437b3e9e027befb2 100644 (file)
@@ -26,7 +26,7 @@ import { sendDeleteAccount } from '../../lib/activitypub/send-request'
 import { CONFIG, CONSTRAINTS_FIELDS } from '../../initializers/constants'
 
 let Account: Sequelize.Model<AccountInstance, AccountAttributes>
-let loadAccountByPodAndUUID: AccountMethods.LoadAccountByPodAndUUID
+let loadAccountByServerAndUUID: AccountMethods.LoadAccountByServerAndUUID
 let load: AccountMethods.Load
 let loadApplication: AccountMethods.LoadApplication
 let loadByUUID: AccountMethods.LoadByUUID
@@ -170,7 +170,7 @@ export default function defineAccount (sequelize: Sequelize.Sequelize, DataTypes
           fields: [ 'name' ]
         },
         {
-          fields: [ 'podId' ]
+          fields: [ 'serverId' ]
         },
         {
           fields: [ 'userId' ],
@@ -181,7 +181,7 @@ export default function defineAccount (sequelize: Sequelize.Sequelize, DataTypes
           unique: true
         },
         {
-          fields: [ 'name', 'podId', 'applicationId' ],
+          fields: [ 'name', 'serverId', 'applicationId' ],
           unique: true
         }
       ],
@@ -191,7 +191,7 @@ export default function defineAccount (sequelize: Sequelize.Sequelize, DataTypes
 
   const classMethods = [
     associate,
-    loadAccountByPodAndUUID,
+    loadAccountByServerAndUUID,
     loadApplication,
     load,
     loadByUUID,
@@ -217,9 +217,9 @@ export default function defineAccount (sequelize: Sequelize.Sequelize, DataTypes
 // ---------------------------------------------------------------------------
 
 function associate (models) {
-  Account.belongsTo(models.Pod, {
+  Account.belongsTo(models.Server, {
     foreignKey: {
-      name: 'podId',
+      name: 'serverId',
       allowNull: true
     },
     onDelete: 'cascade'
@@ -278,19 +278,28 @@ function afterDestroy (account: AccountInstance) {
 }
 
 toFormattedJSON = function (this: AccountInstance) {
-  let host = this.Pod ? this.Pod.host : CONFIG.WEBSERVER.HOST
+  let host = CONFIG.WEBSERVER.HOST
+  let score: number
+
+  if (this.Server) {
+    host = this.Server.host
+    score = this.Server.score as number
+  }
 
   const json = {
     id: this.id,
     host,
-    name: this.name
+    score,
+    name: this.name,
+    createdAt: this.createdAt,
+    updatedAt: this.updatedAt
   }
 
   return json
 }
 
 toActivityPubObject = function (this: AccountInstance) {
-  const type = this.podId ? 'Application' as 'Application' : 'Person' as 'Person'
+  const type = this.serverId ? 'Application' as 'Application' : 'Person' as 'Person'
 
   const json = {
     type,
@@ -317,7 +326,7 @@ toActivityPubObject = function (this: AccountInstance) {
 }
 
 isOwned = function (this: AccountInstance) {
-  return this.podId === null
+  return this.serverId === null
 }
 
 getFollowerSharedInboxUrls = function (this: AccountInstance) {
@@ -356,7 +365,7 @@ getPublicKeyUrl = function (this: AccountInstance) {
 listOwned = function () {
   const query: Sequelize.FindOptions<AccountAttributes> = {
     where: {
-      podId: null
+      serverId: null
     }
   }
 
@@ -417,7 +426,7 @@ loadByNameAndHost = function (name: string, host: string) {
     },
     include: [
       {
-        model: Account['sequelize'].models.Pod,
+        model: Account['sequelize'].models.Server,
         required: true,
         where: {
           host
@@ -440,10 +449,10 @@ loadByUrl = function (url: string, transaction?: Sequelize.Transaction) {
   return Account.findOne(query)
 }
 
-loadAccountByPodAndUUID = function (uuid: string, podId: number, transaction: Sequelize.Transaction) {
+loadAccountByServerAndUUID = function (uuid: string, serverId: number, transaction: Sequelize.Transaction) {
   const query: Sequelize.FindOptions<AccountAttributes> = {
     where: {
-      podId,
+      serverId,
       uuid
     },
     transaction
index 0aec2d3b1d8add80a09a652aca0963328ddd75b2..65faa5294aa0f246b99115fe273c3f01e977ce1b 100644 (file)
@@ -1,6 +1,6 @@
 export * from './application'
 export * from './job'
 export * from './oauth'
-export * from './pod'
+export * from './server'
 export * from './account'
 export * from './video'
diff --git a/server/models/pod/index.ts b/server/models/pod/index.ts
deleted file mode 100644 (file)
index d2bf50d..0000000
+++ /dev/null
@@ -1 +0,0 @@
-export * from './pod-interface'
diff --git a/server/models/pod/pod-interface.ts b/server/models/pod/pod-interface.ts
deleted file mode 100644 (file)
index 6c5aab3..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-import * as Sequelize from 'sequelize'
-import * as Promise from 'bluebird'
-
-// Don't use barrel, import just what we need
-import { Pod as FormattedPod } from '../../../shared/models/pods/pod.model'
-import { ResultList } from '../../../shared/models/result-list.model'
-
-export namespace PodMethods {
-  export type ToFormattedJSON = (this: PodInstance) => FormattedPod
-
-  export type CountAll = () => Promise<number>
-
-  export type IncrementScores = (ids: number[], value: number) => Promise<[ number, PodInstance[] ]>
-
-  export type List = () => Promise<PodInstance[]>
-
-  export type ListForApi = (start: number, count: number, sort: string) => Promise< ResultList<PodInstance> >
-
-  export type ListAllIds = (transaction: Sequelize.Transaction) => Promise<number[]>
-
-  export type ListRandomPodIdsWithRequest = (limit: number, tableWithPods: string, tableWithPodsJoins: string) => Promise<number[]>
-
-  export type ListBadPods = () => Promise<PodInstance[]>
-
-  export type Load = (id: number) => Promise<PodInstance>
-
-  export type LoadByHost = (host: string) => Promise<PodInstance>
-
-  export type RemoveAll = () => Promise<number>
-
-  export type UpdatePodsScore = (goodPods: number[], badPods: number[]) => void
-}
-
-export interface PodClass {
-  countAll: PodMethods.CountAll
-  incrementScores: PodMethods.IncrementScores
-  list: PodMethods.List
-  listForApi: PodMethods.ListForApi
-  listAllIds: PodMethods.ListAllIds
-  listRandomPodIdsWithRequest: PodMethods.ListRandomPodIdsWithRequest
-  listBadPods: PodMethods.ListBadPods
-  load: PodMethods.Load
-  loadByHost: PodMethods.LoadByHost
-  removeAll: PodMethods.RemoveAll
-  updatePodsScore: PodMethods.UpdatePodsScore
-}
-
-export interface PodAttributes {
-  id?: number
-  host?: string
-  score?: number | Sequelize.literal // Sequelize literal for 'score +' + value
-}
-
-export interface PodInstance extends PodClass, PodAttributes, Sequelize.Instance<PodAttributes> {
-  createdAt: Date
-  updatedAt: Date
-
-  toFormattedJSON: PodMethods.ToFormattedJSON,
-}
-
-export interface PodModel extends PodClass, Sequelize.Model<PodInstance, PodAttributes> {}
diff --git a/server/models/pod/pod.ts b/server/models/pod/pod.ts
deleted file mode 100644 (file)
index 6d270ad..0000000
+++ /dev/null
@@ -1,248 +0,0 @@
-import { map } from 'lodash'
-import * as Sequelize from 'sequelize'
-
-import { FRIEND_SCORE, PODS_SCORE } from '../../initializers'
-import { logger, isHostValid } from '../../helpers'
-
-import { addMethodsToModel, getSort } from '../utils'
-import {
-  PodInstance,
-  PodAttributes,
-
-  PodMethods
-} from './pod-interface'
-
-let Pod: Sequelize.Model<PodInstance, PodAttributes>
-let toFormattedJSON: PodMethods.ToFormattedJSON
-let countAll: PodMethods.CountAll
-let incrementScores: PodMethods.IncrementScores
-let list: PodMethods.List
-let listForApi: PodMethods.ListForApi
-let listAllIds: PodMethods.ListAllIds
-let listRandomPodIdsWithRequest: PodMethods.ListRandomPodIdsWithRequest
-let listBadPods: PodMethods.ListBadPods
-let load: PodMethods.Load
-let loadByHost: PodMethods.LoadByHost
-let removeAll: PodMethods.RemoveAll
-let updatePodsScore: PodMethods.UpdatePodsScore
-
-export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) {
-  Pod = sequelize.define<PodInstance, PodAttributes>('Pod',
-    {
-      host: {
-        type: DataTypes.STRING,
-        allowNull: false,
-        validate: {
-          isHost: value => {
-            const res = isHostValid(value)
-            if (res === false) throw new Error('Host not valid.')
-          }
-        }
-      },
-      score: {
-        type: DataTypes.INTEGER,
-        defaultValue: FRIEND_SCORE.BASE,
-        allowNull: false,
-        validate: {
-          isInt: true,
-          max: FRIEND_SCORE.MAX
-        }
-      }
-    },
-    {
-      indexes: [
-        {
-          fields: [ 'host' ],
-          unique: true
-        },
-        {
-          fields: [ 'score' ]
-        }
-      ]
-    }
-  )
-
-  const classMethods = [
-    countAll,
-    incrementScores,
-    list,
-    listForApi,
-    listAllIds,
-    listRandomPodIdsWithRequest,
-    listBadPods,
-    load,
-    loadByHost,
-    updatePodsScore,
-    removeAll
-  ]
-  const instanceMethods = [ toFormattedJSON ]
-  addMethodsToModel(Pod, classMethods, instanceMethods)
-
-  return Pod
-}
-
-// ------------------------------ METHODS ------------------------------
-
-toFormattedJSON = function (this: PodInstance) {
-  const json = {
-    id: this.id,
-    host: this.host,
-    score: this.score as number,
-    createdAt: this.createdAt
-  }
-
-  return json
-}
-
-// ------------------------------ Statics ------------------------------
-
-countAll = function () {
-  return Pod.count()
-}
-
-incrementScores = function (ids: number[], value: number) {
-  const update = {
-    score: Sequelize.literal('score +' + value)
-  }
-
-  const options = {
-    where: {
-      id: {
-        [Sequelize.Op.in]: ids
-      }
-    },
-    // In this case score is a literal and not an integer so we do not validate it
-    validate: false
-  }
-
-  return Pod.update(update, options)
-}
-
-list = function () {
-  return Pod.findAll()
-}
-
-listForApi = function (start: number, count: number, sort: string) {
-  const query = {
-    offset: start,
-    limit: count,
-    order: [ getSort(sort) ]
-  }
-
-  return Pod.findAndCountAll(query).then(({ rows, count }) => {
-    return {
-      data: rows,
-      total: count
-    }
-  })
-}
-
-listAllIds = function (transaction: Sequelize.Transaction) {
-  const query = {
-    attributes: [ 'id' ],
-    transaction
-  }
-
-  return Pod.findAll(query).then(pods => {
-    return map(pods, 'id')
-  })
-}
-
-listRandomPodIdsWithRequest = function (limit: number, tableWithPods: string, tableWithPodsJoins: string) {
-  return Pod.count().then(count => {
-    // Optimization...
-    if (count === 0) return []
-
-    let start = Math.floor(Math.random() * count) - limit
-    if (start < 0) start = 0
-
-    const subQuery = `(SELECT DISTINCT "${tableWithPods}"."podId" FROM "${tableWithPods}" ${tableWithPodsJoins})`
-    const query = {
-      attributes: [ 'id' ],
-      order: [
-        [ 'id', 'ASC' ]
-      ],
-      offset: start,
-      limit: limit,
-      where: {
-        id: {
-          [Sequelize.Op.in]: Sequelize.literal(subQuery)
-        }
-      }
-    }
-
-    return Pod.findAll(query).then(pods => {
-      return map(pods, 'id')
-    })
-  })
-}
-
-listBadPods = function () {
-  const query = {
-    where: {
-      score: {
-        [Sequelize.Op.lte]: 0
-      }
-    }
-  }
-
-  return Pod.findAll(query)
-}
-
-load = function (id: number) {
-  return Pod.findById(id)
-}
-
-loadByHost = function (host: string) {
-  const query = {
-    where: {
-      host: host
-    }
-  }
-
-  return Pod.findOne(query)
-}
-
-removeAll = function () {
-  return Pod.destroy()
-}
-
-updatePodsScore = function (goodPods: number[], badPods: number[]) {
-  logger.info('Updating %d good pods and %d bad pods scores.', goodPods.length, badPods.length)
-
-  if (goodPods.length !== 0) {
-    incrementScores(goodPods, PODS_SCORE.BONUS).catch(err => {
-      logger.error('Cannot increment scores of good pods.', err)
-    })
-  }
-
-  if (badPods.length !== 0) {
-    incrementScores(badPods, PODS_SCORE.PENALTY)
-      .then(() => removeBadPods())
-      .catch(err => {
-        if (err) logger.error('Cannot decrement scores of bad pods.', err)
-      })
-  }
-}
-
-// ---------------------------------------------------------------------------
-
-// Remove pods with a score of 0 (too many requests where they were unreachable)
-async function removeBadPods () {
-  try {
-    const pods = await listBadPods()
-
-    const podsRemovePromises = pods.map(pod => pod.destroy())
-    await Promise.all(podsRemovePromises)
-
-    const numberOfPodsRemoved = pods.length
-
-    if (numberOfPodsRemoved) {
-      logger.info('Removed %d pods.', numberOfPodsRemoved)
-    } else {
-      logger.info('No need to remove bad pods.')
-    }
-  } catch (err) {
-    logger.error('Cannot remove bad pods.', err)
-  }
-}
diff --git a/server/models/server/index.ts b/server/models/server/index.ts
new file mode 100644 (file)
index 0000000..4cb2994
--- /dev/null
@@ -0,0 +1 @@
+export * from './server-interface'
diff --git a/server/models/server/server-interface.ts b/server/models/server/server-interface.ts
new file mode 100644 (file)
index 0000000..806d052
--- /dev/null
@@ -0,0 +1,56 @@
+import * as Sequelize from 'sequelize'
+import * as Promise from 'bluebird'
+
+// Don't use barrel, import just what we need
+import { ResultList } from '../../../shared/models/result-list.model'
+
+export namespace ServerMethods {
+  export type CountAll = () => Promise<number>
+
+  export type IncrementScores = (ids: number[], value: number) => Promise<[ number, ServerInstance[] ]>
+
+  export type List = () => Promise<ServerInstance[]>
+
+  export type ListForApi = (start: number, count: number, sort: string) => Promise< ResultList<ServerInstance> >
+
+  export type ListAllIds = (transaction: Sequelize.Transaction) => Promise<number[]>
+
+  export type ListRandomServerIdsWithRequest = (limit: number, tableWithServers: string, tableWithServersJoins: string) => Promise<number[]>
+
+  export type ListBadServers = () => Promise<ServerInstance[]>
+
+  export type Load = (id: number) => Promise<ServerInstance>
+
+  export type LoadByHost = (host: string) => Promise<ServerInstance>
+
+  export type RemoveAll = () => Promise<number>
+
+  export type UpdateServersScore = (goodServers: number[], badServers: number[]) => void
+}
+
+export interface ServerClass {
+  countAll: ServerMethods.CountAll
+  incrementScores: ServerMethods.IncrementScores
+  list: ServerMethods.List
+  listForApi: ServerMethods.ListForApi
+  listAllIds: ServerMethods.ListAllIds
+  listRandomServerIdsWithRequest: ServerMethods.ListRandomServerIdsWithRequest
+  listBadServers: ServerMethods.ListBadServers
+  load: ServerMethods.Load
+  loadByHost: ServerMethods.LoadByHost
+  removeAll: ServerMethods.RemoveAll
+  updateServersScore: ServerMethods.UpdateServersScore
+}
+
+export interface ServerAttributes {
+  id?: number
+  host?: string
+  score?: number | Sequelize.literal // Sequelize literal for 'score +' + value
+}
+
+export interface ServerInstance extends ServerClass, ServerAttributes, Sequelize.Instance<ServerAttributes> {
+  createdAt: Date
+  updatedAt: Date
+}
+
+export interface ServerModel extends ServerClass, Sequelize.Model<ServerInstance, ServerAttributes> {}
diff --git a/server/models/server/server.ts b/server/models/server/server.ts
new file mode 100644 (file)
index 0000000..26fa875
--- /dev/null
@@ -0,0 +1,233 @@
+import { map } from 'lodash'
+import * as Sequelize from 'sequelize'
+
+import { FRIEND_SCORE, SERVERS_SCORE } from '../../initializers'
+import { logger, isHostValid } from '../../helpers'
+
+import { addMethodsToModel, getSort } from '../utils'
+import {
+  ServerInstance,
+  ServerAttributes,
+
+  ServerMethods
+} from './server-interface'
+
+let Server: Sequelize.Model<ServerInstance, ServerAttributes>
+let countAll: ServerMethods.CountAll
+let incrementScores: ServerMethods.IncrementScores
+let list: ServerMethods.List
+let listForApi: ServerMethods.ListForApi
+let listAllIds: ServerMethods.ListAllIds
+let listRandomServerIdsWithRequest: ServerMethods.ListRandomServerIdsWithRequest
+let listBadServers: ServerMethods.ListBadServers
+let load: ServerMethods.Load
+let loadByHost: ServerMethods.LoadByHost
+let removeAll: ServerMethods.RemoveAll
+let updateServersScore: ServerMethods.UpdateServersScore
+
+export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) {
+  Server = sequelize.define<ServerInstance, ServerAttributes>('Server',
+    {
+      host: {
+        type: DataTypes.STRING,
+        allowNull: false,
+        validate: {
+          isHost: value => {
+            const res = isHostValid(value)
+            if (res === false) throw new Error('Host not valid.')
+          }
+        }
+      },
+      score: {
+        type: DataTypes.INTEGER,
+        defaultValue: FRIEND_SCORE.BASE,
+        allowNull: false,
+        validate: {
+          isInt: true,
+          max: FRIEND_SCORE.MAX
+        }
+      }
+    },
+    {
+      indexes: [
+        {
+          fields: [ 'host' ],
+          unique: true
+        },
+        {
+          fields: [ 'score' ]
+        }
+      ]
+    }
+  )
+
+  const classMethods = [
+    countAll,
+    incrementScores,
+    list,
+    listForApi,
+    listAllIds,
+    listRandomServerIdsWithRequest,
+    listBadServers,
+    load,
+    loadByHost,
+    updateServersScore,
+    removeAll
+  ]
+  addMethodsToModel(Server, classMethods)
+
+  return Server
+}
+
+// ------------------------------ Statics ------------------------------
+
+countAll = function () {
+  return Server.count()
+}
+
+incrementScores = function (ids: number[], value: number) {
+  const update = {
+    score: Sequelize.literal('score +' + value)
+  }
+
+  const options = {
+    where: {
+      id: {
+        [Sequelize.Op.in]: ids
+      }
+    },
+    // In this case score is a literal and not an integer so we do not validate it
+    validate: false
+  }
+
+  return Server.update(update, options)
+}
+
+list = function () {
+  return Server.findAll()
+}
+
+listForApi = function (start: number, count: number, sort: string) {
+  const query = {
+    offset: start,
+    limit: count,
+    order: [ getSort(sort) ]
+  }
+
+  return Server.findAndCountAll(query).then(({ rows, count }) => {
+    return {
+      data: rows,
+      total: count
+    }
+  })
+}
+
+listAllIds = function (transaction: Sequelize.Transaction) {
+  const query = {
+    attributes: [ 'id' ],
+    transaction
+  }
+
+  return Server.findAll(query).then(servers => {
+    return map(servers, 'id')
+  })
+}
+
+listRandomServerIdsWithRequest = function (limit: number, tableWithServers: string, tableWithServersJoins: string) {
+  return Server.count().then(count => {
+    // Optimization...
+    if (count === 0) return []
+
+    let start = Math.floor(Math.random() * count) - limit
+    if (start < 0) start = 0
+
+    const subQuery = `(SELECT DISTINCT "${tableWithServers}"."serverId" FROM "${tableWithServers}" ${tableWithServersJoins})`
+    const query = {
+      attributes: [ 'id' ],
+      order: [
+        [ 'id', 'ASC' ]
+      ],
+      offset: start,
+      limit: limit,
+      where: {
+        id: {
+          [Sequelize.Op.in]: Sequelize.literal(subQuery)
+        }
+      }
+    }
+
+    return Server.findAll(query).then(servers => {
+      return map(servers, 'id')
+    })
+  })
+}
+
+listBadServers = function () {
+  const query = {
+    where: {
+      score: {
+        [Sequelize.Op.lte]: 0
+      }
+    }
+  }
+
+  return Server.findAll(query)
+}
+
+load = function (id: number) {
+  return Server.findById(id)
+}
+
+loadByHost = function (host: string) {
+  const query = {
+    where: {
+      host: host
+    }
+  }
+
+  return Server.findOne(query)
+}
+
+removeAll = function () {
+  return Server.destroy()
+}
+
+updateServersScore = function (goodServers: number[], badServers: number[]) {
+  logger.info('Updating %d good servers and %d bad servers scores.', goodServers.length, badServers.length)
+
+  if (goodServers.length !== 0) {
+    incrementScores(goodServers, SERVERS_SCORE.BONUS).catch(err => {
+      logger.error('Cannot increment scores of good servers.', err)
+    })
+  }
+
+  if (badServers.length !== 0) {
+    incrementScores(badServers, SERVERS_SCORE.PENALTY)
+      .then(() => removeBadServers())
+      .catch(err => {
+        if (err) logger.error('Cannot decrement scores of bad servers.', err)
+      })
+  }
+}
+
+// ---------------------------------------------------------------------------
+
+// Remove servers with a score of 0 (too many requests where they were unreachable)
+async function removeBadServers () {
+  try {
+    const servers = await listBadServers()
+
+    const serversRemovePromises = servers.map(server => server.destroy())
+    await Promise.all(serversRemovePromises)
+
+    const numberOfServersRemoved = servers.length
+
+    if (numberOfServersRemoved) {
+      logger.info('Removed %d servers.', numberOfServersRemoved)
+    } else {
+      logger.info('No need to remove bad servers.')
+    }
+  } catch (err) {
+    logger.error('Cannot remove bad servers.', err)
+  }
+}
index 978268926cbb9ad44f8c406fd2ab5edb67f13f93..16806cae2ee36378486f7bb99ad226c4a24e2bac 100644 (file)
@@ -1,7 +1,7 @@
 import * as Sequelize from 'sequelize'
 import * as Promise from 'bluebird'
 
-import { PodInstance } from '../pod/pod-interface'
+import { ServerInstance } from '../server/server-interface'
 import { ResultList } from '../../../shared'
 
 // Don't use barrel, import just what we need
@@ -28,7 +28,7 @@ export interface VideoAbuseInstance extends VideoAbuseClass, VideoAbuseAttribute
   createdAt: Date
   updatedAt: Date
 
-  Pod: PodInstance
+  Server: ServerInstance
 
   toFormattedJSON: VideoAbuseMethods.ToFormattedJSON
 }
index ebc63e7a058b46ce76a2d548afeb3ad8497d126d..c1d070ec0de8ca3dacae91c8879ded9dfa84d91f 100644 (file)
@@ -45,7 +45,7 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da
           fields: [ 'videoId' ]
         },
         {
-          fields: [ 'reporterPodId' ]
+          fields: [ 'reporterServerId' ]
         }
       ]
     }
@@ -67,18 +67,18 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da
 // ------------------------------ METHODS ------------------------------
 
 toFormattedJSON = function (this: VideoAbuseInstance) {
-  let reporterPodHost
+  let reporterServerHost
 
-  if (this.Pod) {
-    reporterPodHost = this.Pod.host
+  if (this.Server) {
+    reporterServerHost = this.Server.host
   } else {
     // It means it's our video
-    reporterPodHost = CONFIG.WEBSERVER.HOST
+    reporterServerHost = CONFIG.WEBSERVER.HOST
   }
 
   const json = {
     id: this.id,
-    reporterPodHost,
+    reporterServerHost,
     reason: this.reason,
     reporterUsername: this.reporterUsername,
     videoId: this.videoId,
@@ -91,9 +91,9 @@ toFormattedJSON = function (this: VideoAbuseInstance) {
 // ------------------------------ STATICS ------------------------------
 
 function associate (models) {
-  VideoAbuse.belongsTo(models.Pod, {
+  VideoAbuse.belongsTo(models.Server, {
     foreignKey: {
-      name: 'reporterPodId',
+      name: 'reporterServerId',
       allowNull: true
     },
     onDelete: 'CASCADE'
@@ -115,7 +115,7 @@ listForApi = function (start: number, count: number, sort: string) {
     order: [ getSort(sort) ],
     include: [
       {
-        model: VideoAbuse['sequelize'].models.Pod,
+        model: VideoAbuse['sequelize'].models.Server,
         required: false
       }
     ]
index 55e77206380f5bae245895e4855e8d58f1f9a1ed..8ad3e5cb7a907b305eec2bcfdb41306259a3120e 100644 (file)
@@ -22,7 +22,7 @@ export namespace VideoChannelMethods {
   export type LoadAndPopulateAccount = (id: number) => Promise<VideoChannelInstance>
   export type LoadByUUIDAndPopulateAccount = (uuid: string) => Promise<VideoChannelInstance>
   export type LoadByUUID = (uuid: string, t?: Sequelize.Transaction) => Promise<VideoChannelInstance>
-  export type LoadByHostAndUUID = (uuid: string, podHost: string, t?: Sequelize.Transaction) => Promise<VideoChannelInstance>
+  export type LoadByHostAndUUID = (uuid: string, serverHost: string, t?: Sequelize.Transaction) => Promise<VideoChannelInstance>
   export type LoadAndPopulateAccountAndVideos = (id: number) => Promise<VideoChannelInstance>
   export type LoadByUrl = (uuid: string, t?: Sequelize.Transaction) => Promise<VideoChannelInstance>
   export type LoadByUUIDOrUrl = (uuid: string, url: string, t?: Sequelize.Transaction) => Promise<VideoChannelInstance>
index 6d70f2aa2e77f23b4570bc474491fa3945a2ed29..3cb4a33b907cd90359666efc77cd7099ec288593 100644 (file)
@@ -218,7 +218,7 @@ listForApi = function (start: number, count: number, sort: string) {
       {
         model: VideoChannel['sequelize'].models.Account,
         required: true,
-        include: [ { model: VideoChannel['sequelize'].models.Pod, required: false } ]
+        include: [ { model: VideoChannel['sequelize'].models.Server, required: false } ]
       }
     ]
   }
@@ -238,7 +238,7 @@ listByAccount = function (accountId: number) {
           id: accountId
         },
         required: true,
-        include: [ { model: VideoChannel['sequelize'].models.Pod, required: false } ]
+        include: [ { model: VideoChannel['sequelize'].models.Server, required: false } ]
       }
     ]
   }
@@ -297,7 +297,7 @@ loadByHostAndUUID = function (fromHost: string, uuid: string, t?: Sequelize.Tran
         model: VideoChannel['sequelize'].models.Account,
         include: [
           {
-            model: VideoChannel['sequelize'].models.Pod,
+            model: VideoChannel['sequelize'].models.Server,
             required: true,
             where: {
               host: fromHost
@@ -322,7 +322,7 @@ loadByIdAndAccount = function (id: number, accountId: number) {
     include: [
       {
         model: VideoChannel['sequelize'].models.Account,
-        include: [ { model: VideoChannel['sequelize'].models.Pod, required: false } ]
+        include: [ { model: VideoChannel['sequelize'].models.Server, required: false } ]
       }
     ]
   }
@@ -335,7 +335,7 @@ loadAndPopulateAccount = function (id: number) {
     include: [
       {
         model: VideoChannel['sequelize'].models.Account,
-        include: [ { model: VideoChannel['sequelize'].models.Pod, required: false } ]
+        include: [ { model: VideoChannel['sequelize'].models.Server, required: false } ]
       }
     ]
   }
@@ -351,7 +351,7 @@ loadByUUIDAndPopulateAccount = function (uuid: string) {
     include: [
       {
         model: VideoChannel['sequelize'].models.Account,
-        include: [ { model: VideoChannel['sequelize'].models.Pod, required: false } ]
+        include: [ { model: VideoChannel['sequelize'].models.Server, required: false } ]
       }
     ]
   }
@@ -364,7 +364,7 @@ loadAndPopulateAccountAndVideos = function (id: number) {
     include: [
       {
         model: VideoChannel['sequelize'].models.Account,
-        include: [ { model: VideoChannel['sequelize'].models.Pod, required: false } ]
+        include: [ { model: VideoChannel['sequelize'].models.Server, required: false } ]
       },
       VideoChannel['sequelize'].models.Video
     ]
index 7243756d2b73b45016b08f9976ef0ffcc6546402..4df33f801c44958ed8944787515cdc23a9039fd4 100644 (file)
@@ -46,7 +46,7 @@ export namespace VideoMethods {
 
   export type ListForApi = (start: number, count: number, sort: string) => Bluebird< ResultList<VideoInstance> >
   export type ListUserVideosForApi = (userId: number, start: number, count: number, sort: string) => Bluebird< ResultList<VideoInstance> >
-  export type SearchAndPopulateAccountAndPodAndTags = (
+  export type SearchAndPopulateAccountAndServerAndTags = (
     value: string,
     field: string,
     start: number,
@@ -60,8 +60,8 @@ export namespace VideoMethods {
   export type LoadLocalVideoByUUID = (uuid: string, t?: Sequelize.Transaction) => Bluebird<VideoInstance>
   export type LoadByHostAndUUID = (fromHost: string, uuid: string, t?: Sequelize.Transaction) => Bluebird<VideoInstance>
   export type LoadAndPopulateAccount = (id: number) => Bluebird<VideoInstance>
-  export type LoadAndPopulateAccountAndPodAndTags = (id: number) => Bluebird<VideoInstance>
-  export type LoadByUUIDAndPopulateAccountAndPodAndTags = (uuid: string) => Bluebird<VideoInstance>
+  export type LoadAndPopulateAccountAndServerAndTags = (id: number) => Bluebird<VideoInstance>
+  export type LoadByUUIDAndPopulateAccountAndServerAndTags = (uuid: string) => Bluebird<VideoInstance>
   export type LoadByUUIDOrURL = (uuid: string, url: string, t?: Sequelize.Transaction) => Bluebird<VideoInstance>
 
   export type RemoveThumbnail = (this: VideoInstance) => Promise<void>
@@ -79,14 +79,14 @@ export interface VideoClass {
   listOwnedByAccount: VideoMethods.ListOwnedByAccount
   load: VideoMethods.Load
   loadAndPopulateAccount: VideoMethods.LoadAndPopulateAccount
-  loadAndPopulateAccountAndPodAndTags: VideoMethods.LoadAndPopulateAccountAndPodAndTags
+  loadAndPopulateAccountAndServerAndTags: VideoMethods.LoadAndPopulateAccountAndServerAndTags
   loadByHostAndUUID: VideoMethods.LoadByHostAndUUID
   loadByUUID: VideoMethods.LoadByUUID
   loadByUrl: VideoMethods.LoadByUrl
   loadByUUIDOrURL: VideoMethods.LoadByUUIDOrURL
   loadLocalVideoByUUID: VideoMethods.LoadLocalVideoByUUID
-  loadByUUIDAndPopulateAccountAndPodAndTags: VideoMethods.LoadByUUIDAndPopulateAccountAndPodAndTags
-  searchAndPopulateAccountAndPodAndTags: VideoMethods.SearchAndPopulateAccountAndPodAndTags
+  loadByUUIDAndPopulateAccountAndServerAndTags: VideoMethods.LoadByUUIDAndPopulateAccountAndServerAndTags
+  searchAndPopulateAccountAndServerAndTags: VideoMethods.SearchAndPopulateAccountAndServerAndTags
 }
 
 export interface VideoAttributes {
index dd73dd7caa7a813607232069a9c2a4a3d621a1d8..86800fb8897248a1411ff5e80e283db94d1be32b 100644 (file)
@@ -88,9 +88,9 @@ let loadByUUID: VideoMethods.LoadByUUID
 let loadByUUIDOrURL: VideoMethods.LoadByUUIDOrURL
 let loadLocalVideoByUUID: VideoMethods.LoadLocalVideoByUUID
 let loadAndPopulateAccount: VideoMethods.LoadAndPopulateAccount
-let loadAndPopulateAccountAndPodAndTags: VideoMethods.LoadAndPopulateAccountAndPodAndTags
-let loadByUUIDAndPopulateAccountAndPodAndTags: VideoMethods.LoadByUUIDAndPopulateAccountAndPodAndTags
-let searchAndPopulateAccountAndPodAndTags: VideoMethods.SearchAndPopulateAccountAndPodAndTags
+let loadAndPopulateAccountAndServerAndTags: VideoMethods.LoadAndPopulateAccountAndServerAndTags
+let loadByUUIDAndPopulateAccountAndServerAndTags: VideoMethods.LoadByUUIDAndPopulateAccountAndServerAndTags
+let searchAndPopulateAccountAndServerAndTags: VideoMethods.SearchAndPopulateAccountAndServerAndTags
 let removeThumbnail: VideoMethods.RemoveThumbnail
 let removePreview: VideoMethods.RemovePreview
 let removeFile: VideoMethods.RemoveFile
@@ -275,13 +275,13 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da
     listOwnedByAccount,
     load,
     loadAndPopulateAccount,
-    loadAndPopulateAccountAndPodAndTags,
+    loadAndPopulateAccountAndServerAndTags,
     loadByHostAndUUID,
     loadByUUIDOrURL,
     loadByUUID,
     loadLocalVideoByUUID,
-    loadByUUIDAndPopulateAccountAndPodAndTags,
-    searchAndPopulateAccountAndPodAndTags
+    loadByUUIDAndPopulateAccountAndServerAndTags,
+    searchAndPopulateAccountAndServerAndTags
   ]
   const instanceMethods = [
     createPreview,
@@ -477,13 +477,13 @@ getPreviewPath = function (this: VideoInstance) {
 }
 
 toFormattedJSON = function (this: VideoInstance) {
-  let podHost
+  let serverHost
 
-  if (this.VideoChannel.Account.Pod) {
-    podHost = this.VideoChannel.Account.Pod.host
+  if (this.VideoChannel.Account.Server) {
+    serverHost = this.VideoChannel.Account.Server.host
   } else {
     // It means it's our video
-    podHost = CONFIG.WEBSERVER.HOST
+    serverHost = CONFIG.WEBSERVER.HOST
   }
 
   const json = {
@@ -498,7 +498,7 @@ toFormattedJSON = function (this: VideoInstance) {
     languageLabel: this.getLanguageLabel(),
     nsfw: this.nsfw,
     description: this.getTruncatedDescription(),
-    podHost,
+    serverHost,
     isLocal: this.isOwned(),
     account: this.VideoChannel.Account.name,
     duration: this.duration,
@@ -519,7 +519,7 @@ toFormattedJSON = function (this: VideoInstance) {
 toFormattedDetailsJSON = function (this: VideoInstance) {
   const formattedJson = this.toFormattedJSON()
 
-  // Maybe our pod is not up to date and there are new privacy settings since our version
+  // Maybe our server is not up to date and there are new privacy settings since our version
   let privacyLabel = VIDEO_PRIVACIES[this.privacy]
   if (!privacyLabel) privacyLabel = 'Unknown'
 
@@ -721,7 +721,7 @@ getDescriptionPath = function (this: VideoInstance) {
 getCategoryLabel = function (this: VideoInstance) {
   let categoryLabel = VIDEO_CATEGORIES[this.category]
 
-  // Maybe our pod is not up to date and there are new categories since our version
+  // Maybe our server is not up to date and there are new categories since our version
   if (!categoryLabel) categoryLabel = 'Misc'
 
   return categoryLabel
@@ -730,7 +730,7 @@ getCategoryLabel = function (this: VideoInstance) {
 getLicenceLabel = function (this: VideoInstance) {
   let licenceLabel = VIDEO_LICENCES[this.licence]
 
-  // Maybe our pod is not up to date and there are new licences since our version
+  // Maybe our server is not up to date and there are new licences since our version
   if (!licenceLabel) licenceLabel = 'Unknown'
 
   return licenceLabel
@@ -830,7 +830,7 @@ listForApi = function (start: number, count: number, sort: string) {
             model: Video['sequelize'].models.Account,
             include: [
               {
-                model: Video['sequelize'].models.Pod,
+                model: Video['sequelize'].models.Server,
                 required: false
               }
             ]
@@ -866,7 +866,7 @@ loadByHostAndUUID = function (fromHost: string, uuid: string, t?: Sequelize.Tran
             model: Video['sequelize'].models.Account,
             include: [
               {
-                model: Video['sequelize'].models.Pod,
+                model: Video['sequelize'].models.Server,
                 required: true,
                 where: {
                   host: fromHost
@@ -989,7 +989,7 @@ loadAndPopulateAccount = function (id: number) {
   return Video.findById(id, options)
 }
 
-loadAndPopulateAccountAndPodAndTags = function (id: number) {
+loadAndPopulateAccountAndServerAndTags = function (id: number) {
   const options = {
     include: [
       {
@@ -997,7 +997,7 @@ loadAndPopulateAccountAndPodAndTags = function (id: number) {
         include: [
           {
             model: Video['sequelize'].models.Account,
-            include: [ { model: Video['sequelize'].models.Pod, required: false } ]
+            include: [ { model: Video['sequelize'].models.Server, required: false } ]
           }
         ]
       },
@@ -1009,7 +1009,7 @@ loadAndPopulateAccountAndPodAndTags = function (id: number) {
   return Video.findById(id, options)
 }
 
-loadByUUIDAndPopulateAccountAndPodAndTags = function (uuid: string) {
+loadByUUIDAndPopulateAccountAndServerAndTags = function (uuid: string) {
   const options = {
     where: {
       uuid
@@ -1020,7 +1020,7 @@ loadByUUIDAndPopulateAccountAndPodAndTags = function (uuid: string) {
         include: [
           {
             model: Video['sequelize'].models.Account,
-            include: [ { model: Video['sequelize'].models.Pod, required: false } ]
+            include: [ { model: Video['sequelize'].models.Server, required: false } ]
           }
         ]
       },
@@ -1032,15 +1032,15 @@ loadByUUIDAndPopulateAccountAndPodAndTags = function (uuid: string) {
   return Video.findOne(options)
 }
 
-searchAndPopulateAccountAndPodAndTags = function (value: string, field: string, start: number, count: number, sort: string) {
-  const podInclude: Sequelize.IncludeOptions = {
-    model: Video['sequelize'].models.Pod,
+searchAndPopulateAccountAndServerAndTags = function (value: string, field: string, start: number, count: number, sort: string) {
+  const serverInclude: Sequelize.IncludeOptions = {
+    model: Video['sequelize'].models.Server,
     required: false
   }
 
   const accountInclude: Sequelize.IncludeOptions = {
     model: Video['sequelize'].models.Account,
-    include: [ podInclude ]
+    include: [ serverInclude ]
   }
 
   const videoChannelInclude: Sequelize.IncludeOptions = {
@@ -1071,13 +1071,13 @@ searchAndPopulateAccountAndPodAndTags = function (value: string, field: string,
        )`
     )
   } else if (field === 'host') {
-    // FIXME: Include our pod? (not stored in the database)
-    podInclude.where = {
+    // FIXME: Include our server? (not stored in the database)
+    serverInclude.where = {
       host: {
         [Sequelize.Op.iLike]: '%' + value + '%'
       }
     }
-    podInclude.required = true
+    serverInclude.required = true
   } else if (field === 'account') {
     accountInclude.where = {
       name: {
@@ -1123,8 +1123,8 @@ function getBaseUrls (video: VideoInstance) {
     baseUrlHttp = CONFIG.WEBSERVER.URL
     baseUrlWs = CONFIG.WEBSERVER.WS + '://' + CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT
   } else {
-    baseUrlHttp = REMOTE_SCHEME.HTTP + '://' + video.VideoChannel.Account.Pod.host
-    baseUrlWs = REMOTE_SCHEME.WS + '://' + video.VideoChannel.Account.Pod.host
+    baseUrlHttp = REMOTE_SCHEME.HTTP + '://' + video.VideoChannel.Account.Server.host
+    baseUrlWs = REMOTE_SCHEME.WS + '://' + video.VideoChannel.Account.Server.host
   }
 
   return { baseUrlHttp, baseUrlWs }
index 80cfe07e4816fe696b008777b8d85990c5faee62..8094634c1ed76c758f4a6e44b3c2484d30116f6e 100644 (file)
@@ -1 +1,8 @@
 export type FollowState = 'pending' | 'accepted'
+
+export interface AccountFollow {
+  id: number
+  name: string
+  score?: number // Used for followers
+  host: string
+}
index 28decac03f352a99dcac38b2bf092d52d9b807b5..faf616bfc46e67da491817dc997021339671815c 100644 (file)
@@ -1,10 +1,8 @@
 export * from './accounts'
 export * from './activitypub'
-export * from './pods'
 export * from './users'
 export * from './videos'
 export * from './job.model'
 export * from './oauth-client-local.model'
 export * from './result-list.model'
-export * from './request-scheduler.model'
 export * from './server-config.model'
diff --git a/shared/models/pods/index.ts b/shared/models/pods/index.ts
deleted file mode 100644 (file)
index f59d015..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-export * from './pod-signature.model'
-export * from './pod.model'
-export * from './remote-video'
diff --git a/shared/models/pods/pod-signature.model.ts b/shared/models/pods/pod-signature.model.ts
deleted file mode 100644 (file)
index b7988a4..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-export interface PodSignature {
-  host: string
-  signature: string
-}
diff --git a/shared/models/pods/pod.model.ts b/shared/models/pods/pod.model.ts
deleted file mode 100644 (file)
index ff9e8f2..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-export interface Pod {
-  id: number,
-  host: string,
-  score: number,
-  createdAt: Date
-}
diff --git a/shared/models/pods/remote-video/index.ts b/shared/models/pods/remote-video/index.ts
deleted file mode 100644 (file)
index 918b9e1..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-export * from './remote-qadu-video-request.model'
-export * from './remote-video-author-create-request.model'
-export * from './remote-video-author-remove-request.model'
-export * from './remote-video-event-request.model'
-export * from './remote-video-request.model'
-export * from './remote-video-create-request.model'
-export * from './remote-video-update-request.model'
-export * from './remote-video-remove-request.model'
-export * from './remote-video-channel-create-request.model'
-export * from './remote-video-channel-update-request.model'
-export * from './remote-video-channel-remove-request.model'
-export * from './remote-video-report-abuse-request.model'
diff --git a/shared/models/pods/remote-video/remote-qadu-video-request.model.ts b/shared/models/pods/remote-video/remote-qadu-video-request.model.ts
deleted file mode 100644 (file)
index 6128c58..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-export interface RemoteQaduVideoData {
-  uuid: string
-  views?: number
-  likes?: number
-  dislikes?: number
-}
-
-export interface RemoteQaduVideoRequest {
-  data: RemoteQaduVideoData
-}
diff --git a/shared/models/pods/remote-video/remote-video-author-create-request.model.ts b/shared/models/pods/remote-video/remote-video-author-create-request.model.ts
deleted file mode 100644 (file)
index ae364d1..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-import { RemoteVideoRequest } from './remote-video-request.model'
-
-export interface RemoteVideoAuthorCreateData {
-  uuid: string
-  name: string
-}
-
-export interface RemoteVideoAuthorCreateRequest extends RemoteVideoRequest {
-  type: 'add-author'
-  data: RemoteVideoAuthorCreateData
-}
diff --git a/shared/models/pods/remote-video/remote-video-author-remove-request.model.ts b/shared/models/pods/remote-video/remote-video-author-remove-request.model.ts
deleted file mode 100644 (file)
index 8738e92..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-import { RemoteVideoRequest } from './remote-video-request.model'
-
-export interface RemoteVideoAuthorRemoveData {
-  uuid: string
-}
-
-export interface RemoteVideoAuthorRemoveRequest extends RemoteVideoRequest {
-  type: 'remove-author'
-  data: RemoteVideoAuthorRemoveData
-}
diff --git a/shared/models/pods/remote-video/remote-video-channel-create-request.model.ts b/shared/models/pods/remote-video/remote-video-channel-create-request.model.ts
deleted file mode 100644 (file)
index 54163a2..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-import { RemoteVideoRequest } from './remote-video-request.model'
-
-export interface RemoteVideoChannelCreateData {
-  uuid: string
-  name: string
-  description: string
-  createdAt: Date
-  updatedAt: Date
-  ownerUUID: string
-}
-
-export interface RemoteVideoChannelCreateRequest extends RemoteVideoRequest {
-  type: 'add-channel'
-  data: RemoteVideoChannelCreateData
-}
diff --git a/shared/models/pods/remote-video/remote-video-channel-remove-request.model.ts b/shared/models/pods/remote-video/remote-video-channel-remove-request.model.ts
deleted file mode 100644 (file)
index 7aa3fe1..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-import { RemoteVideoRequest } from './remote-video-request.model'
-
-export interface RemoteVideoChannelRemoveData {
-  uuid: string
-}
-
-export interface RemoteVideoChannelRemoveRequest extends RemoteVideoRequest {
-  type: 'remove-channel'
-  data: RemoteVideoChannelRemoveData
-}
diff --git a/shared/models/pods/remote-video/remote-video-channel-update-request.model.ts b/shared/models/pods/remote-video/remote-video-channel-update-request.model.ts
deleted file mode 100644 (file)
index 70250d1..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-import { RemoteVideoRequest } from './remote-video-request.model'
-
-export interface RemoteVideoChannelUpdateData {
-  uuid: string
-  name: string
-  description: string
-  createdAt: Date
-  updatedAt: Date
-  ownerUUID: string
-}
-
-export interface RemoteVideoChannelUpdateRequest extends RemoteVideoRequest {
-  type: 'update-channel'
-  data: RemoteVideoChannelUpdateData
-}
diff --git a/shared/models/pods/remote-video/remote-video-create-request.model.ts b/shared/models/pods/remote-video/remote-video-create-request.model.ts
deleted file mode 100644 (file)
index 9a382e6..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-import { RemoteVideoRequest } from './remote-video-request.model'
-
-export interface RemoteVideoCreateData {
-  uuid: string
-  channelUUID: string
-  tags: string[]
-  name: string
-  category: number
-  licence: number
-  language: number
-  nsfw: boolean
-  truncatedDescription: string
-  duration: number
-  createdAt: Date
-  updatedAt: Date
-  views: number
-  likes: number
-  dislikes: number
-  privacy: number
-  thumbnailData: string
-  files: {
-    infoHash: string
-    extname: string
-    resolution: number
-    size: number
-  }[]
-}
-
-export interface RemoteVideoCreateRequest extends RemoteVideoRequest {
-  type: 'add-video'
-  data: RemoteVideoCreateData
-}
diff --git a/shared/models/pods/remote-video/remote-video-event-request.model.ts b/shared/models/pods/remote-video/remote-video-event-request.model.ts
deleted file mode 100644 (file)
index ecc3747..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-export type RemoteVideoEventType = 'views' | 'likes' | 'dislikes'
-
-export interface RemoteVideoEventData {
-  uuid: string
-  eventType: RemoteVideoEventType
-  count: number
-}
-
-export interface RemoteVideoEventRequest {
-  data: RemoteVideoEventData
-}
diff --git a/shared/models/pods/remote-video/remote-video-remove-request.model.ts b/shared/models/pods/remote-video/remote-video-remove-request.model.ts
deleted file mode 100644 (file)
index 79a5e0a..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-import { RemoteVideoRequest } from './remote-video-request.model'
-
-export interface RemoteVideoRemoveData {
-  uuid: string
-}
-
-export interface RemoteVideoRemoveRequest extends RemoteVideoRequest {
-  type: 'remove-video'
-  data: RemoteVideoRemoveData
-}
diff --git a/shared/models/pods/remote-video/remote-video-report-abuse-request.model.ts b/shared/models/pods/remote-video/remote-video-report-abuse-request.model.ts
deleted file mode 100644 (file)
index 05ad132..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-import { RemoteVideoRequest } from './remote-video-request.model'
-
-export interface RemoteVideoReportAbuseData {
-  videoUUID: string
-  reporterUsername: string
-  reportReason: string
-}
-
-export interface RemoteVideoReportAbuseRequest extends RemoteVideoRequest {
-  type: 'report-abuse'
-  data: RemoteVideoReportAbuseData
-}
diff --git a/shared/models/pods/remote-video/remote-video-request.model.ts b/shared/models/pods/remote-video/remote-video-request.model.ts
deleted file mode 100644 (file)
index 56f8136..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-export interface RemoteVideoRequest {
-  type: RemoteVideoRequestType
-  data: any
-}
-
-export type RemoteVideoRequestType = 'add-video' | 'update-video' | 'remove-video' |
-                                     'add-channel' | 'update-channel' | 'remove-channel' |
-                                     'report-abuse' |
-                                     'add-author' | 'remove-author'
diff --git a/shared/models/pods/remote-video/remote-video-update-request.model.ts b/shared/models/pods/remote-video/remote-video-update-request.model.ts
deleted file mode 100644 (file)
index 924489c..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-import { RemoteVideoRequest } from './remote-video-request.model'
-
-export interface RemoteVideoUpdateData {
-  uuid: string
-  tags: string[]
-  name: string
-  category: number
-  licence: number
-  language: number
-  nsfw: boolean
-  truncatedDescription: string
-  duration: number
-  createdAt: Date
-  updatedAt: Date
-  views: number
-  likes: number
-  dislikes: number
-  privacy: number
-  files: {
-    infoHash: string
-    extname: string
-    resolution: number
-    size: number
-  }[]
-}
-
-export interface RemoteVideoUpdateRequest extends RemoteVideoRequest {
-  type: 'update-video'
-  data: RemoteVideoUpdateData
-}
diff --git a/shared/models/request-scheduler.model.ts b/shared/models/request-scheduler.model.ts
deleted file mode 100644 (file)
index 8df184a..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-export type RequestEndpoint = 'videos'
-
-export type RequestVideoQaduType = 'likes' | 'dislikes' | 'views'
-
-export type RequestVideoEventType = 'likes' | 'dislikes' | 'views'
-
-export type RequestSchedulerStatsAttributes = {
-  totalRequests: number
-  requestsLimitPods: number
-  requestsLimitPerPod: number
-  remainingMilliSeconds: number
-  milliSecondsInterval: number
-}
-
-export interface RequestSchedulerStats {
-  requestScheduler: RequestSchedulerStatsAttributes
-  requestVideoQaduScheduler: RequestSchedulerStatsAttributes
-  requestVideoEventScheduler: RequestSchedulerStatsAttributes
-}
index e005a1fd52b0d104797f3970eedcb2b9d83ce309..38041e491b006c2dd363f0dc6ee0a86d2beaf419 100644 (file)
@@ -1,6 +1,6 @@
 export interface VideoAbuse {
   id: number
-  reporterPodHost: string
+  reporterServerHost: string
   reason: string
   reporterUsername: string
   videoId: number
index 0606f1aec53cd17099b2463416a8a735b26cd721..08b29425cbb39acc8be413225745fd3afe32de11 100644 (file)
@@ -26,7 +26,7 @@ export interface Video {
   duration: number
   isLocal: boolean
   name: string
-  podHost: string
+  serverHost: string
   tags: string[]
   thumbnailPath: string
   previewPath: string