diff options
Diffstat (limited to 'client/src/app/shared')
5 files changed, 61 insertions, 24 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 @@ | |||
1 | import { SortMeta } from 'primeng/api' | 1 | import { SortMeta } from 'primeng/api' |
2 | import { Observable } from 'rxjs' | 2 | import { from, Observable } from 'rxjs' |
3 | import { catchError, map } from 'rxjs/operators' | 3 | import { catchError, concatMap, map, toArray } from 'rxjs/operators' |
4 | import { HttpClient, HttpParams } from '@angular/common/http' | 4 | import { HttpClient, HttpParams } from '@angular/common/http' |
5 | import { Injectable } from '@angular/core' | 5 | import { Injectable } from '@angular/core' |
6 | import { RestExtractor, RestPagination, RestService } from '@app/core' | 6 | import { RestExtractor, RestPagination, RestService } from '@app/core' |
7 | import { arrayify } from '@shared/core-utils' | ||
7 | import { ActivityPubActorType, ActorFollow, FollowState, ResultList, ServerFollowCreate } from '@shared/models' | 8 | import { ActivityPubActorType, ActorFollow, FollowState, ResultList, ServerFollowCreate } from '@shared/models' |
8 | import { environment } from '../../../environments/environment' | 9 | import { environment } from '../../../environments/environment' |
9 | import { AdvancedInputFilter } from '../shared-forms' | 10 | import { 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[] { |
diff --git a/client/src/app/shared/shared-main/video/video.service.ts b/client/src/app/shared/shared-main/video/video.service.ts index 4fbc4f7f6..f2bf02695 100644 --- a/client/src/app/shared/shared-main/video/video.service.ts +++ b/client/src/app/shared/shared-main/video/video.service.ts | |||
@@ -5,6 +5,7 @@ import { HttpClient, HttpParams, HttpRequest } from '@angular/common/http' | |||
5 | import { Injectable } from '@angular/core' | 5 | import { Injectable } from '@angular/core' |
6 | import { AuthService, ComponentPaginationLight, RestExtractor, RestService, ServerService, UserService } from '@app/core' | 6 | import { AuthService, ComponentPaginationLight, RestExtractor, RestService, ServerService, UserService } from '@app/core' |
7 | import { objectToFormData } from '@app/helpers' | 7 | import { objectToFormData } from '@app/helpers' |
8 | import { arrayify } from '@shared/core-utils' | ||
8 | import { | 9 | import { |
9 | BooleanBothQuery, | 10 | BooleanBothQuery, |
10 | FeedFormat, | 11 | FeedFormat, |
@@ -285,7 +286,7 @@ export class VideoService { | |||
285 | } | 286 | } |
286 | 287 | ||
287 | removeVideo (idArg: number | number[]) { | 288 | removeVideo (idArg: number | number[]) { |
288 | const ids = Array.isArray(idArg) ? idArg : [ idArg ] | 289 | const ids = arrayify(idArg) |
289 | 290 | ||
290 | return from(ids) | 291 | return from(ids) |
291 | .pipe( | 292 | .pipe( |
diff --git a/client/src/app/shared/shared-moderation/blocklist.service.ts b/client/src/app/shared/shared-moderation/blocklist.service.ts index 3e92c2831..1169bf757 100644 --- a/client/src/app/shared/shared-moderation/blocklist.service.ts +++ b/client/src/app/shared/shared-moderation/blocklist.service.ts | |||
@@ -4,6 +4,7 @@ import { catchError, concatMap, map, toArray } from 'rxjs/operators' | |||
4 | import { HttpClient, HttpParams } from '@angular/common/http' | 4 | import { HttpClient, HttpParams } from '@angular/common/http' |
5 | import { Injectable } from '@angular/core' | 5 | import { Injectable } from '@angular/core' |
6 | import { RestExtractor, RestPagination, RestService } from '@app/core' | 6 | import { RestExtractor, RestPagination, RestService } from '@app/core' |
7 | import { arrayify } from '@shared/core-utils' | ||
7 | import { AccountBlock as AccountBlockServer, BlockStatus, ResultList, ServerBlock } from '@shared/models' | 8 | import { AccountBlock as AccountBlockServer, BlockStatus, ResultList, ServerBlock } from '@shared/models' |
8 | import { environment } from '../../../environments/environment' | 9 | import { environment } from '../../../environments/environment' |
9 | import { Account } from '../shared-main' | 10 | import { Account } from '../shared-main' |
@@ -122,7 +123,7 @@ export class BlocklistService { | |||
122 | } | 123 | } |
123 | 124 | ||
124 | blockAccountByInstance (accountsArg: Pick<Account, 'nameWithHost'> | Pick<Account, 'nameWithHost'>[]) { | 125 | blockAccountByInstance (accountsArg: Pick<Account, 'nameWithHost'> | Pick<Account, 'nameWithHost'>[]) { |
125 | const accounts = Array.isArray(accountsArg) ? accountsArg : [ accountsArg ] | 126 | const accounts = arrayify(accountsArg) |
126 | 127 | ||
127 | return from(accounts) | 128 | return from(accounts) |
128 | .pipe( | 129 | .pipe( |
diff --git a/client/src/app/shared/shared-moderation/video-block.service.ts b/client/src/app/shared/shared-moderation/video-block.service.ts index 5dfb0d7d4..6272b672f 100644 --- a/client/src/app/shared/shared-moderation/video-block.service.ts +++ b/client/src/app/shared/shared-moderation/video-block.service.ts | |||
@@ -4,6 +4,7 @@ import { catchError, concatMap, map, toArray } from 'rxjs/operators' | |||
4 | import { HttpClient, HttpParams } from '@angular/common/http' | 4 | import { HttpClient, HttpParams } from '@angular/common/http' |
5 | import { Injectable } from '@angular/core' | 5 | import { Injectable } from '@angular/core' |
6 | import { RestExtractor, RestPagination, RestService } from '@app/core' | 6 | import { RestExtractor, RestPagination, RestService } from '@app/core' |
7 | import { arrayify } from '@shared/core-utils' | ||
7 | import { ResultList, VideoBlacklist, VideoBlacklistType } from '@shared/models' | 8 | import { ResultList, VideoBlacklist, VideoBlacklistType } from '@shared/models' |
8 | import { environment } from '../../../environments/environment' | 9 | import { environment } from '../../../environments/environment' |
9 | 10 | ||
@@ -53,7 +54,7 @@ export class VideoBlockService { | |||
53 | } | 54 | } |
54 | 55 | ||
55 | unblockVideo (videoIdArgs: number | number[]) { | 56 | unblockVideo (videoIdArgs: number | number[]) { |
56 | const videoIds = Array.isArray(videoIdArgs) ? videoIdArgs : [ videoIdArgs ] | 57 | const videoIds = arrayify(videoIdArgs) |
57 | 58 | ||
58 | return observableFrom(videoIds) | 59 | return observableFrom(videoIds) |
59 | .pipe( | 60 | .pipe( |
diff --git a/client/src/app/shared/shared-users/user-admin.service.ts b/client/src/app/shared/shared-users/user-admin.service.ts index 3db271c4a..422221d62 100644 --- a/client/src/app/shared/shared-users/user-admin.service.ts +++ b/client/src/app/shared/shared-users/user-admin.service.ts | |||
@@ -5,6 +5,7 @@ import { HttpClient, HttpParams } from '@angular/common/http' | |||
5 | import { Injectable } from '@angular/core' | 5 | import { Injectable } from '@angular/core' |
6 | import { RestExtractor, RestPagination, RestService, UserService } from '@app/core' | 6 | import { RestExtractor, RestPagination, RestService, UserService } from '@app/core' |
7 | import { getBytes } from '@root-helpers/bytes' | 7 | import { getBytes } from '@root-helpers/bytes' |
8 | import { arrayify } from '@shared/core-utils' | ||
8 | import { ResultList, User as UserServerModel, UserCreate, UserRole, UserUpdate } from '@shared/models' | 9 | import { ResultList, User as UserServerModel, UserCreate, UserRole, UserUpdate } from '@shared/models' |
9 | 10 | ||
10 | @Injectable() | 11 | @Injectable() |
@@ -65,7 +66,7 @@ export class UserAdminService { | |||
65 | } | 66 | } |
66 | 67 | ||
67 | removeUser (usersArg: UserServerModel | UserServerModel[]) { | 68 | removeUser (usersArg: UserServerModel | UserServerModel[]) { |
68 | const users = Array.isArray(usersArg) ? usersArg : [ usersArg ] | 69 | const users = arrayify(usersArg) |
69 | 70 | ||
70 | return from(users) | 71 | return from(users) |
71 | .pipe( | 72 | .pipe( |
@@ -77,7 +78,7 @@ export class UserAdminService { | |||
77 | 78 | ||
78 | banUsers (usersArg: UserServerModel | UserServerModel[], reason?: string) { | 79 | banUsers (usersArg: UserServerModel | UserServerModel[], reason?: string) { |
79 | const body = reason ? { reason } : {} | 80 | const body = reason ? { reason } : {} |
80 | const users = Array.isArray(usersArg) ? usersArg : [ usersArg ] | 81 | const users = arrayify(usersArg) |
81 | 82 | ||
82 | return from(users) | 83 | return from(users) |
83 | .pipe( | 84 | .pipe( |
@@ -88,7 +89,7 @@ export class UserAdminService { | |||
88 | } | 89 | } |
89 | 90 | ||
90 | unbanUsers (usersArg: UserServerModel | UserServerModel[]) { | 91 | unbanUsers (usersArg: UserServerModel | UserServerModel[]) { |
91 | const users = Array.isArray(usersArg) ? usersArg : [ usersArg ] | 92 | const users = arrayify(usersArg) |
92 | 93 | ||
93 | return from(users) | 94 | return from(users) |
94 | .pipe( | 95 | .pipe( |