diff options
author | Chocobozzz <me@florianbigard.com> | 2020-07-24 15:05:51 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-07-31 11:35:19 +0200 |
commit | edbc9325462ddf4536775871ebc25e06f46612d1 (patch) | |
tree | 9671dd51303e75d48d4f4f9a1df7a1960e33780d /shared/extra-utils/moderation/abuses.ts | |
parent | 20516920d2b72c8a18bc24b9740f7176aa962da2 (diff) | |
download | PeerTube-edbc9325462ddf4536775871ebc25e06f46612d1.tar.gz PeerTube-edbc9325462ddf4536775871ebc25e06f46612d1.tar.zst PeerTube-edbc9325462ddf4536775871ebc25e06f46612d1.zip |
Add server API to abuse messages
Diffstat (limited to 'shared/extra-utils/moderation/abuses.ts')
-rw-r--r-- | shared/extra-utils/moderation/abuses.ts | 86 |
1 files changed, 83 insertions, 3 deletions
diff --git a/shared/extra-utils/moderation/abuses.ts b/shared/extra-utils/moderation/abuses.ts index 62af9556e..7db75cebb 100644 --- a/shared/extra-utils/moderation/abuses.ts +++ b/shared/extra-utils/moderation/abuses.ts | |||
@@ -54,7 +54,7 @@ function reportAbuse (options: { | |||
54 | }) | 54 | }) |
55 | } | 55 | } |
56 | 56 | ||
57 | function getAbusesList (options: { | 57 | function getAdminAbusesList (options: { |
58 | url: string | 58 | url: string |
59 | token: string | 59 | token: string |
60 | 60 | ||
@@ -117,6 +117,48 @@ function getAbusesList (options: { | |||
117 | }) | 117 | }) |
118 | } | 118 | } |
119 | 119 | ||
120 | function getUserAbusesList (options: { | ||
121 | url: string | ||
122 | token: string | ||
123 | |||
124 | start?: number | ||
125 | count?: number | ||
126 | sort?: string | ||
127 | |||
128 | id?: number | ||
129 | search?: string | ||
130 | state?: AbuseState | ||
131 | }) { | ||
132 | const { | ||
133 | url, | ||
134 | token, | ||
135 | start, | ||
136 | count, | ||
137 | sort, | ||
138 | id, | ||
139 | search, | ||
140 | state | ||
141 | } = options | ||
142 | const path = '/api/v1/users/me/abuses' | ||
143 | |||
144 | const query = { | ||
145 | id, | ||
146 | search, | ||
147 | state, | ||
148 | start, | ||
149 | count, | ||
150 | sort: sort || 'createdAt' | ||
151 | } | ||
152 | |||
153 | return makeGetRequest({ | ||
154 | url, | ||
155 | path, | ||
156 | token, | ||
157 | query, | ||
158 | statusCodeExpected: 200 | ||
159 | }) | ||
160 | } | ||
161 | |||
120 | function updateAbuse ( | 162 | function updateAbuse ( |
121 | url: string, | 163 | url: string, |
122 | token: string, | 164 | token: string, |
@@ -146,11 +188,49 @@ function deleteAbuse (url: string, token: string, abuseId: number, statusCodeExp | |||
146 | }) | 188 | }) |
147 | } | 189 | } |
148 | 190 | ||
191 | function listAbuseMessages (url: string, token: string, abuseId: number, statusCodeExpected = 200) { | ||
192 | const path = '/api/v1/abuses/' + abuseId + '/messages' | ||
193 | |||
194 | return makeGetRequest({ | ||
195 | url, | ||
196 | token, | ||
197 | path, | ||
198 | statusCodeExpected | ||
199 | }) | ||
200 | } | ||
201 | |||
202 | function deleteAbuseMessage (url: string, token: string, abuseId: number, messageId: number, statusCodeExpected = 204) { | ||
203 | const path = '/api/v1/abuses/' + abuseId + '/messages/' + messageId | ||
204 | |||
205 | return makeDeleteRequest({ | ||
206 | url, | ||
207 | token, | ||
208 | path, | ||
209 | statusCodeExpected | ||
210 | }) | ||
211 | } | ||
212 | |||
213 | function addAbuseMessage (url: string, token: string, abuseId: number, message: string, statusCodeExpected = 200) { | ||
214 | const path = '/api/v1/abuses/' + abuseId + '/messages' | ||
215 | |||
216 | return makePostBodyRequest({ | ||
217 | url, | ||
218 | token, | ||
219 | path, | ||
220 | fields: { message }, | ||
221 | statusCodeExpected | ||
222 | }) | ||
223 | } | ||
224 | |||
149 | // --------------------------------------------------------------------------- | 225 | // --------------------------------------------------------------------------- |
150 | 226 | ||
151 | export { | 227 | export { |
152 | reportAbuse, | 228 | reportAbuse, |
153 | getAbusesList, | 229 | getAdminAbusesList, |
154 | updateAbuse, | 230 | updateAbuse, |
155 | deleteAbuse | 231 | deleteAbuse, |
232 | getUserAbusesList, | ||
233 | listAbuseMessages, | ||
234 | deleteAbuseMessage, | ||
235 | addAbuseMessage | ||
156 | } | 236 | } |