diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/controllers/api/pods.ts | 3 | ||||
-rw-r--r-- | server/lib/friends.ts | 10 | ||||
-rw-r--r-- | server/lib/oauth-model.ts | 7 | ||||
-rw-r--r-- | server/models/video/tag.ts | 2 | ||||
-rw-r--r-- | server/models/video/video.ts | 16 |
5 files changed, 20 insertions, 18 deletions
diff --git a/server/controllers/api/pods.ts b/server/controllers/api/pods.ts index 55a7df661..5210f9fe4 100644 --- a/server/controllers/api/pods.ts +++ b/server/controllers/api/pods.ts | |||
@@ -23,6 +23,7 @@ import { | |||
23 | import { | 23 | import { |
24 | PodInstance | 24 | PodInstance |
25 | } from '../../models' | 25 | } from '../../models' |
26 | import { Pod as FormatedPod } from '../../../shared' | ||
26 | 27 | ||
27 | const podsRouter = express.Router() | 28 | const podsRouter = express.Router() |
28 | 29 | ||
@@ -72,7 +73,7 @@ function addPods (req: express.Request, res: express.Response, next: express.Nex | |||
72 | 73 | ||
73 | function listPods (req: express.Request, res: express.Response, next: express.NextFunction) { | 74 | function listPods (req: express.Request, res: express.Response, next: express.NextFunction) { |
74 | db.Pod.list() | 75 | db.Pod.list() |
75 | .then(podsList => res.json(getFormatedObjects(podsList, podsList.length))) | 76 | .then(podsList => res.json(getFormatedObjects<FormatedPod, PodInstance>(podsList, podsList.length))) |
76 | .catch(err => next(err)) | 77 | .catch(err => next(err)) |
77 | } | 78 | } |
78 | 79 | ||
diff --git a/server/lib/friends.ts b/server/lib/friends.ts index 4d56e9eb2..a65820191 100644 --- a/server/lib/friends.ts +++ b/server/lib/friends.ts | |||
@@ -38,7 +38,9 @@ import { | |||
38 | RemoteVideoCreateData, | 38 | RemoteVideoCreateData, |
39 | RemoteVideoUpdateData, | 39 | RemoteVideoUpdateData, |
40 | RemoteVideoRemoveData, | 40 | RemoteVideoRemoveData, |
41 | RemoteVideoReportAbuseData | 41 | RemoteVideoReportAbuseData, |
42 | ResultList, | ||
43 | Pod as FormatedPod | ||
42 | } from '../../shared' | 44 | } from '../../shared' |
43 | 45 | ||
44 | type QaduParam = { videoId: string, type: RequestVideoQaduType } | 46 | type QaduParam = { videoId: string, type: RequestVideoQaduType } |
@@ -268,8 +270,8 @@ export { | |||
268 | 270 | ||
269 | function computeForeignPodsList (host: string, podsScore: { [ host: string ]: number }) { | 271 | function computeForeignPodsList (host: string, podsScore: { [ host: string ]: number }) { |
270 | // TODO: type res | 272 | // TODO: type res |
271 | return getForeignPodsList(host).then((res: any) => { | 273 | return getForeignPodsList(host).then(res => { |
272 | const foreignPodsList = res.data | 274 | const foreignPodsList: { host: string }[] = res.data |
273 | 275 | ||
274 | // Let's give 1 point to the pod we ask the friends list | 276 | // Let's give 1 point to the pod we ask the friends list |
275 | foreignPodsList.push({ host }) | 277 | foreignPodsList.push({ host }) |
@@ -302,7 +304,7 @@ function computeWinningPods (hosts: string[], podsScore: { [ host: string ]: num | |||
302 | } | 304 | } |
303 | 305 | ||
304 | function getForeignPodsList (host: string) { | 306 | function getForeignPodsList (host: string) { |
305 | return new Promise((res, rej) => { | 307 | return new Promise< ResultList<FormatedPod> >((res, rej) => { |
306 | const path = '/api/' + API_VERSION + '/pods' | 308 | const path = '/api/' + API_VERSION + '/pods' |
307 | 309 | ||
308 | request.get(REMOTE_SCHEME.HTTP + '://' + host + path, function (err, response, body) { | 310 | request.get(REMOTE_SCHEME.HTTP + '://' + host + path, function (err, response, body) { |
diff --git a/server/lib/oauth-model.ts b/server/lib/oauth-model.ts index f34c9c667..2d7e56756 100644 --- a/server/lib/oauth-model.ts +++ b/server/lib/oauth-model.ts | |||
@@ -68,11 +68,10 @@ function saveToken (token: TokenInfo, client: OAuthClientInstance, user: UserIns | |||
68 | userId: user.id | 68 | userId: user.id |
69 | } | 69 | } |
70 | 70 | ||
71 | return db.OAuthToken.create(tokenToCreate).then(function (tokenCreated: any) { | 71 | return db.OAuthToken.create(tokenToCreate).then(tokenCreated => { |
72 | tokenCreated.client = client | 72 | const tokenToReturn = Object.assign(tokenCreated, { client, user }) |
73 | tokenCreated.user = user | ||
74 | 73 | ||
75 | return tokenCreated | 74 | return tokenToReturn |
76 | }) | 75 | }) |
77 | } | 76 | } |
78 | 77 | ||
diff --git a/server/models/video/tag.ts b/server/models/video/tag.ts index d0d8353d7..2992da56d 100644 --- a/server/models/video/tag.ts +++ b/server/models/video/tag.ts | |||
@@ -54,7 +54,7 @@ function associate (models) { | |||
54 | findOrCreateTags = function (tags: string[], transaction: Sequelize.Transaction) { | 54 | findOrCreateTags = function (tags: string[], transaction: Sequelize.Transaction) { |
55 | const tasks: Promise<TagInstance>[] = [] | 55 | const tasks: Promise<TagInstance>[] = [] |
56 | tags.forEach(tag => { | 56 | tags.forEach(tag => { |
57 | const query: any = { | 57 | const query: Sequelize.FindOrInitializeOptions<TagAttributes> = { |
58 | where: { | 58 | where: { |
59 | name: tag | 59 | name: tag |
60 | }, | 60 | }, |
diff --git a/server/models/video/video.ts b/server/models/video/video.ts index 47d3cad1d..496385b35 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts | |||
@@ -696,23 +696,23 @@ loadAndPopulateAuthorAndPodAndTags = function (id: string) { | |||
696 | } | 696 | } |
697 | 697 | ||
698 | searchAndPopulateAuthorAndPodAndTags = function (value: string, field: string, start: number, count: number, sort: string) { | 698 | searchAndPopulateAuthorAndPodAndTags = function (value: string, field: string, start: number, count: number, sort: string) { |
699 | const podInclude: any = { | 699 | const podInclude: Sequelize.IncludeOptions = { |
700 | model: Video['sequelize'].models.Pod, | 700 | model: Video['sequelize'].models.Pod, |
701 | required: false | 701 | required: false |
702 | } | 702 | } |
703 | 703 | ||
704 | const authorInclude: any = { | 704 | const authorInclude: Sequelize.IncludeOptions = { |
705 | model: Video['sequelize'].models.Author, | 705 | model: Video['sequelize'].models.Author, |
706 | include: [ | 706 | include: [ |
707 | podInclude | 707 | podInclude |
708 | ] | 708 | ] |
709 | } | 709 | } |
710 | 710 | ||
711 | const tagInclude: any = { | 711 | const tagInclude: Sequelize.IncludeOptions = { |
712 | model: Video['sequelize'].models.Tag | 712 | model: Video['sequelize'].models.Tag |
713 | } | 713 | } |
714 | 714 | ||
715 | const query: any = { | 715 | const query: Sequelize.FindOptions = { |
716 | distinct: true, | 716 | distinct: true, |
717 | where: createBaseVideosWhere(), | 717 | where: createBaseVideosWhere(), |
718 | offset: start, | 718 | offset: start, |
@@ -723,10 +723,10 @@ searchAndPopulateAuthorAndPodAndTags = function (value: string, field: string, s | |||
723 | // Make an exact search with the magnet | 723 | // Make an exact search with the magnet |
724 | if (field === 'magnetUri') { | 724 | if (field === 'magnetUri') { |
725 | const infoHash = magnetUtil.decode(value).infoHash | 725 | const infoHash = magnetUtil.decode(value).infoHash |
726 | query.where.infoHash = infoHash | 726 | query.where['infoHash'] = infoHash |
727 | } else if (field === 'tags') { | 727 | } else if (field === 'tags') { |
728 | const escapedValue = Video['sequelize'].escape('%' + value + '%') | 728 | const escapedValue = Video['sequelize'].escape('%' + value + '%') |
729 | query.where.id.$in = Video['sequelize'].literal( | 729 | query.where['id'].$in = Video['sequelize'].literal( |
730 | `(SELECT "VideoTags"."videoId" | 730 | `(SELECT "VideoTags"."videoId" |
731 | FROM "Tags" | 731 | FROM "Tags" |
732 | INNER JOIN "VideoTags" ON "Tags"."id" = "VideoTags"."tagId" | 732 | INNER JOIN "VideoTags" ON "Tags"."id" = "VideoTags"."tagId" |
@@ -830,14 +830,14 @@ function createThumbnail (video: VideoInstance, videoPath: string) { | |||
830 | } | 830 | } |
831 | 831 | ||
832 | function generateImage (video: VideoInstance, videoPath: string, folder: string, imageName: string, size: string) { | 832 | function generateImage (video: VideoInstance, videoPath: string, folder: string, imageName: string, size: string) { |
833 | const options: any = { | 833 | const options = { |
834 | filename: imageName, | 834 | filename: imageName, |
835 | count: 1, | 835 | count: 1, |
836 | folder | 836 | folder |
837 | } | 837 | } |
838 | 838 | ||
839 | if (size) { | 839 | if (size) { |
840 | options.size = size | 840 | options['size'] = size |
841 | } | 841 | } |
842 | 842 | ||
843 | return new Promise<string>((res, rej) => { | 843 | return new Promise<string>((res, rej) => { |