diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/models/account/account-blocklist.ts | 14 | ||||
-rw-r--r-- | server/tests/api/moderation/blocklist.ts | 28 |
2 files changed, 42 insertions, 0 deletions
diff --git a/server/models/account/account-blocklist.ts b/server/models/account/account-blocklist.ts index a7b8db076..377249b38 100644 --- a/server/models/account/account-blocklist.ts +++ b/server/models/account/account-blocklist.ts | |||
@@ -132,6 +132,20 @@ export class AccountBlocklistModel extends Model<Partial<AttributesOnly<AccountB | |||
132 | as: 'BlockedAccount' | 132 | as: 'BlockedAccount' |
133 | } | 133 | } |
134 | ] | 134 | ] |
135 | } else if (search) { // We need some joins when counting with search | ||
136 | query.include = [ | ||
137 | { | ||
138 | model: AccountModel.unscoped(), | ||
139 | required: true, | ||
140 | as: 'BlockedAccount', | ||
141 | include: [ | ||
142 | { | ||
143 | model: ActorModel.unscoped(), | ||
144 | required: true | ||
145 | } | ||
146 | ] | ||
147 | } | ||
148 | ] | ||
135 | } | 149 | } |
136 | 150 | ||
137 | return query | 151 | return query |
diff --git a/server/tests/api/moderation/blocklist.ts b/server/tests/api/moderation/blocklist.ts index e1344a245..a5a92317d 100644 --- a/server/tests/api/moderation/blocklist.ts +++ b/server/tests/api/moderation/blocklist.ts | |||
@@ -256,6 +256,13 @@ describe('Test blocklist', function () { | |||
256 | } | 256 | } |
257 | }) | 257 | }) |
258 | 258 | ||
259 | it('Should search blocked accounts', async function () { | ||
260 | const body = await command.listMyAccountBlocklist({ start: 0, count: 10, search: 'user2' }) | ||
261 | expect(body.total).to.equal(1) | ||
262 | |||
263 | expect(body.data[0].blockedAccount.name).to.equal('user2') | ||
264 | }) | ||
265 | |||
259 | it('Should get blocked status', async function () { | 266 | it('Should get blocked status', async function () { |
260 | const remoteHandle = 'user2@' + servers[1].host | 267 | const remoteHandle = 'user2@' + servers[1].host |
261 | const localHandle = 'user1@' + servers[0].host | 268 | const localHandle = 'user1@' + servers[0].host |
@@ -475,6 +482,13 @@ describe('Test blocklist', function () { | |||
475 | expect(block.blockedServer.host).to.equal('localhost:' + servers[1].port) | 482 | expect(block.blockedServer.host).to.equal('localhost:' + servers[1].port) |
476 | }) | 483 | }) |
477 | 484 | ||
485 | it('Should search blocked servers', async function () { | ||
486 | const body = await command.listMyServerBlocklist({ start: 0, count: 10, search: servers[1].host }) | ||
487 | expect(body.total).to.equal(1) | ||
488 | |||
489 | expect(body.data[0].blockedServer.host).to.equal(servers[1].host) | ||
490 | }) | ||
491 | |||
478 | it('Should get blocklist status', async function () { | 492 | it('Should get blocklist status', async function () { |
479 | const blockedServer = servers[1].host | 493 | const blockedServer = servers[1].host |
480 | const notBlockedServer = 'example.com' | 494 | const notBlockedServer = 'example.com' |
@@ -645,6 +659,13 @@ describe('Test blocklist', function () { | |||
645 | } | 659 | } |
646 | }) | 660 | }) |
647 | 661 | ||
662 | it('Should search blocked accounts', async function () { | ||
663 | const body = await command.listServerAccountBlocklist({ start: 0, count: 10, search: 'user2' }) | ||
664 | expect(body.total).to.equal(1) | ||
665 | |||
666 | expect(body.data[0].blockedAccount.name).to.equal('user2') | ||
667 | }) | ||
668 | |||
648 | it('Should get blocked status', async function () { | 669 | it('Should get blocked status', async function () { |
649 | const remoteHandle = 'user2@' + servers[1].host | 670 | const remoteHandle = 'user2@' + servers[1].host |
650 | const localHandle = 'user1@' + servers[0].host | 671 | const localHandle = 'user1@' + servers[0].host |
@@ -805,6 +826,13 @@ describe('Test blocklist', function () { | |||
805 | expect(block.blockedServer.host).to.equal('localhost:' + servers[1].port) | 826 | expect(block.blockedServer.host).to.equal('localhost:' + servers[1].port) |
806 | }) | 827 | }) |
807 | 828 | ||
829 | it('Should search blocked servers', async function () { | ||
830 | const body = await command.listServerServerBlocklist({ start: 0, count: 10, search: servers[1].host }) | ||
831 | expect(body.total).to.equal(1) | ||
832 | |||
833 | expect(body.data[0].blockedServer.host).to.equal(servers[1].host) | ||
834 | }) | ||
835 | |||
808 | it('Should get blocklist status', async function () { | 836 | it('Should get blocklist status', async function () { |
809 | const blockedServer = servers[1].host | 837 | const blockedServer = servers[1].host |
810 | const notBlockedServer = 'example.com' | 838 | const notBlockedServer = 'example.com' |