This commit is contained in:
Felix Ableitner 2024-11-26 12:23:57 +01:00
parent ff2a7c5136
commit 6a2629e997
5 changed files with 18 additions and 20 deletions

View file

@ -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");

View file

@ -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 () => {

View file

@ -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,

View file

@ -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 {

View file

@ -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(),