]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/videos/+video-watch/comment/video-comment.service.ts
Fix transcoding
[github/Chocobozzz/PeerTube.git] / client / src / app / videos / +video-watch / comment / video-comment.service.ts
index 73526cb3e757414f4ffca33bd114299174a042a5..7d9c2d0ad87724978cc21ed6c86d8d1de697d5d0 100644 (file)
@@ -3,7 +3,7 @@ import { HttpClient, HttpParams } from '@angular/common/http'
 import { Injectable } from '@angular/core'
 import { lineFeedToHtml } from '@app/shared/misc/utils'
 import { Observable } from 'rxjs'
-import { ResultList } from '../../../../../../shared/models'
+import { ResultList, FeedFormat } from '../../../../../../shared/models'
 import {
   VideoComment as VideoCommentServerModel,
   VideoCommentCreate,
@@ -18,6 +18,7 @@ import { VideoComment } from './video-comment.model'
 @Injectable()
 export class VideoCommentService {
   private static BASE_VIDEO_URL = environment.apiUrl + '/api/v1/videos/'
+  private static BASE_FEEDS_URL = environment.apiUrl + '/feeds/video-comments.'
 
   constructor (
     private authHttp: HttpClient,
@@ -31,7 +32,7 @@ export class VideoCommentService {
 
     return this.authHttp.post(url, normalizedComment)
                .pipe(
-                  map(data => this.extractVideoComment(data['comment'])),
+                  map((data: any) => this.extractVideoComment(data['comment'])),
                   catchError(err => this.restExtractor.handleError(err))
                )
   }
@@ -42,7 +43,7 @@ export class VideoCommentService {
 
     return this.authHttp.post(url, normalizedComment)
                .pipe(
-                 map(data => this.extractVideoComment(data[ 'comment' ])),
+                 map((data: any) => this.extractVideoComment(data[ 'comment' ])),
                  catchError(err => this.restExtractor.handleError(err))
                )
   }
@@ -88,6 +89,34 @@ export class VideoCommentService {
                )
   }
 
+  getVideoCommentsFeeds (videoUUID?: string) {
+    const feeds = [
+      {
+        format: FeedFormat.RSS,
+        label: 'rss 2.0',
+        url: VideoCommentService.BASE_FEEDS_URL + FeedFormat.RSS.toLowerCase()
+      },
+      {
+        format: FeedFormat.ATOM,
+        label: 'atom 1.0',
+        url: VideoCommentService.BASE_FEEDS_URL + FeedFormat.ATOM.toLowerCase()
+      },
+      {
+        format: FeedFormat.JSON,
+        label: 'json 1.0',
+        url: VideoCommentService.BASE_FEEDS_URL + FeedFormat.JSON.toLowerCase()
+      }
+    ]
+
+    if (videoUUID !== undefined) {
+      for (const feed of feeds) {
+        feed.url += '?videoId=' + videoUUID
+      }
+    }
+
+    return feeds
+  }
+
   private extractVideoComment (videoComment: VideoCommentServerModel) {
     return new VideoComment(videoComment)
   }