aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--client/src/app/+admin/follows/shared/follow.service.ts2
-rw-r--r--client/src/app/shared/users/user.service.ts7
-rw-r--r--client/src/app/shared/video/video.service.ts9
-rw-r--r--server/controllers/api/users.ts6
-rw-r--r--shared/models/users/index.ts1
-rw-r--r--shared/models/users/user-video-quota.model.ts3
6 files changed, 17 insertions, 11 deletions
diff --git a/client/src/app/+admin/follows/shared/follow.service.ts b/client/src/app/+admin/follows/shared/follow.service.ts
index 5897e64ca..87ea5fb0c 100644
--- a/client/src/app/+admin/follows/shared/follow.service.ts
+++ b/client/src/app/+admin/follows/shared/follow.service.ts
@@ -22,7 +22,7 @@ export class FollowService {
22 let params = new HttpParams() 22 let params = new HttpParams()
23 params = this.restService.addRestGetParams(params, pagination, sort) 23 params = this.restService.addRestGetParams(params, pagination, sort)
24 24
25 return this.authHttp.get<ResultList<Account>>(FollowService.BASE_APPLICATION_URL + '/following', { params }) 25 return this.authHttp.get<ResultList<AccountFollow>>(FollowService.BASE_APPLICATION_URL + '/following', { params })
26 .pipe( 26 .pipe(
27 map(res => this.restExtractor.convertResultListDateToHuman(res)), 27 map(res => this.restExtractor.convertResultListDateToHuman(res)),
28 catchError(res => this.restExtractor.handleError(res)) 28 catchError(res => this.restExtractor.handleError(res))
diff --git a/client/src/app/shared/users/user.service.ts b/client/src/app/shared/users/user.service.ts
index 4843be618..9fe6c8b60 100644
--- a/client/src/app/shared/users/user.service.ts
+++ b/client/src/app/shared/users/user.service.ts
@@ -1,9 +1,10 @@
1import { catchError, map } from 'rxjs/operators' 1import { catchError, map } from 'rxjs/operators'
2import { HttpClient } from '@angular/common/http' 2import { HttpClient } from '@angular/common/http'
3import { Injectable } from '@angular/core' 3import { Injectable } from '@angular/core'
4import { UserCreate, UserUpdateMe } from '../../../../../shared' 4import { UserCreate, UserUpdateMe, UserVideoQuota } from '../../../../../shared'
5import { environment } from '../../../environments/environment' 5import { environment } from '../../../environments/environment'
6import { RestExtractor } from '../rest' 6import { RestExtractor } from '../rest'
7import { Avatar } from '../../../../../shared/models/avatars/avatar.model'
7 8
8@Injectable() 9@Injectable()
9export class UserService { 10export class UserService {
@@ -41,7 +42,7 @@ export class UserService {
41 changeAvatar (avatarForm: FormData) { 42 changeAvatar (avatarForm: FormData) {
42 const url = UserService.BASE_USERS_URL + 'me/avatar/pick' 43 const url = UserService.BASE_USERS_URL + 'me/avatar/pick'
43 44
44 return this.authHttp.post(url, avatarForm) 45 return this.authHttp.post<{ avatar: Avatar }>(url, avatarForm)
45 .pipe(catchError(this.restExtractor.handleError)) 46 .pipe(catchError(this.restExtractor.handleError))
46 } 47 }
47 48
@@ -56,7 +57,7 @@ export class UserService {
56 getMyVideoQuotaUsed () { 57 getMyVideoQuotaUsed () {
57 const url = UserService.BASE_USERS_URL + '/me/video-quota-used' 58 const url = UserService.BASE_USERS_URL + '/me/video-quota-used'
58 59
59 return this.authHttp.get(url) 60 return this.authHttp.get<UserVideoQuota>(url)
60 .pipe(catchError(res => this.restExtractor.handleError(res))) 61 .pipe(catchError(res => this.restExtractor.handleError(res)))
61 } 62 }
62 63
diff --git a/client/src/app/shared/video/video.service.ts b/client/src/app/shared/video/video.service.ts
index f57cb6d6d..5b8e2467a 100644
--- a/client/src/app/shared/video/video.service.ts
+++ b/client/src/app/shared/video/video.service.ts
@@ -48,7 +48,7 @@ export class VideoService {
48 ) 48 )
49 } 49 }
50 50
51 viewVideo (uuid: string): Observable<VideoDetails> { 51 viewVideo (uuid: string): Observable<boolean> {
52 return this.authHttp.post(this.getVideoViewUrl(uuid), {}) 52 return this.authHttp.post(this.getVideoViewUrl(uuid), {})
53 .pipe( 53 .pipe(
54 map(this.restExtractor.extractDataBool), 54 map(this.restExtractor.extractDataBool),
@@ -92,7 +92,7 @@ export class VideoService {
92 const req = new HttpRequest('POST', VideoService.BASE_VIDEO_URL + 'upload', video, { reportProgress: true }) 92 const req = new HttpRequest('POST', VideoService.BASE_VIDEO_URL + 'upload', video, { reportProgress: true })
93 93
94 return this.authHttp 94 return this.authHttp
95 .request(req) 95 .request<{ video: { id: number, uuid: string} }>(req)
96 .pipe(catchError(this.restExtractor.handleError)) 96 .pipe(catchError(this.restExtractor.handleError))
97 } 97 }
98 98
@@ -265,11 +265,10 @@ export class VideoService {
265 return this.setVideoRate(id, 'none') 265 return this.setVideoRate(id, 'none')
266 } 266 }
267 267
268 getUserVideoRating (id: number): Observable<UserVideoRate> { 268 getUserVideoRating (id: number) {
269 const url = UserService.BASE_USERS_URL + 'me/videos/' + id + '/rating' 269 const url = UserService.BASE_USERS_URL + 'me/videos/' + id + '/rating'
270 270
271 return this.authHttp 271 return this.authHttp.get<UserVideoRate>(url)
272 .get(url)
273 .pipe(catchError(res => this.restExtractor.handleError(res))) 272 .pipe(catchError(res => this.restExtractor.handleError(res)))
274 } 273 }
275 274
diff --git a/server/controllers/api/users.ts b/server/controllers/api/users.ts
index 2342c23dd..0a591f11d 100644
--- a/server/controllers/api/users.ts
+++ b/server/controllers/api/users.ts
@@ -44,6 +44,7 @@ import { OAuthTokenModel } from '../../models/oauth/oauth-token'
44import { VideoModel } from '../../models/video/video' 44import { VideoModel } from '../../models/video/video'
45import { VideoSortField } from '../../../client/src/app/shared/video/sort-field.type' 45import { VideoSortField } from '../../../client/src/app/shared/video/sort-field.type'
46import { createReqFiles } from '../../helpers/express-utils' 46import { createReqFiles } from '../../helpers/express-utils'
47import { UserVideoQuota } from '../../../shared/models/users/user-video-quota.model'
47 48
48const reqAvatarFile = createReqFiles([ 'avatarfile' ], IMAGE_MIMETYPE_EXT, { avatarfile: CONFIG.STORAGE.AVATARS_DIR }) 49const reqAvatarFile = createReqFiles([ 'avatarfile' ], IMAGE_MIMETYPE_EXT, { avatarfile: CONFIG.STORAGE.AVATARS_DIR })
49const loginRateLimiter = new RateLimit({ 50const loginRateLimiter = new RateLimit({
@@ -253,9 +254,10 @@ async function getUserVideoQuotaUsed (req: express.Request, res: express.Respons
253 const user = await UserModel.loadByUsernameAndPopulateChannels(res.locals.oauth.token.user.username) 254 const user = await UserModel.loadByUsernameAndPopulateChannels(res.locals.oauth.token.user.username)
254 const videoQuotaUsed = await UserModel.getOriginalVideoFileTotalFromUser(user) 255 const videoQuotaUsed = await UserModel.getOriginalVideoFileTotalFromUser(user)
255 256
256 return res.json({ 257 const data: UserVideoQuota = {
257 videoQuotaUsed 258 videoQuotaUsed
258 }) 259 }
260 return res.json(data)
259} 261}
260 262
261function getUser (req: express.Request, res: express.Response, next: express.NextFunction) { 263function getUser (req: express.Request, res: express.Response, next: express.NextFunction) {
diff --git a/shared/models/users/index.ts b/shared/models/users/index.ts
index a260bd380..15c2f99c2 100644
--- a/shared/models/users/index.ts
+++ b/shared/models/users/index.ts
@@ -6,3 +6,4 @@ export * from './user-update.model'
6export * from './user-update-me.model' 6export * from './user-update-me.model'
7export * from './user-right.enum' 7export * from './user-right.enum'
8export * from './user-role' 8export * from './user-role'
9export * from './user-video-quota.model'
diff --git a/shared/models/users/user-video-quota.model.ts b/shared/models/users/user-video-quota.model.ts
new file mode 100644
index 000000000..b856fd9fc
--- /dev/null
+++ b/shared/models/users/user-video-quota.model.ts
@@ -0,0 +1,3 @@
1export interface UserVideoQuota {
2 videoQuotaUsed: number
3}