aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/shared-instance
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/shared/shared-instance')
-rw-r--r--client/src/app/shared/shared-instance/instance-follow.service.ts69
1 files changed, 51 insertions, 18 deletions
diff --git a/client/src/app/shared/shared-instance/instance-follow.service.ts b/client/src/app/shared/shared-instance/instance-follow.service.ts
index 06484d938..5366fd068 100644
--- a/client/src/app/shared/shared-instance/instance-follow.service.ts
+++ b/client/src/app/shared/shared-instance/instance-follow.service.ts
@@ -1,9 +1,10 @@
1import { SortMeta } from 'primeng/api' 1import { SortMeta } from 'primeng/api'
2import { Observable } from 'rxjs' 2import { from, Observable } from 'rxjs'
3import { catchError, map } from 'rxjs/operators' 3import { catchError, concatMap, map, toArray } from 'rxjs/operators'
4import { HttpClient, HttpParams } from '@angular/common/http' 4import { HttpClient, HttpParams } from '@angular/common/http'
5import { Injectable } from '@angular/core' 5import { Injectable } from '@angular/core'
6import { RestExtractor, RestPagination, RestService } from '@app/core' 6import { RestExtractor, RestPagination, RestService } from '@app/core'
7import { arrayify } from '@shared/core-utils'
7import { ActivityPubActorType, ActorFollow, FollowState, ResultList, ServerFollowCreate } from '@shared/models' 8import { ActivityPubActorType, ActorFollow, FollowState, ResultList, ServerFollowCreate } from '@shared/models'
8import { environment } from '../../../environments/environment' 9import { environment } from '../../../environments/environment'
9import { AdvancedInputFilter } from '../shared-forms' 10import { AdvancedInputFilter } from '../shared-forms'
@@ -81,32 +82,64 @@ export class InstanceFollowService {
81 .pipe(catchError(res => this.restExtractor.handleError(res))) 82 .pipe(catchError(res => this.restExtractor.handleError(res)))
82 } 83 }
83 84
84 unfollow (follow: ActorFollow) { 85 unfollow (followsArg: ActorFollow[] | ActorFollow) {
85 const handle = follow.following.name + '@' + follow.following.host 86 const follows = arrayify(followsArg)
86 87
87 return this.authHttp.delete(InstanceFollowService.BASE_APPLICATION_URL + '/following/' + handle) 88 return from(follows)
88 .pipe(catchError(res => this.restExtractor.handleError(res))) 89 .pipe(
90 concatMap(follow => {
91 const handle = follow.following.name + '@' + follow.following.host
92
93 return this.authHttp.delete(InstanceFollowService.BASE_APPLICATION_URL + '/following/' + handle)
94 }),
95 toArray(),
96 catchError(err => this.restExtractor.handleError(err))
97 )
89 } 98 }
90 99
91 acceptFollower (follow: ActorFollow) { 100 acceptFollower (followsArg: ActorFollow[] | ActorFollow) {
92 const handle = follow.follower.name + '@' + follow.follower.host 101 const follows = arrayify(followsArg)
93 102
94 return this.authHttp.post(`${InstanceFollowService.BASE_APPLICATION_URL}/followers/${handle}/accept`, {}) 103 return from(follows)
95 .pipe(catchError(res => this.restExtractor.handleError(res))) 104 .pipe(
105 concatMap(follow => {
106 const handle = follow.follower.name + '@' + follow.follower.host
107
108 return this.authHttp.post(`${InstanceFollowService.BASE_APPLICATION_URL}/followers/${handle}/accept`, {})
109 }),
110 toArray(),
111 catchError(err => this.restExtractor.handleError(err))
112 )
96 } 113 }
97 114
98 rejectFollower (follow: ActorFollow) { 115 rejectFollower (followsArg: ActorFollow[] | ActorFollow) {
99 const handle = follow.follower.name + '@' + follow.follower.host 116 const follows = arrayify(followsArg)
100 117
101 return this.authHttp.post(`${InstanceFollowService.BASE_APPLICATION_URL}/followers/${handle}/reject`, {}) 118 return from(follows)
102 .pipe(catchError(res => this.restExtractor.handleError(res))) 119 .pipe(
120 concatMap(follow => {
121 const handle = follow.follower.name + '@' + follow.follower.host
122
123 return this.authHttp.post(`${InstanceFollowService.BASE_APPLICATION_URL}/followers/${handle}/reject`, {})
124 }),
125 toArray(),
126 catchError(err => this.restExtractor.handleError(err))
127 )
103 } 128 }
104 129
105 removeFollower (follow: ActorFollow) { 130 removeFollower (followsArg: ActorFollow[] | ActorFollow) {
106 const handle = follow.follower.name + '@' + follow.follower.host 131 const follows = arrayify(followsArg)
107 132
108 return this.authHttp.delete(`${InstanceFollowService.BASE_APPLICATION_URL}/followers/${handle}`) 133 return from(follows)
109 .pipe(catchError(res => this.restExtractor.handleError(res))) 134 .pipe(
135 concatMap(follow => {
136 const handle = follow.follower.name + '@' + follow.follower.host
137
138 return this.authHttp.delete(`${InstanceFollowService.BASE_APPLICATION_URL}/followers/${handle}`)
139 }),
140 toArray(),
141 catchError(err => this.restExtractor.handleError(err))
142 )
110 } 143 }
111 144
112 buildFollowsListFilters (): AdvancedInputFilter[] { 145 buildFollowsListFilters (): AdvancedInputFilter[] {