aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2020-04-14 10:55:34 +0200
committerRigel Kent <par@rigelk.eu>2020-04-14 15:53:37 +0200
commitbb152476c819e4c7487d080433c616f0d523e049 (patch)
tree955b6afa140b6e83eced3cb21c8ec1d62fa6a15e /server
parent1055eb3a7b89bc50dc611ab933f9dbd603488747 (diff)
downloadPeerTube-bb152476c819e4c7487d080433c616f0d523e049.tar.gz
PeerTube-bb152476c819e4c7487d080433c616f0d523e049.tar.zst
PeerTube-bb152476c819e4c7487d080433c616f0d523e049.zip
Refactor follow/mute as modals in admin, add actions in abuse list
Diffstat (limited to 'server')
-rw-r--r--server/middlewares/validators/blocklist.ts6
-rw-r--r--server/tests/api/check-params/blocklist.ts12
2 files changed, 8 insertions, 10 deletions
diff --git a/server/middlewares/validators/blocklist.ts b/server/middlewares/validators/blocklist.ts
index 47a0b1a1c..b2183437c 100644
--- a/server/middlewares/validators/blocklist.ts
+++ b/server/middlewares/validators/blocklist.ts
@@ -84,11 +84,9 @@ const blockServerValidator = [
84 .end() 84 .end()
85 } 85 }
86 86
87 const server = await ServerModel.loadByHost(host) 87 let server = await ServerModel.loadByHost(host)
88 if (!server) { 88 if (!server) {
89 return res.status(404) 89 server = await ServerModel.create({ host })
90 .send({ error: 'Server host not found.' })
91 .end()
92 } 90 }
93 91
94 res.locals.server = server 92 res.locals.server = server
diff --git a/server/tests/api/check-params/blocklist.ts b/server/tests/api/check-params/blocklist.ts
index fb459f756..1219ec9bd 100644
--- a/server/tests/api/check-params/blocklist.ts
+++ b/server/tests/api/check-params/blocklist.ts
@@ -175,13 +175,13 @@ describe('Test blocklist API validators', function () {
175 }) 175 })
176 }) 176 })
177 177
178 it('Should fail with an unknown server', async function () { 178 it('Should succeed with an unknown server', async function () {
179 await makePostBodyRequest({ 179 await makePostBodyRequest({
180 url: server.url, 180 url: server.url,
181 token: server.accessToken, 181 token: server.accessToken,
182 path, 182 path,
183 fields: { host: 'localhost:9003' }, 183 fields: { host: 'localhost:9003' },
184 statusCodeExpected: 404 184 statusCodeExpected: 204
185 }) 185 })
186 }) 186 })
187 187
@@ -218,7 +218,7 @@ describe('Test blocklist API validators', function () {
218 it('Should fail with an unknown server block', async function () { 218 it('Should fail with an unknown server block', async function () {
219 await makeDeleteRequest({ 219 await makeDeleteRequest({
220 url: server.url, 220 url: server.url,
221 path: path + '/localhost:9003', 221 path: path + '/localhost:9004',
222 token: server.accessToken, 222 token: server.accessToken,
223 statusCodeExpected: 404 223 statusCodeExpected: 404
224 }) 224 })
@@ -415,13 +415,13 @@ describe('Test blocklist API validators', function () {
415 }) 415 })
416 }) 416 })
417 417
418 it('Should fail with an unknown server', async function () { 418 it('Should succeed with an unknown server', async function () {
419 await makePostBodyRequest({ 419 await makePostBodyRequest({
420 url: server.url, 420 url: server.url,
421 token: server.accessToken, 421 token: server.accessToken,
422 path, 422 path,
423 fields: { host: 'localhost:9003' }, 423 fields: { host: 'localhost:9003' },
424 statusCodeExpected: 404 424 statusCodeExpected: 204
425 }) 425 })
426 }) 426 })
427 427
@@ -467,7 +467,7 @@ describe('Test blocklist API validators', function () {
467 it('Should fail with an unknown server block', async function () { 467 it('Should fail with an unknown server block', async function () {
468 await makeDeleteRequest({ 468 await makeDeleteRequest({
469 url: server.url, 469 url: server.url,
470 path: path + '/localhost:9003', 470 path: path + '/localhost:9004',
471 token: server.accessToken, 471 token: server.accessToken,
472 statusCodeExpected: 404 472 statusCodeExpected: 404
473 }) 473 })