diff --git a/api_tests/src/community.spec.ts b/api_tests/src/community.spec.ts index 36ddf2505..d75b711fc 100644 --- a/api_tests/src/community.spec.ts +++ b/api_tests/src/community.spec.ts @@ -25,17 +25,16 @@ import { getComments, createComment, getCommunityByName, - blockInstance, waitUntil, alphaUrl, delta, - betaAllowedInstances, searchPostLocal, longDelay, editCommunity, unfollows, - allowInstance, + userBlockInstance, } from "./shared"; +import { AdminAllowInstanceParams } from "lemmy-js-client/dist/types/AdminAllowInstanceParams"; import { EditCommunity, EditSite } from "lemmy-js-client"; beforeAll(setupLogins); @@ -364,7 +363,7 @@ test("User blocks instance, communities are hidden", async () => { expect(listing_ids).toContain(postRes.post_view.post.ap_id); // block the beta instance - await blockInstance(alpha, alphaPost.community.instance_id, true); + await userBlockInstance(alpha, alphaPost.community.instance_id, true); // after blocking, post should not be in listing let listing2 = await getPosts(alpha, "All"); @@ -372,7 +371,7 @@ test("User blocks instance, communities are hidden", async () => { expect(listing_ids2.indexOf(postRes.post_view.post.ap_id)).toBe(-1); // unblock instance again - await blockInstance(alpha, alphaPost.community.instance_id, false); + await userBlockInstance(alpha, alphaPost.community.instance_id, false); // post should be included in listing let listing3 = await getPosts(alpha, "All"); diff --git a/api_tests/src/post.spec.ts b/api_tests/src/post.spec.ts index 59e3d774e..2ee682599 100644 --- a/api_tests/src/post.spec.ts +++ b/api_tests/src/post.spec.ts @@ -40,6 +40,7 @@ import { createCommunity, } from "./shared"; import { PostView } from "lemmy-js-client/dist/types/PostView"; +import { AdminBlockInstanceParams} from "lemmy-js-client/dist/types/AdminBlockInstanceParams"; import { EditSite, ResolveObject } from "lemmy-js-client"; let betaCommunity: CommunityView | undefined; @@ -87,12 +88,13 @@ async function assertPostFederation( } test("Create a post", async () => { - // Setup some allowlists and blocklists - const editSiteForm: EditSite = {}; - - editSiteForm.allowed_instances = []; - editSiteForm.blocked_instances = ["lemmy-alpha"]; - await epsilon.editSite(editSiteForm); + // Block alpha + var block_instance_params: AdminBlockInstanceParams = { + instance: "lemmy-alpha", + block: true, + reason: undefined, + }; + await epsilon.adminBlockInstance(block_instance_params); if (!betaCommunity) { throw "Missing beta community"; @@ -132,11 +134,9 @@ test("Create a post", async () => { resolvePost(epsilon, postRes.post_view.post), ).rejects.toStrictEqual(Error("not_found")); - // remove added allow/blocklists - editSiteForm.allowed_instances = []; - editSiteForm.blocked_instances = []; - await delta.editSite(editSiteForm); - await epsilon.editSite(editSiteForm); + // remove blocked instance + block_instance_params.block= false; + await epsilon.adminBlockInstance(block_instance_params); }); test("Create a post in a non-existent community", async () => { diff --git a/api_tests/src/shared.ts b/api_tests/src/shared.ts index 1f9402095..4fee6af80 100644 --- a/api_tests/src/shared.ts +++ b/api_tests/src/shared.ts @@ -184,7 +184,6 @@ export async function setupLogins() { await allowInstance(gamma, "lemmy-delta"); await allowInstance(gamma, "lemmy-epsilon"); - // Setup delta allowed instance await allowInstance(delta, "lemmy-beta"); // Create the main alpha/beta communities @@ -202,7 +201,7 @@ export async function setupLogins() { } } -export async function allowInstance(api: LemmyHttp, instance: string) { +async function allowInstance(api: LemmyHttp, instance: string) { const params: AdminAllowInstanceParams = { instance, allow: true, diff --git a/crates/api/src/site/admin_allow_instance.rs b/crates/api/src/site/admin_allow_instance.rs index 97e8279fe..81879ecae 100644 --- a/crates/api/src/site/admin_allow_instance.rs +++ b/crates/api/src/site/admin_allow_instance.rs @@ -32,7 +32,7 @@ pub async fn admin_allow_instance( .await? .id; let form = FederationAllowListForm { - instance_id: instance_id, + instance_id, updated: None, }; if data.allow { diff --git a/crates/api/src/site/admin_block_instance.rs b/crates/api/src/site/admin_block_instance.rs index d27ec252f..ec6fd2f9c 100644 --- a/crates/api/src/site/admin_block_instance.rs +++ b/crates/api/src/site/admin_block_instance.rs @@ -44,7 +44,7 @@ pub async fn admin_block_instance( } let mod_log_form = AdminBlockInstanceForm { - instance_id: instance_id, + instance_id, admin_person_id: local_user_view.person.id, blocked: data.block, reason: data.reason.clone(),