aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils
diff options
context:
space:
mode:
Diffstat (limited to 'shared/extra-utils')
-rw-r--r--shared/extra-utils/moderation/abuses.ts86
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
57function getAbusesList (options: { 57function 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
120function 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
120function updateAbuse ( 162function 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
191function 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
202function 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
213function 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
151export { 227export {
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}