aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/shared-user-subscription
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/shared/shared-user-subscription')
-rw-r--r--client/src/app/shared/shared-user-subscription/user-subscription.service.ts41
1 files changed, 38 insertions, 3 deletions
diff --git a/client/src/app/shared/shared-user-subscription/user-subscription.service.ts b/client/src/app/shared/shared-user-subscription/user-subscription.service.ts
index f289fb6cf..ede65ff39 100644
--- a/client/src/app/shared/shared-user-subscription/user-subscription.service.ts
+++ b/client/src/app/shared/shared-user-subscription/user-subscription.service.ts
@@ -6,7 +6,7 @@ import { Injectable } from '@angular/core'
6import { ComponentPaginationLight, RestExtractor, RestService } from '@app/core' 6import { ComponentPaginationLight, RestExtractor, RestService } from '@app/core'
7import { buildBulkObservable } from '@app/helpers' 7import { buildBulkObservable } from '@app/helpers'
8import { Video, VideoChannel, VideoChannelService, VideoService } from '@app/shared/shared-main' 8import { Video, VideoChannel, VideoChannelService, VideoService } from '@app/shared/shared-main'
9import { ResultList, VideoChannel as VideoChannelServer, VideoSortField } from '@shared/models' 9import { ActorFollow, ResultList, VideoChannel as VideoChannelServer, VideoSortField } from '@shared/models'
10import { environment } from '../../../environments/environment' 10import { environment } from '../../../environments/environment'
11 11
12const logger = debug('peertube:subscriptions:UserSubscriptionService') 12const logger = debug('peertube:subscriptions:UserSubscriptionService')
@@ -17,6 +17,8 @@ type SubscriptionExistResultObservable = { [ uri: string ]: Observable<boolean>
17@Injectable() 17@Injectable()
18export class UserSubscriptionService { 18export class UserSubscriptionService {
19 static BASE_USER_SUBSCRIPTIONS_URL = environment.apiUrl + '/api/v1/users/me/subscriptions' 19 static BASE_USER_SUBSCRIPTIONS_URL = environment.apiUrl + '/api/v1/users/me/subscriptions'
20 static BASE_VIDEO_CHANNELS_URL = environment.apiUrl + '/api/v1/video-channels'
21 static BASE_ACCOUNTS_URL = environment.apiUrl + '/api/v1/accounts'
20 22
21 // Use a replay subject because we "next" a value before subscribing 23 // Use a replay subject because we "next" a value before subscribing
22 private existsSubject = new ReplaySubject<string>(1) 24 private existsSubject = new ReplaySubject<string>(1)
@@ -43,13 +45,46 @@ export class UserSubscriptionService {
43 ) 45 )
44 } 46 }
45 47
48 listFollowers (parameters: {
49 pagination: ComponentPaginationLight
50 nameWithHost: string
51 search?: string
52 }) {
53 const { pagination, nameWithHost, search } = parameters
54
55 let url = `${UserSubscriptionService.BASE_ACCOUNTS_URL}/${nameWithHost}/followers`
56
57 let params = new HttpParams()
58 params = this.restService.addRestGetParams(params, this.restService.componentToRestPagination(pagination), '-createdAt')
59
60 if (search) {
61 const filters = this.restService.parseQueryStringFilter(search, {
62 channel: {
63 prefix: 'channel:'
64 }
65 })
66
67 if (filters.channel) {
68 url = `${UserSubscriptionService.BASE_VIDEO_CHANNELS_URL}/${filters.channel}/followers`
69 }
70
71 params = this.restService.addObjectParams(params, { search: filters.search })
72 }
73
74 return this.authHttp
75 .get<ResultList<ActorFollow>>(url, { params })
76 .pipe(
77 catchError(err => this.restExtractor.handleError(err))
78 )
79 }
80
46 getUserSubscriptionVideos (parameters: { 81 getUserSubscriptionVideos (parameters: {
47 videoPagination: ComponentPaginationLight 82 videoPagination: ComponentPaginationLight
48 sort: VideoSortField 83 sort: VideoSortField
49 skipCount?: boolean 84 skipCount?: boolean
50 }): Observable<ResultList<Video>> { 85 }): Observable<ResultList<Video>> {
51 const { videoPagination, sort, skipCount } = parameters 86 const { videoPagination, sort, skipCount } = parameters
52 const pagination = this.restService.componentPaginationToRestPagination(videoPagination) 87 const pagination = this.restService.componentToRestPagination(videoPagination)
53 88
54 let params = new HttpParams() 89 let params = new HttpParams()
55 params = this.restService.addRestGetParams(params, pagination, sort) 90 params = this.restService.addRestGetParams(params, pagination, sort)
@@ -106,7 +141,7 @@ export class UserSubscriptionService {
106 const { pagination, search } = parameters 141 const { pagination, search } = parameters
107 const url = UserSubscriptionService.BASE_USER_SUBSCRIPTIONS_URL 142 const url = UserSubscriptionService.BASE_USER_SUBSCRIPTIONS_URL
108 143
109 const restPagination = this.restService.componentPaginationToRestPagination(pagination) 144 const restPagination = this.restService.componentToRestPagination(pagination)
110 145
111 let params = new HttpParams() 146 let params = new HttpParams()
112 params = this.restService.addRestGetParams(params, restPagination) 147 params = this.restService.addRestGetParams(params, restPagination)