import { VideoDetails } from './video-details.model'
import { VideoEdit } from './video-edit.model'
import { Video } from './video.model'
+import { objectToFormData } from '@app/shared/misc/utils'
@Injectable()
export class VideoService {
private restService: RestService
) {}
+ getVideoViewUrl (uuid: string) {
+ return VideoService.BASE_VIDEO_URL + uuid + '/views'
+ }
+
getVideo (uuid: string): Observable<VideoDetails> {
return this.authHttp.get<VideoDetailsServerModel>(VideoService.BASE_VIDEO_URL + uuid)
.map(videoHash => new VideoDetails(videoHash))
}
viewVideo (uuid: string): Observable<VideoDetails> {
- return this.authHttp.post(VideoService.BASE_VIDEO_URL + uuid + '/views', {})
+ return this.authHttp.post(this.getVideoViewUrl(uuid), {})
.map(this.restExtractor.extractDataBool)
.catch(this.restExtractor.handleError)
}
description,
privacy: video.privacy,
tags: video.tags,
- nsfw: video.nsfw
+ nsfw: video.nsfw,
+ commentsEnabled: video.commentsEnabled,
+ support: video.support,
+ thumbnailfile: video.thumbnailfile,
+ previewfile: video.previewfile
}
- return this.authHttp.put(VideoService.BASE_VIDEO_URL + video.id, body)
+ const data = objectToFormData(body)
+
+ return this.authHttp.put(VideoService.BASE_VIDEO_URL + video.id, data)
.map(this.restExtractor.extractDataBool)
.catch(this.restExtractor.handleError)
}
return this.setVideoRate(id, 'dislike')
}
+ unsetVideoLike (id: number) {
+ return this.setVideoRate(id, 'none')
+ }
+
getUserVideoRating (id: number): Observable<UserVideoRate> {
const url = UserService.BASE_USERS_URL + 'me/videos/' + id + '/rating'