2020-08-31 13:48:02 +00:00
|
|
|
jest.setTimeout(120000);
|
2022-10-27 09:24:07 +00:00
|
|
|
|
2023-04-26 04:26:10 +00:00
|
|
|
import { CommunityView } from "lemmy-js-client/dist/types/CommunityView";
|
2020-08-04 14:57:37 +00:00
|
|
|
import {
|
|
|
|
alpha,
|
|
|
|
beta,
|
|
|
|
gamma,
|
2020-08-20 12:44:22 +00:00
|
|
|
delta,
|
|
|
|
epsilon,
|
2020-08-04 14:57:37 +00:00
|
|
|
setupLogins,
|
|
|
|
createPost,
|
2020-12-20 21:16:57 +00:00
|
|
|
editPost,
|
2022-12-12 11:17:10 +00:00
|
|
|
featurePost,
|
2020-08-04 14:57:37 +00:00
|
|
|
lockPost,
|
2021-08-23 15:25:39 +00:00
|
|
|
resolvePost,
|
2020-08-04 14:57:37 +00:00
|
|
|
likePost,
|
|
|
|
followBeta,
|
2021-08-23 15:25:39 +00:00
|
|
|
resolveBetaCommunity,
|
2020-08-04 14:57:37 +00:00
|
|
|
createComment,
|
|
|
|
deletePost,
|
|
|
|
removePost,
|
|
|
|
getPost,
|
|
|
|
unfollowRemotes,
|
2021-08-23 15:25:39 +00:00
|
|
|
resolvePerson,
|
2021-03-12 19:09:03 +00:00
|
|
|
banPersonFromSite,
|
2021-03-18 13:24:29 +00:00
|
|
|
followCommunity,
|
2021-03-12 19:09:03 +00:00
|
|
|
banPersonFromCommunity,
|
2021-10-15 14:37:33 +00:00
|
|
|
reportPost,
|
|
|
|
listPostReports,
|
|
|
|
randomString,
|
2022-02-07 19:23:12 +00:00
|
|
|
registerUser,
|
2022-03-22 19:50:47 +00:00
|
|
|
getSite,
|
2022-10-13 16:30:31 +00:00
|
|
|
unfollows,
|
2022-10-27 09:24:07 +00:00
|
|
|
resolveCommunity,
|
2023-09-09 16:25:03 +00:00
|
|
|
waitUntil,
|
2023-09-20 10:46:25 +00:00
|
|
|
waitForPost,
|
2023-09-21 10:42:28 +00:00
|
|
|
alphaUrl,
|
2023-10-09 10:46:12 +00:00
|
|
|
loginUser,
|
2024-02-27 14:11:41 +00:00
|
|
|
createCommunity,
|
2022-10-27 09:24:07 +00:00
|
|
|
} from "./shared";
|
2023-04-26 04:26:10 +00:00
|
|
|
import { PostView } from "lemmy-js-client/dist/types/PostView";
|
2024-03-01 18:45:06 +00:00
|
|
|
import { EditSite, ResolveObject } from "lemmy-js-client";
|
2020-08-04 14:57:37 +00:00
|
|
|
|
2023-01-04 15:59:26 +00:00
|
|
|
let betaCommunity: CommunityView | undefined;
|
2020-08-04 14:57:37 +00:00
|
|
|
|
|
|
|
beforeAll(async () => {
|
|
|
|
await setupLogins();
|
2023-01-04 15:59:26 +00:00
|
|
|
betaCommunity = (await resolveBetaCommunity(alpha)).community;
|
2021-08-23 15:25:39 +00:00
|
|
|
expect(betaCommunity).toBeDefined();
|
2020-12-18 02:10:20 +00:00
|
|
|
await unfollows();
|
2020-08-04 14:57:37 +00:00
|
|
|
});
|
|
|
|
|
2023-11-17 04:43:40 +00:00
|
|
|
afterAll(() => {
|
|
|
|
unfollows();
|
2020-12-18 02:10:20 +00:00
|
|
|
});
|
|
|
|
|
2023-01-04 15:59:26 +00:00
|
|
|
function assertPostFederation(postOne?: PostView, postTwo?: PostView) {
|
|
|
|
expect(postOne?.post.ap_id).toBe(postTwo?.post.ap_id);
|
|
|
|
expect(postOne?.post.name).toBe(postTwo?.post.name);
|
|
|
|
expect(postOne?.post.body).toBe(postTwo?.post.body);
|
|
|
|
// TODO url clears arent working
|
|
|
|
// expect(postOne?.post.url).toBe(postTwo?.post.url);
|
|
|
|
expect(postOne?.post.nsfw).toBe(postTwo?.post.nsfw);
|
|
|
|
expect(postOne?.post.embed_title).toBe(postTwo?.post.embed_title);
|
|
|
|
expect(postOne?.post.embed_description).toBe(postTwo?.post.embed_description);
|
|
|
|
expect(postOne?.post.embed_video_url).toBe(postTwo?.post.embed_video_url);
|
|
|
|
expect(postOne?.post.published).toBe(postTwo?.post.published);
|
|
|
|
expect(postOne?.community.actor_id).toBe(postTwo?.community.actor_id);
|
|
|
|
expect(postOne?.post.locked).toBe(postTwo?.post.locked);
|
|
|
|
expect(postOne?.post.removed).toBe(postTwo?.post.removed);
|
|
|
|
expect(postOne?.post.deleted).toBe(postTwo?.post.deleted);
|
2020-09-17 15:41:51 +00:00
|
|
|
}
|
|
|
|
|
2022-10-27 09:24:07 +00:00
|
|
|
test("Create a post", async () => {
|
2024-01-25 14:22:11 +00:00
|
|
|
// Setup some allowlists and blocklists
|
|
|
|
let editSiteForm: EditSite = {
|
|
|
|
allowed_instances: ["lemmy-beta"],
|
|
|
|
};
|
|
|
|
await delta.editSite(editSiteForm);
|
|
|
|
|
|
|
|
editSiteForm.allowed_instances = [];
|
|
|
|
editSiteForm.blocked_instances = ["lemmy-alpha"];
|
|
|
|
await epsilon.editSite(editSiteForm);
|
|
|
|
|
2023-01-04 15:59:26 +00:00
|
|
|
if (!betaCommunity) {
|
|
|
|
throw "Missing beta community";
|
|
|
|
}
|
|
|
|
|
2024-01-15 14:33:39 +00:00
|
|
|
let postRes = await createPost(
|
|
|
|
alpha,
|
|
|
|
betaCommunity.community.id,
|
|
|
|
"https://example.com/",
|
|
|
|
"აშშ ითხოვს ირანს დაუყოვნებლივ გაანთავისუფლოს დაკავებული ნავთობის ტანკერი",
|
|
|
|
);
|
2020-12-20 21:16:57 +00:00
|
|
|
expect(postRes.post_view.post).toBeDefined();
|
|
|
|
expect(postRes.post_view.community.local).toBe(false);
|
|
|
|
expect(postRes.post_view.creator.local).toBe(true);
|
|
|
|
expect(postRes.post_view.counts.score).toBe(1);
|
2020-08-04 14:57:37 +00:00
|
|
|
|
|
|
|
// Make sure that post is liked on beta
|
2023-09-20 10:46:25 +00:00
|
|
|
const betaPost = await waitForPost(
|
|
|
|
beta,
|
|
|
|
postRes.post_view.post,
|
|
|
|
res => res?.counts.score === 1,
|
2023-09-09 16:25:03 +00:00
|
|
|
);
|
2020-08-04 14:57:37 +00:00
|
|
|
|
|
|
|
expect(betaPost).toBeDefined();
|
2023-01-04 15:59:26 +00:00
|
|
|
expect(betaPost?.community.local).toBe(true);
|
|
|
|
expect(betaPost?.creator.local).toBe(false);
|
|
|
|
expect(betaPost?.counts.score).toBe(1);
|
2020-12-20 21:16:57 +00:00
|
|
|
assertPostFederation(betaPost, postRes.post_view);
|
2020-08-20 12:44:22 +00:00
|
|
|
|
|
|
|
// Delta only follows beta, so it should not see an alpha ap_id
|
2023-11-17 04:43:40 +00:00
|
|
|
await expect(
|
|
|
|
resolvePost(delta, postRes.post_view.post),
|
|
|
|
).rejects.toStrictEqual(Error("couldnt_find_object"));
|
2020-08-20 12:44:22 +00:00
|
|
|
|
|
|
|
// Epsilon has alpha blocked, it should not see the alpha post
|
2023-11-17 04:43:40 +00:00
|
|
|
await expect(
|
|
|
|
resolvePost(epsilon, postRes.post_view.post),
|
|
|
|
).rejects.toStrictEqual(Error("couldnt_find_object"));
|
2024-01-25 14:22:11 +00:00
|
|
|
|
|
|
|
// remove added allow/blocklists
|
|
|
|
editSiteForm.allowed_instances = [];
|
|
|
|
editSiteForm.blocked_instances = [];
|
|
|
|
await delta.editSite(editSiteForm);
|
|
|
|
await epsilon.editSite(editSiteForm);
|
2020-08-20 12:44:22 +00:00
|
|
|
});
|
|
|
|
|
2022-10-27 09:24:07 +00:00
|
|
|
test("Create a post in a non-existent community", async () => {
|
2023-11-17 04:43:40 +00:00
|
|
|
await expect(createPost(alpha, -2)).rejects.toStrictEqual(
|
|
|
|
Error("couldnt_find_community"),
|
|
|
|
);
|
2020-08-04 14:57:37 +00:00
|
|
|
});
|
|
|
|
|
2022-10-27 09:24:07 +00:00
|
|
|
test("Unlike a post", async () => {
|
2023-01-04 15:59:26 +00:00
|
|
|
if (!betaCommunity) {
|
|
|
|
throw "Missing beta community";
|
|
|
|
}
|
2020-12-21 02:48:29 +00:00
|
|
|
let postRes = await createPost(alpha, betaCommunity.community.id);
|
2020-12-20 21:16:57 +00:00
|
|
|
let unlike = await likePost(alpha, 0, postRes.post_view.post);
|
|
|
|
expect(unlike.post_view.counts.score).toBe(0);
|
2020-08-04 14:57:37 +00:00
|
|
|
|
2020-08-20 12:44:22 +00:00
|
|
|
// Try to unlike it again, make sure it stays at 0
|
2020-12-20 21:16:57 +00:00
|
|
|
let unlike2 = await likePost(alpha, 0, postRes.post_view.post);
|
|
|
|
expect(unlike2.post_view.counts.score).toBe(0);
|
2020-08-20 12:44:22 +00:00
|
|
|
|
2020-08-04 14:57:37 +00:00
|
|
|
// Make sure that post is unliked on beta
|
2023-09-20 10:46:25 +00:00
|
|
|
const betaPost = await waitForPost(
|
|
|
|
beta,
|
|
|
|
postRes.post_view.post,
|
2023-09-20 11:21:47 +00:00
|
|
|
post => post?.counts.score === 0,
|
2023-09-20 10:46:25 +00:00
|
|
|
);
|
|
|
|
|
2020-08-04 14:57:37 +00:00
|
|
|
expect(betaPost).toBeDefined();
|
2023-01-04 15:59:26 +00:00
|
|
|
expect(betaPost?.community.local).toBe(true);
|
|
|
|
expect(betaPost?.creator.local).toBe(false);
|
|
|
|
expect(betaPost?.counts.score).toBe(0);
|
2020-12-20 21:16:57 +00:00
|
|
|
assertPostFederation(betaPost, postRes.post_view);
|
2020-08-04 14:57:37 +00:00
|
|
|
});
|
|
|
|
|
2022-10-27 09:24:07 +00:00
|
|
|
test("Update a post", async () => {
|
2023-01-04 15:59:26 +00:00
|
|
|
if (!betaCommunity) {
|
|
|
|
throw "Missing beta community";
|
|
|
|
}
|
2020-12-21 02:48:29 +00:00
|
|
|
let postRes = await createPost(alpha, betaCommunity.community.id);
|
2023-09-20 10:46:25 +00:00
|
|
|
await waitForPost(beta, postRes.post_view.post);
|
2020-08-04 14:57:37 +00:00
|
|
|
|
2022-10-27 09:24:07 +00:00
|
|
|
let updatedName = "A jest test federated post, updated";
|
2020-12-20 21:16:57 +00:00
|
|
|
let updatedPost = await editPost(alpha, postRes.post_view.post);
|
|
|
|
expect(updatedPost.post_view.post.name).toBe(updatedName);
|
|
|
|
expect(updatedPost.post_view.community.local).toBe(false);
|
|
|
|
expect(updatedPost.post_view.creator.local).toBe(true);
|
2020-08-20 12:44:22 +00:00
|
|
|
|
|
|
|
// Make sure that post is updated on beta
|
2023-09-20 10:46:25 +00:00
|
|
|
let betaPost = await waitForPost(beta, updatedPost.post_view.post);
|
2020-12-20 21:16:57 +00:00
|
|
|
expect(betaPost.community.local).toBe(true);
|
|
|
|
expect(betaPost.creator.local).toBe(false);
|
|
|
|
expect(betaPost.post.name).toBe(updatedName);
|
|
|
|
assertPostFederation(betaPost, updatedPost.post_view);
|
2020-08-20 12:44:22 +00:00
|
|
|
|
|
|
|
// Make sure lemmy beta cannot update the post
|
2023-11-17 04:43:40 +00:00
|
|
|
await expect(editPost(beta, betaPost.post)).rejects.toStrictEqual(
|
|
|
|
Error("no_post_edit_allowed"),
|
2023-07-21 09:47:56 +00:00
|
|
|
);
|
2020-08-04 14:57:37 +00:00
|
|
|
});
|
|
|
|
|
2022-10-27 09:24:07 +00:00
|
|
|
test("Sticky a post", async () => {
|
2023-01-04 15:59:26 +00:00
|
|
|
if (!betaCommunity) {
|
|
|
|
throw "Missing beta community";
|
|
|
|
}
|
2020-12-21 02:48:29 +00:00
|
|
|
let postRes = await createPost(alpha, betaCommunity.community.id);
|
2020-08-04 14:57:37 +00:00
|
|
|
|
2023-09-20 11:38:12 +00:00
|
|
|
let betaPost1 = await waitForPost(beta, postRes.post_view.post);
|
2023-01-04 15:59:26 +00:00
|
|
|
if (!betaPost1) {
|
|
|
|
throw "Missing beta post1";
|
|
|
|
}
|
2022-12-12 11:17:10 +00:00
|
|
|
let stickiedPostRes = await featurePost(beta, true, betaPost1.post);
|
|
|
|
expect(stickiedPostRes.post_view.post.featured_community).toBe(true);
|
2020-08-04 14:57:37 +00:00
|
|
|
|
|
|
|
// Make sure that post is stickied on beta
|
2023-01-04 15:59:26 +00:00
|
|
|
let betaPost = (await resolvePost(beta, postRes.post_view.post)).post;
|
|
|
|
expect(betaPost?.community.local).toBe(true);
|
|
|
|
expect(betaPost?.creator.local).toBe(false);
|
|
|
|
expect(betaPost?.post.featured_community).toBe(true);
|
2020-08-04 14:57:37 +00:00
|
|
|
|
|
|
|
// Unsticky a post
|
2022-12-12 11:17:10 +00:00
|
|
|
let unstickiedPost = await featurePost(beta, false, betaPost1.post);
|
|
|
|
expect(unstickiedPost.post_view.post.featured_community).toBe(false);
|
2020-08-04 14:57:37 +00:00
|
|
|
|
|
|
|
// Make sure that post is unstickied on beta
|
2023-01-04 15:59:26 +00:00
|
|
|
let betaPost2 = (await resolvePost(beta, postRes.post_view.post)).post;
|
|
|
|
expect(betaPost2?.community.local).toBe(true);
|
|
|
|
expect(betaPost2?.creator.local).toBe(false);
|
|
|
|
expect(betaPost2?.post.featured_community).toBe(false);
|
2020-08-20 12:44:22 +00:00
|
|
|
|
|
|
|
// Make sure that gamma cannot sticky the post on beta
|
2023-09-21 12:01:22 +00:00
|
|
|
let gammaPost = (await resolvePost(gamma, postRes.post_view.post)).post;
|
2023-01-04 15:59:26 +00:00
|
|
|
if (!gammaPost) {
|
|
|
|
throw "Missing gamma post";
|
|
|
|
}
|
2022-12-12 11:17:10 +00:00
|
|
|
let gammaTrySticky = await featurePost(gamma, true, gammaPost.post);
|
2023-01-04 15:59:26 +00:00
|
|
|
let betaPost3 = (await resolvePost(beta, postRes.post_view.post)).post;
|
2022-12-12 11:17:10 +00:00
|
|
|
expect(gammaTrySticky.post_view.post.featured_community).toBe(true);
|
2023-01-04 15:59:26 +00:00
|
|
|
expect(betaPost3?.post.featured_community).toBe(false);
|
2020-08-04 14:57:37 +00:00
|
|
|
});
|
|
|
|
|
2024-02-27 14:11:41 +00:00
|
|
|
test("Collection of featured posts gets federated", async () => {
|
|
|
|
// create a new community and feature a post
|
|
|
|
let community = await createCommunity(alpha);
|
|
|
|
let post = await createPost(alpha, community.community_view.community.id);
|
|
|
|
let featuredPost = await featurePost(alpha, true, post.post_view.post);
|
|
|
|
expect(featuredPost.post_view.post.featured_community).toBe(true);
|
|
|
|
|
|
|
|
// fetch the community, ensure that post is also fetched and marked as featured
|
|
|
|
let betaCommunity = await resolveCommunity(
|
|
|
|
beta,
|
|
|
|
community.community_view.community.actor_id,
|
|
|
|
);
|
2024-03-01 18:45:06 +00:00
|
|
|
expect(betaCommunity).toBeDefined();
|
2024-02-27 14:11:41 +00:00
|
|
|
|
|
|
|
const betaPost = await waitForPost(
|
|
|
|
beta,
|
|
|
|
post.post_view.post,
|
|
|
|
post => post?.post.featured_community === true,
|
|
|
|
);
|
2024-03-01 18:45:06 +00:00
|
|
|
expect(betaPost).toBeDefined();
|
2024-02-27 14:11:41 +00:00
|
|
|
});
|
|
|
|
|
2022-10-27 09:24:07 +00:00
|
|
|
test("Lock a post", async () => {
|
2023-01-04 15:59:26 +00:00
|
|
|
if (!betaCommunity) {
|
|
|
|
throw "Missing beta community";
|
|
|
|
}
|
2021-03-18 13:24:29 +00:00
|
|
|
await followCommunity(alpha, true, betaCommunity.community.id);
|
2023-09-09 16:25:03 +00:00
|
|
|
await waitUntil(
|
|
|
|
() => resolveBetaCommunity(alpha),
|
|
|
|
c => c.community?.subscribed === "Subscribed",
|
|
|
|
);
|
2020-08-04 14:57:37 +00:00
|
|
|
|
2023-09-09 16:25:03 +00:00
|
|
|
let postRes = await createPost(alpha, betaCommunity.community.id);
|
2023-09-20 10:46:25 +00:00
|
|
|
let betaPost1 = await waitForPost(beta, postRes.post_view.post);
|
2020-11-10 16:53:35 +00:00
|
|
|
// Lock the post
|
2021-03-18 13:24:29 +00:00
|
|
|
let lockedPostRes = await lockPost(beta, true, betaPost1.post);
|
2020-12-20 21:16:57 +00:00
|
|
|
expect(lockedPostRes.post_view.post.locked).toBe(true);
|
2020-08-04 14:57:37 +00:00
|
|
|
|
2021-03-18 13:24:29 +00:00
|
|
|
// Make sure that post is locked on alpha
|
2023-09-20 10:46:25 +00:00
|
|
|
let alphaPost1 = await waitForPost(
|
|
|
|
alpha,
|
|
|
|
postRes.post_view.post,
|
2023-09-20 11:21:47 +00:00
|
|
|
post => !!post && post.post.locked,
|
2023-09-09 16:25:03 +00:00
|
|
|
);
|
2020-08-04 14:57:37 +00:00
|
|
|
|
2024-03-04 14:15:21 +00:00
|
|
|
// Try to make a new comment there, on alpha. For this we need to create a normal
|
|
|
|
// user account because admins/mods can comment in locked posts.
|
|
|
|
let user = await registerUser(alpha, alphaUrl);
|
|
|
|
await expect(createComment(user, alphaPost1.post.id)).rejects.toStrictEqual(
|
2023-11-17 04:43:40 +00:00
|
|
|
Error("locked"),
|
|
|
|
);
|
2020-08-04 14:57:37 +00:00
|
|
|
|
|
|
|
// Unlock a post
|
2021-03-18 13:24:29 +00:00
|
|
|
let unlockedPost = await lockPost(beta, false, betaPost1.post);
|
2020-12-20 21:16:57 +00:00
|
|
|
expect(unlockedPost.post_view.post.locked).toBe(false);
|
2020-08-04 14:57:37 +00:00
|
|
|
|
2021-03-18 13:24:29 +00:00
|
|
|
// Make sure that post is unlocked on alpha
|
2023-09-20 10:46:25 +00:00
|
|
|
let alphaPost2 = await waitForPost(
|
|
|
|
alpha,
|
|
|
|
postRes.post_view.post,
|
2023-09-20 11:21:47 +00:00
|
|
|
post => !!post && !post.post.locked,
|
2023-09-09 16:25:03 +00:00
|
|
|
);
|
2021-03-18 13:24:29 +00:00
|
|
|
expect(alphaPost2.community.local).toBe(false);
|
|
|
|
expect(alphaPost2.creator.local).toBe(true);
|
|
|
|
expect(alphaPost2.post.locked).toBe(false);
|
2020-11-10 16:53:35 +00:00
|
|
|
|
2021-03-18 13:24:29 +00:00
|
|
|
// Try to create a new comment, on alpha
|
2024-03-04 14:15:21 +00:00
|
|
|
let commentAlpha = await createComment(user, alphaPost1.post.id);
|
2021-03-18 13:24:29 +00:00
|
|
|
expect(commentAlpha).toBeDefined();
|
2020-08-04 14:57:37 +00:00
|
|
|
});
|
|
|
|
|
2022-10-27 09:24:07 +00:00
|
|
|
test("Delete a post", async () => {
|
2023-01-04 15:59:26 +00:00
|
|
|
if (!betaCommunity) {
|
|
|
|
throw "Missing beta community";
|
|
|
|
}
|
|
|
|
|
2020-12-21 02:48:29 +00:00
|
|
|
let postRes = await createPost(alpha, betaCommunity.community.id);
|
|
|
|
expect(postRes.post_view.post).toBeDefined();
|
2023-09-20 14:18:31 +00:00
|
|
|
await waitForPost(beta, postRes.post_view.post);
|
2020-08-04 14:57:37 +00:00
|
|
|
|
2020-12-20 21:16:57 +00:00
|
|
|
let deletedPost = await deletePost(alpha, true, postRes.post_view.post);
|
|
|
|
expect(deletedPost.post_view.post.deleted).toBe(true);
|
2021-10-27 13:34:18 +00:00
|
|
|
expect(deletedPost.post_view.post.name).toBe(postRes.post_view.post.name);
|
2020-08-04 14:57:37 +00:00
|
|
|
|
|
|
|
// Make sure lemmy beta sees post is deleted
|
2020-08-31 13:48:02 +00:00
|
|
|
// This will be undefined because of the tombstone
|
2023-09-20 13:07:36 +00:00
|
|
|
await waitForPost(beta, postRes.post_view.post, p => !p || p.post.deleted);
|
2020-08-04 14:57:37 +00:00
|
|
|
|
|
|
|
// Undelete
|
2020-12-20 21:16:57 +00:00
|
|
|
let undeletedPost = await deletePost(alpha, false, postRes.post_view.post);
|
2020-08-04 14:57:37 +00:00
|
|
|
|
|
|
|
// Make sure lemmy beta sees post is undeleted
|
2023-09-20 13:07:36 +00:00
|
|
|
let betaPost2 = await waitForPost(
|
|
|
|
beta,
|
|
|
|
postRes.post_view.post,
|
|
|
|
p => !!p && !p.post.deleted,
|
|
|
|
);
|
2023-09-20 10:46:25 +00:00
|
|
|
|
2023-01-04 15:59:26 +00:00
|
|
|
if (!betaPost2) {
|
|
|
|
throw "Missing beta post 2";
|
|
|
|
}
|
2020-12-20 21:16:57 +00:00
|
|
|
expect(betaPost2.post.deleted).toBe(false);
|
|
|
|
assertPostFederation(betaPost2, undeletedPost.post_view);
|
2020-08-20 12:44:22 +00:00
|
|
|
|
|
|
|
// Make sure lemmy beta cannot delete the post
|
2023-11-17 04:43:40 +00:00
|
|
|
await expect(deletePost(beta, true, betaPost2.post)).rejects.toStrictEqual(
|
|
|
|
Error("no_post_edit_allowed"),
|
2023-07-21 09:47:56 +00:00
|
|
|
);
|
2020-08-04 14:57:37 +00:00
|
|
|
});
|
|
|
|
|
2022-10-27 09:24:07 +00:00
|
|
|
test("Remove a post from admin and community on different instance", async () => {
|
2023-01-04 15:59:26 +00:00
|
|
|
if (!betaCommunity) {
|
|
|
|
throw "Missing beta community";
|
|
|
|
}
|
|
|
|
|
|
|
|
let gammaCommunity = (
|
|
|
|
await resolveCommunity(gamma, betaCommunity.community.actor_id)
|
|
|
|
).community?.community;
|
|
|
|
if (!gammaCommunity) {
|
|
|
|
throw "Missing gamma community";
|
|
|
|
}
|
|
|
|
let postRes = await createPost(gamma, gammaCommunity.id);
|
|
|
|
|
2023-09-21 12:01:22 +00:00
|
|
|
let alphaPost = (await resolvePost(alpha, postRes.post_view.post)).post;
|
2023-01-04 15:59:26 +00:00
|
|
|
if (!alphaPost) {
|
|
|
|
throw "Missing alpha post";
|
|
|
|
}
|
2022-04-04 14:46:49 +00:00
|
|
|
let removedPost = await removePost(alpha, true, alphaPost.post);
|
2020-12-20 21:16:57 +00:00
|
|
|
expect(removedPost.post_view.post.removed).toBe(true);
|
2021-10-27 13:34:18 +00:00
|
|
|
expect(removedPost.post_view.post.name).toBe(postRes.post_view.post.name);
|
2020-08-04 14:57:37 +00:00
|
|
|
|
2020-08-07 14:51:53 +00:00
|
|
|
// Make sure lemmy beta sees post is NOT removed
|
2023-09-21 12:01:22 +00:00
|
|
|
let betaPost = (await resolvePost(beta, postRes.post_view.post)).post;
|
2023-01-04 15:59:26 +00:00
|
|
|
if (!betaPost) {
|
|
|
|
throw "Missing beta post";
|
|
|
|
}
|
2020-12-20 21:16:57 +00:00
|
|
|
expect(betaPost.post.removed).toBe(false);
|
2020-08-04 14:57:37 +00:00
|
|
|
|
|
|
|
// Undelete
|
2022-04-04 14:46:49 +00:00
|
|
|
let undeletedPost = await removePost(alpha, false, alphaPost.post);
|
2020-12-20 21:16:57 +00:00
|
|
|
expect(undeletedPost.post_view.post.removed).toBe(false);
|
2020-08-04 14:57:37 +00:00
|
|
|
|
|
|
|
// Make sure lemmy beta sees post is undeleted
|
2023-01-04 15:59:26 +00:00
|
|
|
let betaPost2 = (await resolvePost(beta, postRes.post_view.post)).post;
|
|
|
|
expect(betaPost2?.post.removed).toBe(false);
|
2020-12-20 21:16:57 +00:00
|
|
|
assertPostFederation(betaPost2, undeletedPost.post_view);
|
2020-08-04 14:57:37 +00:00
|
|
|
});
|
|
|
|
|
2022-10-27 09:24:07 +00:00
|
|
|
test("Remove a post from admin and community on same instance", async () => {
|
2023-01-04 15:59:26 +00:00
|
|
|
if (!betaCommunity) {
|
|
|
|
throw "Missing beta community";
|
|
|
|
}
|
2020-12-17 19:36:22 +00:00
|
|
|
await followBeta(alpha);
|
2023-09-26 01:39:18 +00:00
|
|
|
let gammaCommunity = await resolveCommunity(
|
|
|
|
gamma,
|
|
|
|
betaCommunity.community.actor_id,
|
|
|
|
);
|
|
|
|
let postRes = await createPost(gamma, gammaCommunity.community!.community.id);
|
2020-12-21 02:48:29 +00:00
|
|
|
expect(postRes.post_view.post).toBeDefined();
|
2020-08-07 14:51:53 +00:00
|
|
|
// Get the id for beta
|
2023-09-20 10:46:25 +00:00
|
|
|
let betaPost = await waitForPost(beta, postRes.post_view.post);
|
2020-12-17 19:59:53 +00:00
|
|
|
expect(betaPost).toBeDefined();
|
2020-08-07 14:51:53 +00:00
|
|
|
|
2023-09-26 01:39:18 +00:00
|
|
|
let alphaPost0 = await waitForPost(alpha, postRes.post_view.post);
|
|
|
|
expect(alphaPost0).toBeDefined();
|
|
|
|
|
2020-08-07 14:51:53 +00:00
|
|
|
// The beta admin removes it (the community lives on beta)
|
2020-12-20 21:16:57 +00:00
|
|
|
let removePostRes = await removePost(beta, true, betaPost.post);
|
|
|
|
expect(removePostRes.post_view.post.removed).toBe(true);
|
2020-08-07 14:51:53 +00:00
|
|
|
|
|
|
|
// Make sure lemmy alpha sees post is removed
|
2023-09-20 11:21:47 +00:00
|
|
|
let alphaPost = await waitUntil(
|
2023-09-26 01:39:18 +00:00
|
|
|
() => getPost(alpha, alphaPost0.post.id),
|
2023-09-20 11:21:47 +00:00
|
|
|
p => p?.post_view.post.removed ?? false,
|
2023-09-18 17:04:46 +00:00
|
|
|
);
|
2023-09-26 01:39:18 +00:00
|
|
|
expect(alphaPost?.post_view.post.removed).toBe(true);
|
2023-09-20 11:21:47 +00:00
|
|
|
assertPostFederation(alphaPost.post_view, removePostRes.post_view);
|
2020-08-07 14:51:53 +00:00
|
|
|
|
|
|
|
// Undelete
|
2020-12-20 21:16:57 +00:00
|
|
|
let undeletedPost = await removePost(beta, false, betaPost.post);
|
|
|
|
expect(undeletedPost.post_view.post.removed).toBe(false);
|
2020-08-07 14:51:53 +00:00
|
|
|
|
|
|
|
// Make sure lemmy alpha sees post is undeleted
|
2023-09-20 10:46:25 +00:00
|
|
|
let alphaPost2 = await waitForPost(
|
|
|
|
alpha,
|
|
|
|
postRes.post_view.post,
|
2023-09-20 11:21:47 +00:00
|
|
|
p => !!p && !p.post.removed,
|
2023-09-18 17:04:46 +00:00
|
|
|
);
|
2023-09-20 10:46:25 +00:00
|
|
|
expect(alphaPost2.post.removed).toBe(false);
|
|
|
|
assertPostFederation(alphaPost2, undeletedPost.post_view);
|
2020-12-17 19:01:33 +00:00
|
|
|
await unfollowRemotes(alpha);
|
2020-08-07 14:51:53 +00:00
|
|
|
});
|
|
|
|
|
2022-10-27 09:24:07 +00:00
|
|
|
test("Search for a post", async () => {
|
2023-01-04 15:59:26 +00:00
|
|
|
if (!betaCommunity) {
|
|
|
|
throw "Missing beta community";
|
|
|
|
}
|
2020-12-17 19:59:53 +00:00
|
|
|
await unfollowRemotes(alpha);
|
2020-12-21 02:48:29 +00:00
|
|
|
let postRes = await createPost(alpha, betaCommunity.community.id);
|
|
|
|
expect(postRes.post_view.post).toBeDefined();
|
2020-12-17 19:36:22 +00:00
|
|
|
|
2023-09-20 11:21:47 +00:00
|
|
|
let betaPost = await waitForPost(beta, postRes.post_view.post);
|
2023-01-04 15:59:26 +00:00
|
|
|
expect(betaPost?.post.name).toBeDefined();
|
2020-08-04 14:57:37 +00:00
|
|
|
});
|
|
|
|
|
2024-03-01 18:45:06 +00:00
|
|
|
test("Enforce site ban federation for local user", async () => {
|
2023-01-04 15:59:26 +00:00
|
|
|
if (!betaCommunity) {
|
|
|
|
throw "Missing beta community";
|
|
|
|
}
|
2024-03-01 18:45:06 +00:00
|
|
|
|
2022-02-07 19:23:12 +00:00
|
|
|
// create a test user
|
2024-03-01 18:45:06 +00:00
|
|
|
let alphaUserHttp = await registerUser(alpha, alphaUrl);
|
|
|
|
let alphaUserPerson = (await getSite(alphaUserHttp)).my_user?.local_user_view
|
2023-10-09 10:46:12 +00:00
|
|
|
.person;
|
|
|
|
let alphaUserActorId = alphaUserPerson?.actor_id;
|
2023-01-04 15:59:26 +00:00
|
|
|
if (!alphaUserActorId) {
|
|
|
|
throw "Missing alpha user actor id";
|
|
|
|
}
|
2022-02-07 19:23:12 +00:00
|
|
|
expect(alphaUserActorId).toBeDefined();
|
2024-03-01 18:45:06 +00:00
|
|
|
await followBeta(alphaUserHttp);
|
|
|
|
|
|
|
|
let alphaPerson = (await resolvePerson(alphaUserHttp, alphaUserActorId!))
|
|
|
|
.person;
|
2023-01-04 15:59:26 +00:00
|
|
|
if (!alphaPerson) {
|
|
|
|
throw "Missing alpha person";
|
|
|
|
}
|
2021-08-23 15:25:39 +00:00
|
|
|
expect(alphaPerson).toBeDefined();
|
2020-11-10 16:53:35 +00:00
|
|
|
|
2022-02-07 19:23:12 +00:00
|
|
|
// alpha makes post in beta community, it federates to beta instance
|
2024-03-01 18:45:06 +00:00
|
|
|
let postRes1 = await createPost(alphaUserHttp, betaCommunity.community.id);
|
2023-09-20 10:46:25 +00:00
|
|
|
let searchBeta1 = await waitForPost(beta, postRes1.post_view.post);
|
2022-02-07 19:23:12 +00:00
|
|
|
|
2024-03-01 18:45:06 +00:00
|
|
|
// ban alpha from its own instance
|
2022-10-27 09:24:07 +00:00
|
|
|
let banAlpha = await banPersonFromSite(
|
|
|
|
alpha,
|
|
|
|
alphaPerson.person.id,
|
|
|
|
true,
|
2023-07-06 13:10:38 +00:00
|
|
|
true,
|
2022-10-27 09:24:07 +00:00
|
|
|
);
|
2023-10-20 00:15:55 +00:00
|
|
|
expect(banAlpha.banned).toBe(true);
|
2020-11-10 16:53:35 +00:00
|
|
|
|
2022-02-07 19:23:12 +00:00
|
|
|
// alpha ban should be federated to beta
|
2023-09-09 16:25:03 +00:00
|
|
|
let alphaUserOnBeta1 = await waitUntil(
|
2023-09-21 10:42:28 +00:00
|
|
|
() => resolvePerson(beta, alphaUserActorId!),
|
2023-09-09 16:25:03 +00:00
|
|
|
res => res.person?.person.banned ?? false,
|
|
|
|
);
|
2023-01-04 15:59:26 +00:00
|
|
|
expect(alphaUserOnBeta1.person?.person.banned).toBe(true);
|
2020-11-10 16:53:35 +00:00
|
|
|
|
2022-02-07 19:23:12 +00:00
|
|
|
// existing alpha post should be removed on beta
|
2024-03-01 18:45:06 +00:00
|
|
|
let betaBanRes = await waitUntil(
|
2023-09-20 20:26:00 +00:00
|
|
|
() => getPost(beta, searchBeta1.post.id),
|
|
|
|
s => s.post_view.post.removed,
|
|
|
|
);
|
2024-03-01 18:45:06 +00:00
|
|
|
expect(betaBanRes.post_view.post.removed).toBe(true);
|
2020-11-10 16:53:35 +00:00
|
|
|
|
|
|
|
// Unban alpha
|
2022-10-27 09:24:07 +00:00
|
|
|
let unBanAlpha = await banPersonFromSite(
|
|
|
|
alpha,
|
|
|
|
alphaPerson.person.id,
|
|
|
|
false,
|
2023-07-06 13:10:38 +00:00
|
|
|
false,
|
2022-10-27 09:24:07 +00:00
|
|
|
);
|
2023-10-20 00:15:55 +00:00
|
|
|
expect(unBanAlpha.banned).toBe(false);
|
2022-02-07 19:23:12 +00:00
|
|
|
|
2023-10-09 10:46:12 +00:00
|
|
|
// Login gets invalidated by ban, need to login again
|
2023-10-16 16:36:53 +00:00
|
|
|
if (!alphaUserPerson) {
|
|
|
|
throw "Missing alpha person";
|
|
|
|
}
|
|
|
|
let newAlphaUserJwt = await loginUser(alpha, alphaUserPerson.name);
|
2024-03-01 18:45:06 +00:00
|
|
|
alphaUserHttp.setHeaders({
|
2023-10-09 10:46:12 +00:00
|
|
|
Authorization: "Bearer " + newAlphaUserJwt.jwt ?? "",
|
|
|
|
});
|
2022-02-07 19:23:12 +00:00
|
|
|
// alpha makes new post in beta community, it federates
|
2024-03-01 18:45:06 +00:00
|
|
|
let postRes2 = await createPost(alphaUserHttp, betaCommunity!.community.id);
|
2023-10-16 16:36:53 +00:00
|
|
|
await waitForPost(beta, postRes2.post_view.post);
|
2022-02-07 19:23:12 +00:00
|
|
|
|
2024-03-01 18:45:06 +00:00
|
|
|
await unfollowRemotes(alpha);
|
|
|
|
});
|
|
|
|
|
|
|
|
test("Enforce site ban federation for federated user", async () => {
|
|
|
|
if (!betaCommunity) {
|
|
|
|
throw "Missing beta community";
|
|
|
|
}
|
|
|
|
|
|
|
|
// create a test user
|
|
|
|
let alphaUserHttp = await registerUser(alpha, alphaUrl);
|
|
|
|
let alphaUserPerson = (await getSite(alphaUserHttp)).my_user?.local_user_view
|
|
|
|
.person;
|
|
|
|
let alphaUserActorId = alphaUserPerson?.actor_id;
|
|
|
|
if (!alphaUserActorId) {
|
|
|
|
throw "Missing alpha user actor id";
|
|
|
|
}
|
|
|
|
expect(alphaUserActorId).toBeDefined();
|
|
|
|
await followBeta(alphaUserHttp);
|
|
|
|
|
2023-09-21 10:42:28 +00:00
|
|
|
let alphaUserOnBeta2 = await resolvePerson(beta, alphaUserActorId!);
|
2023-01-04 15:59:26 +00:00
|
|
|
expect(alphaUserOnBeta2.person?.person.banned).toBe(false);
|
2024-03-01 18:45:06 +00:00
|
|
|
|
|
|
|
if (!alphaUserOnBeta2.person) {
|
|
|
|
throw "Missing alpha person";
|
|
|
|
}
|
|
|
|
|
|
|
|
// alpha makes post in beta community, it federates to beta instance
|
|
|
|
let postRes1 = await createPost(alphaUserHttp, betaCommunity.community.id);
|
|
|
|
let searchBeta1 = await waitForPost(beta, postRes1.post_view.post);
|
|
|
|
expect(searchBeta1.post).toBeDefined();
|
|
|
|
|
|
|
|
// Now ban and remove their data from beta
|
|
|
|
let banAlphaOnBeta = await banPersonFromSite(
|
|
|
|
beta,
|
|
|
|
alphaUserOnBeta2.person.person.id,
|
|
|
|
true,
|
|
|
|
true,
|
|
|
|
);
|
|
|
|
expect(banAlphaOnBeta.banned).toBe(true);
|
|
|
|
|
|
|
|
// The beta site ban should NOT be federated to alpha
|
|
|
|
let alphaPerson2 = (await getSite(alphaUserHttp)).my_user!.local_user_view
|
|
|
|
.person;
|
|
|
|
expect(alphaPerson2.banned).toBe(false);
|
|
|
|
|
|
|
|
// existing alpha post should be removed on beta
|
|
|
|
let betaBanRes = await waitUntil(
|
|
|
|
() => getPost(beta, searchBeta1.post.id),
|
|
|
|
s => s.post_view.post.removed,
|
|
|
|
);
|
|
|
|
expect(betaBanRes.post_view.post.removed).toBe(true);
|
|
|
|
|
|
|
|
// existing alpha's post to the beta community should be removed on alpha
|
|
|
|
let alphaPostAfterRemoveOnBeta = await waitUntil(
|
|
|
|
() => getPost(alpha, postRes1.post_view.post.id),
|
|
|
|
s => s.post_view.post.removed,
|
|
|
|
);
|
|
|
|
expect(betaBanRes.post_view.post.removed).toBe(true);
|
|
|
|
expect(alphaPostAfterRemoveOnBeta.post_view.post.removed).toBe(true);
|
|
|
|
expect(
|
|
|
|
alphaPostAfterRemoveOnBeta.post_view.creator_banned_from_community,
|
|
|
|
).toBe(true);
|
|
|
|
|
|
|
|
await unfollowRemotes(alpha);
|
2020-11-10 16:53:35 +00:00
|
|
|
});
|
|
|
|
|
2024-03-01 18:45:06 +00:00
|
|
|
test("Enforce community ban for federated user", async () => {
|
2023-01-04 15:59:26 +00:00
|
|
|
if (!betaCommunity) {
|
|
|
|
throw "Missing beta community";
|
|
|
|
}
|
2024-03-01 18:45:06 +00:00
|
|
|
await followBeta(alpha);
|
2020-11-10 16:53:35 +00:00
|
|
|
let alphaShortname = `@lemmy_alpha@lemmy-alpha:8541`;
|
2023-01-04 15:59:26 +00:00
|
|
|
let alphaPerson = (await resolvePerson(beta, alphaShortname)).person;
|
|
|
|
if (!alphaPerson) {
|
|
|
|
throw "Missing alpha person";
|
|
|
|
}
|
2021-08-23 15:25:39 +00:00
|
|
|
expect(alphaPerson).toBeDefined();
|
2020-11-10 16:53:35 +00:00
|
|
|
|
2022-02-07 19:23:12 +00:00
|
|
|
// make a post in beta, it goes through
|
|
|
|
let postRes1 = await createPost(alpha, betaCommunity.community.id);
|
2024-03-01 18:45:06 +00:00
|
|
|
let searchBeta1 = await waitForPost(beta, postRes1.post_view.post);
|
|
|
|
expect(searchBeta1.post).toBeDefined();
|
2022-02-07 19:23:12 +00:00
|
|
|
|
|
|
|
// ban alpha from beta community
|
2022-10-27 09:24:07 +00:00
|
|
|
let banAlpha = await banPersonFromCommunity(
|
|
|
|
beta,
|
|
|
|
alphaPerson.person.id,
|
2024-03-01 18:45:06 +00:00
|
|
|
searchBeta1.community.id,
|
2022-10-27 09:24:07 +00:00
|
|
|
true,
|
2023-07-06 13:10:38 +00:00
|
|
|
true,
|
2022-10-27 09:24:07 +00:00
|
|
|
);
|
2023-10-20 00:15:55 +00:00
|
|
|
expect(banAlpha.banned).toBe(true);
|
2020-11-10 16:53:35 +00:00
|
|
|
|
2022-02-07 19:23:12 +00:00
|
|
|
// ensure that the post by alpha got removed
|
2024-03-01 18:45:06 +00:00
|
|
|
let removePostRes = await waitUntil(
|
|
|
|
() => getPost(alpha, postRes1.post_view.post.id),
|
|
|
|
s => s.post_view.post.removed,
|
2023-07-21 09:47:56 +00:00
|
|
|
);
|
2024-03-01 18:45:06 +00:00
|
|
|
expect(removePostRes.post_view.post.removed).toBe(true);
|
|
|
|
expect(removePostRes.post_view.creator_banned_from_community).toBe(true);
|
|
|
|
expect(removePostRes.community_view.banned_from_community).toBe(true);
|
2022-02-07 19:23:12 +00:00
|
|
|
|
2021-04-09 15:01:26 +00:00
|
|
|
// Alpha tries to make post on beta, but it fails because of ban
|
2024-03-01 18:45:06 +00:00
|
|
|
await expect(
|
|
|
|
createPost(alpha, betaCommunity.community.id),
|
|
|
|
).rejects.toStrictEqual(Error("banned_from_community"));
|
2020-11-10 16:53:35 +00:00
|
|
|
|
|
|
|
// Unban alpha
|
2021-03-12 19:09:03 +00:00
|
|
|
let unBanAlpha = await banPersonFromCommunity(
|
2020-12-20 21:16:57 +00:00
|
|
|
beta,
|
2021-08-23 15:25:39 +00:00
|
|
|
alphaPerson.person.id,
|
2024-03-01 18:45:06 +00:00
|
|
|
searchBeta1.community.id,
|
2022-02-07 19:23:12 +00:00
|
|
|
false,
|
2023-07-06 13:10:38 +00:00
|
|
|
false,
|
2020-12-20 21:16:57 +00:00
|
|
|
);
|
2023-10-20 00:15:55 +00:00
|
|
|
expect(unBanAlpha.banned).toBe(false);
|
2024-03-01 18:45:06 +00:00
|
|
|
|
|
|
|
// Need to re-follow the community
|
|
|
|
await followBeta(alpha);
|
|
|
|
|
2022-02-07 19:23:12 +00:00
|
|
|
let postRes3 = await createPost(alpha, betaCommunity.community.id);
|
|
|
|
expect(postRes3.post_view.post).toBeDefined();
|
|
|
|
expect(postRes3.post_view.community.local).toBe(false);
|
|
|
|
expect(postRes3.post_view.creator.local).toBe(true);
|
|
|
|
expect(postRes3.post_view.counts.score).toBe(1);
|
2021-04-09 15:01:26 +00:00
|
|
|
|
|
|
|
// Make sure that post makes it to beta community
|
2024-03-01 18:45:06 +00:00
|
|
|
let postRes4 = await waitForPost(beta, postRes3.post_view.post);
|
|
|
|
expect(postRes4.post).toBeDefined();
|
|
|
|
expect(postRes4.creator_banned_from_community).toBe(false);
|
|
|
|
|
|
|
|
await unfollowRemotes(alpha);
|
2020-11-10 16:53:35 +00:00
|
|
|
});
|
2021-10-15 14:37:33 +00:00
|
|
|
|
2022-10-27 09:24:07 +00:00
|
|
|
test("A and G subscribe to B (center) A posts, it gets announced to G", async () => {
|
2023-01-04 15:59:26 +00:00
|
|
|
if (!betaCommunity) {
|
|
|
|
throw "Missing beta community";
|
|
|
|
}
|
2024-03-01 18:45:06 +00:00
|
|
|
await followBeta(alpha);
|
|
|
|
|
2022-03-22 22:06:59 +00:00
|
|
|
let postRes = await createPost(alpha, betaCommunity.community.id);
|
|
|
|
expect(postRes.post_view.post).toBeDefined();
|
|
|
|
|
2023-09-21 12:01:22 +00:00
|
|
|
let betaPost = (await resolvePost(gamma, postRes.post_view.post)).post;
|
2023-01-04 15:59:26 +00:00
|
|
|
expect(betaPost?.post.name).toBeDefined();
|
2024-03-01 18:45:06 +00:00
|
|
|
await unfollowRemotes(alpha);
|
2022-03-22 22:06:59 +00:00
|
|
|
});
|
|
|
|
|
2022-10-27 09:24:07 +00:00
|
|
|
test("Report a post", async () => {
|
2023-01-04 15:59:26 +00:00
|
|
|
// Note, this is a different one from the setup
|
|
|
|
let betaCommunity = (await resolveBetaCommunity(beta)).community;
|
|
|
|
if (!betaCommunity) {
|
|
|
|
throw "Missing beta community";
|
|
|
|
}
|
2024-03-01 18:45:06 +00:00
|
|
|
await followBeta(alpha);
|
2021-10-15 14:37:33 +00:00
|
|
|
let postRes = await createPost(beta, betaCommunity.community.id);
|
|
|
|
expect(postRes.post_view.post).toBeDefined();
|
|
|
|
|
2023-09-21 12:01:22 +00:00
|
|
|
let alphaPost = (await resolvePost(alpha, postRes.post_view.post)).post;
|
2023-01-04 15:59:26 +00:00
|
|
|
if (!alphaPost) {
|
|
|
|
throw "Missing alpha post";
|
|
|
|
}
|
2022-10-27 09:24:07 +00:00
|
|
|
let alphaReport = (
|
|
|
|
await reportPost(alpha, alphaPost.post.id, randomString(10))
|
|
|
|
).post_report_view.post_report;
|
2021-10-15 14:37:33 +00:00
|
|
|
|
2023-09-18 19:58:20 +00:00
|
|
|
let betaReport = (await waitUntil(
|
|
|
|
() =>
|
|
|
|
listPostReports(beta).then(p =>
|
|
|
|
p.post_reports.find(
|
|
|
|
r =>
|
|
|
|
r.post_report.original_post_name === alphaReport.original_post_name,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
res => !!res,
|
|
|
|
))!.post_report;
|
2021-10-15 14:37:33 +00:00
|
|
|
expect(betaReport).toBeDefined();
|
|
|
|
expect(betaReport.resolved).toBe(false);
|
|
|
|
expect(betaReport.original_post_name).toBe(alphaReport.original_post_name);
|
2023-01-04 15:59:26 +00:00
|
|
|
expect(betaReport.original_post_url).toBe(alphaReport.original_post_url);
|
|
|
|
expect(betaReport.original_post_body).toBe(alphaReport.original_post_body);
|
2021-10-15 14:37:33 +00:00
|
|
|
expect(betaReport.reason).toBe(alphaReport.reason);
|
2024-03-01 18:45:06 +00:00
|
|
|
await unfollowRemotes(alpha);
|
2022-03-22 19:50:47 +00:00
|
|
|
});
|
2023-10-25 11:14:59 +00:00
|
|
|
|
|
|
|
test("Fetch post via redirect", async () => {
|
2024-03-01 18:45:06 +00:00
|
|
|
await followBeta(alpha);
|
2023-10-25 11:14:59 +00:00
|
|
|
let alphaPost = await createPost(alpha, betaCommunity!.community.id);
|
|
|
|
expect(alphaPost.post_view.post).toBeDefined();
|
|
|
|
// Make sure that post is liked on beta
|
|
|
|
const betaPost = await waitForPost(
|
|
|
|
beta,
|
|
|
|
alphaPost.post_view.post,
|
|
|
|
res => res?.counts.score === 1,
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(betaPost).toBeDefined();
|
|
|
|
expect(betaPost.post?.ap_id).toBe(alphaPost.post_view.post.ap_id);
|
|
|
|
|
|
|
|
// Fetch post from url on beta instance instead of ap_id
|
|
|
|
let q = `http://lemmy-beta:8551/post/${betaPost.post.id}`;
|
|
|
|
let form: ResolveObject = {
|
|
|
|
q,
|
|
|
|
};
|
|
|
|
let gammaPost = await gamma.resolveObject(form);
|
|
|
|
expect(gammaPost).toBeDefined();
|
|
|
|
expect(gammaPost.post?.post.ap_id).toBe(alphaPost.post_view.post.ap_id);
|
2024-03-01 18:45:06 +00:00
|
|
|
await unfollowRemotes(alpha);
|
2023-10-25 11:14:59 +00:00
|
|
|
});
|