mirror of
https://github.com/LemmyNet/lemmy
synced 2024-10-30 15:21:20 +00:00
Merge branch 'main' into arm-docker-image
This commit is contained in:
commit
cf4ae6f81a
24
Cargo.lock
generated
24
Cargo.lock
generated
@ -2530,7 +2530,7 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||
|
||||
[[package]]
|
||||
name = "lemmy_api"
|
||||
version = "0.19.0-rc.5"
|
||||
version = "0.19.0-rc.6"
|
||||
dependencies = [
|
||||
"activitypub_federation",
|
||||
"actix-web",
|
||||
@ -2558,7 +2558,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lemmy_api_common"
|
||||
version = "0.19.0-rc.5"
|
||||
version = "0.19.0-rc.6"
|
||||
dependencies = [
|
||||
"activitypub_federation",
|
||||
"actix-web",
|
||||
@ -2592,7 +2592,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lemmy_api_crud"
|
||||
version = "0.19.0-rc.5"
|
||||
version = "0.19.0-rc.6"
|
||||
dependencies = [
|
||||
"activitypub_federation",
|
||||
"actix-web",
|
||||
@ -2610,7 +2610,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lemmy_apub"
|
||||
version = "0.19.0-rc.5"
|
||||
version = "0.19.0-rc.6"
|
||||
dependencies = [
|
||||
"activitypub_federation",
|
||||
"actix-web",
|
||||
@ -2649,7 +2649,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lemmy_db_schema"
|
||||
version = "0.19.0-rc.5"
|
||||
version = "0.19.0-rc.6"
|
||||
dependencies = [
|
||||
"activitypub_federation",
|
||||
"async-trait",
|
||||
@ -2685,7 +2685,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lemmy_db_views"
|
||||
version = "0.19.0-rc.5"
|
||||
version = "0.19.0-rc.6"
|
||||
dependencies = [
|
||||
"actix-web",
|
||||
"diesel",
|
||||
@ -2703,7 +2703,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lemmy_db_views_actor"
|
||||
version = "0.19.0-rc.5"
|
||||
version = "0.19.0-rc.6"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"diesel",
|
||||
@ -2720,7 +2720,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lemmy_db_views_moderator"
|
||||
version = "0.19.0-rc.5"
|
||||
version = "0.19.0-rc.6"
|
||||
dependencies = [
|
||||
"diesel",
|
||||
"diesel-async",
|
||||
@ -2732,7 +2732,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lemmy_federate"
|
||||
version = "0.19.0-rc.5"
|
||||
version = "0.19.0-rc.6"
|
||||
dependencies = [
|
||||
"activitypub_federation",
|
||||
"anyhow",
|
||||
@ -2755,7 +2755,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lemmy_routes"
|
||||
version = "0.19.0-rc.5"
|
||||
version = "0.19.0-rc.6"
|
||||
dependencies = [
|
||||
"activitypub_federation",
|
||||
"actix-web",
|
||||
@ -2779,7 +2779,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lemmy_server"
|
||||
version = "0.19.0-rc.5"
|
||||
version = "0.19.0-rc.6"
|
||||
dependencies = [
|
||||
"activitypub_federation",
|
||||
"actix-cors",
|
||||
@ -2820,7 +2820,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lemmy_utils"
|
||||
version = "0.19.0-rc.5"
|
||||
version = "0.19.0-rc.6"
|
||||
dependencies = [
|
||||
"actix-web",
|
||||
"anyhow",
|
||||
|
24
Cargo.toml
24
Cargo.toml
@ -1,5 +1,5 @@
|
||||
[workspace.package]
|
||||
version = "0.19.0-rc.5"
|
||||
version = "0.19.0-rc.6"
|
||||
edition = "2021"
|
||||
description = "A link aggregator for the fediverse"
|
||||
license = "AGPL-3.0"
|
||||
@ -84,16 +84,16 @@ unused_self = "deny"
|
||||
unwrap_used = "deny"
|
||||
|
||||
[workspace.dependencies]
|
||||
lemmy_api = { version = "=0.19.0-rc.5", path = "./crates/api" }
|
||||
lemmy_api_crud = { version = "=0.19.0-rc.5", path = "./crates/api_crud" }
|
||||
lemmy_apub = { version = "=0.19.0-rc.5", path = "./crates/apub" }
|
||||
lemmy_utils = { version = "=0.19.0-rc.5", path = "./crates/utils" }
|
||||
lemmy_db_schema = { version = "=0.19.0-rc.5", path = "./crates/db_schema" }
|
||||
lemmy_api_common = { version = "=0.19.0-rc.5", path = "./crates/api_common" }
|
||||
lemmy_routes = { version = "=0.19.0-rc.5", path = "./crates/routes" }
|
||||
lemmy_db_views = { version = "=0.19.0-rc.5", path = "./crates/db_views" }
|
||||
lemmy_db_views_actor = { version = "=0.19.0-rc.5", path = "./crates/db_views_actor" }
|
||||
lemmy_db_views_moderator = { version = "=0.19.0-rc.5", path = "./crates/db_views_moderator" }
|
||||
lemmy_api = { version = "=0.19.0-rc.6", path = "./crates/api" }
|
||||
lemmy_api_crud = { version = "=0.19.0-rc.6", path = "./crates/api_crud" }
|
||||
lemmy_apub = { version = "=0.19.0-rc.6", path = "./crates/apub" }
|
||||
lemmy_utils = { version = "=0.19.0-rc.6", path = "./crates/utils" }
|
||||
lemmy_db_schema = { version = "=0.19.0-rc.6", path = "./crates/db_schema" }
|
||||
lemmy_api_common = { version = "=0.19.0-rc.6", path = "./crates/api_common" }
|
||||
lemmy_routes = { version = "=0.19.0-rc.6", path = "./crates/routes" }
|
||||
lemmy_db_views = { version = "=0.19.0-rc.6", path = "./crates/db_views" }
|
||||
lemmy_db_views_actor = { version = "=0.19.0-rc.6", path = "./crates/db_views_actor" }
|
||||
lemmy_db_views_moderator = { version = "=0.19.0-rc.6", path = "./crates/db_views_moderator" }
|
||||
activitypub_federation = { version = "0.5.0-beta.5", default-features = false, features = [
|
||||
"actix-web",
|
||||
] }
|
||||
@ -163,7 +163,7 @@ lemmy_utils = { workspace = true }
|
||||
lemmy_db_schema = { workspace = true }
|
||||
lemmy_api_common = { workspace = true }
|
||||
lemmy_routes = { workspace = true }
|
||||
lemmy_federate = { version = "0.19.0-rc.5", path = "crates/federate" }
|
||||
lemmy_federate = { version = "0.19.0-rc.6", path = "crates/federate" }
|
||||
activitypub_federation = { workspace = true }
|
||||
diesel = { workspace = true }
|
||||
diesel-async = { workspace = true }
|
||||
|
@ -16,6 +16,7 @@ fi
|
||||
./api_tests/pict-rs \
|
||||
run -a 0.0.0.0:8080 \
|
||||
--danger-dummy-mode \
|
||||
--api-key "my-pictrs-key" \
|
||||
filesystem -p /tmp/pictrs/files \
|
||||
sled -p /tmp/pictrs/sled-repo 2>&1 &
|
||||
|
||||
|
@ -230,10 +230,7 @@ test.skip("Remove a comment from admin and community on the same instance", asyn
|
||||
});
|
||||
|
||||
test("Remove a comment from admin and community on different instance", async () => {
|
||||
let alpha_user = await registerUser(alpha);
|
||||
let newAlphaApi = new LemmyHttp(alphaUrl, {
|
||||
headers: { Authorization: `Bearer ${alpha_user.jwt ?? ""}` },
|
||||
});
|
||||
let newAlphaApi = await registerUser(alpha, alphaUrl);
|
||||
|
||||
// New alpha user creates a community, post, and comment.
|
||||
let newCommunity = await createCommunity(newAlphaApi);
|
||||
|
@ -251,10 +251,7 @@ test("Admin actions in remote community are not federated to origin", async () =
|
||||
|
||||
test("moderator view", async () => {
|
||||
// register a new user with their own community on alpha and post to it
|
||||
let registerUserRes = await registerUser(alpha);
|
||||
let otherUser = new LemmyHttp(alphaUrl, {
|
||||
headers: { Authorization: `Bearer ${registerUserRes.jwt ?? ""}` },
|
||||
});
|
||||
let otherUser = await registerUser(alpha, alphaUrl);
|
||||
|
||||
let otherCommunity = (await createCommunity(otherUser)).community_view;
|
||||
expect(otherCommunity.community.name).toBeDefined();
|
||||
|
@ -1,6 +1,5 @@
|
||||
jest.setTimeout(120000);
|
||||
|
||||
import { LemmyHttp } from "lemmy-js-client";
|
||||
import {
|
||||
alpha,
|
||||
setupLogins,
|
||||
@ -10,8 +9,8 @@ import {
|
||||
getSite,
|
||||
waitUntil,
|
||||
beta,
|
||||
registerUser,
|
||||
betaUrl,
|
||||
registerUser,
|
||||
} from "./shared";
|
||||
|
||||
beforeAll(setupLogins);
|
||||
@ -21,11 +20,7 @@ afterAll(() => {
|
||||
});
|
||||
|
||||
test("Follow local community", async () => {
|
||||
let userRes = await registerUser(beta);
|
||||
expect(userRes.jwt).toBeDefined();
|
||||
let user = new LemmyHttp(betaUrl, {
|
||||
headers: { Authorization: `Bearer ${userRes.jwt ?? ""}` },
|
||||
});
|
||||
let user = await registerUser(beta, betaUrl);
|
||||
|
||||
let community = (await resolveBetaCommunity(user)).community!;
|
||||
expect(community.counts.subscribers).toBe(1);
|
||||
|
@ -1,7 +1,23 @@
|
||||
jest.setTimeout(120000);
|
||||
|
||||
import { UploadImage, DeleteImage } from "lemmy-js-client";
|
||||
import { alpha, setupLogins, unfollowRemotes } from "./shared";
|
||||
import {
|
||||
UploadImage,
|
||||
DeleteImage,
|
||||
PurgePerson,
|
||||
PurgePost,
|
||||
} from "lemmy-js-client";
|
||||
import {
|
||||
alpha,
|
||||
alphaUrl,
|
||||
beta,
|
||||
betaUrl,
|
||||
createPost,
|
||||
getSite,
|
||||
registerUser,
|
||||
resolveBetaCommunity,
|
||||
setupLogins,
|
||||
unfollowRemotes,
|
||||
} from "./shared";
|
||||
import fs = require("fs");
|
||||
const downloadFileSync = require("download-file-sync");
|
||||
|
||||
@ -18,7 +34,6 @@ test("Upload image and delete it", async () => {
|
||||
image: upload_image,
|
||||
};
|
||||
const upload = await alpha.uploadImage(upload_form);
|
||||
console.log(upload);
|
||||
expect(upload.files![0].file).toBeDefined();
|
||||
expect(upload.files![0].delete_token).toBeDefined();
|
||||
expect(upload.url).toBeDefined();
|
||||
@ -41,4 +56,71 @@ test("Upload image and delete it", async () => {
|
||||
expect(content2).toBe("");
|
||||
});
|
||||
|
||||
// TODO: add tests for image purging
|
||||
test("Purge user, uploaded image removed", async () => {
|
||||
let user = await registerUser(alpha, alphaUrl);
|
||||
|
||||
// upload test image
|
||||
const upload_image = fs.readFileSync("test.png");
|
||||
const upload_form: UploadImage = {
|
||||
image: upload_image,
|
||||
};
|
||||
const upload = await user.uploadImage(upload_form);
|
||||
expect(upload.files![0].file).toBeDefined();
|
||||
expect(upload.files![0].delete_token).toBeDefined();
|
||||
expect(upload.url).toBeDefined();
|
||||
expect(upload.delete_url).toBeDefined();
|
||||
|
||||
// ensure that image download is working. theres probably a better way to do this
|
||||
const content = downloadFileSync(upload.url);
|
||||
expect(content.length).toBeGreaterThan(0);
|
||||
|
||||
// purge user
|
||||
let site = await getSite(user);
|
||||
const purge_form: PurgePerson = {
|
||||
person_id: site.my_user!.local_user_view.person.id,
|
||||
};
|
||||
const delete_ = await alpha.purgePerson(purge_form);
|
||||
expect(delete_.success).toBe(true);
|
||||
|
||||
// ensure that image is deleted
|
||||
const content2 = downloadFileSync(upload.url);
|
||||
expect(content2).toBe("");
|
||||
});
|
||||
|
||||
test("Purge post, linked image removed", async () => {
|
||||
let user = await registerUser(beta, betaUrl);
|
||||
|
||||
// upload test image
|
||||
const upload_image = fs.readFileSync("test.png");
|
||||
const upload_form: UploadImage = {
|
||||
image: upload_image,
|
||||
};
|
||||
const upload = await user.uploadImage(upload_form);
|
||||
expect(upload.files![0].file).toBeDefined();
|
||||
expect(upload.files![0].delete_token).toBeDefined();
|
||||
expect(upload.url).toBeDefined();
|
||||
expect(upload.delete_url).toBeDefined();
|
||||
|
||||
// ensure that image download is working. theres probably a better way to do this
|
||||
const content = downloadFileSync(upload.url);
|
||||
expect(content.length).toBeGreaterThan(0);
|
||||
|
||||
let community = await resolveBetaCommunity(user);
|
||||
let post = await createPost(
|
||||
user,
|
||||
community.community!.community.id,
|
||||
upload.url,
|
||||
);
|
||||
expect(post.post_view.post.url).toBe(upload.url);
|
||||
|
||||
// purge post
|
||||
const purge_form: PurgePost = {
|
||||
post_id: post.post_view.post.id,
|
||||
};
|
||||
const delete_ = await beta.purgePost(purge_form);
|
||||
expect(delete_.success).toBe(true);
|
||||
|
||||
// ensure that image is deleted
|
||||
const content2 = downloadFileSync(upload.url);
|
||||
expect(content2).toBe("");
|
||||
});
|
||||
|
@ -390,11 +390,7 @@ test("Enforce site ban for federated user", async () => {
|
||||
throw "Missing beta community";
|
||||
}
|
||||
// create a test user
|
||||
let alphaUserJwt = await registerUser(alpha);
|
||||
expect(alphaUserJwt).toBeDefined();
|
||||
let alpha_user = new LemmyHttp(alphaUrl, {
|
||||
headers: { Authorization: `Bearer ${alphaUserJwt.jwt ?? ""}` },
|
||||
});
|
||||
let alpha_user = await registerUser(alpha, alphaUrl);
|
||||
let alphaUserPerson = (await getSite(alpha_user)).my_user?.local_user_view
|
||||
.person;
|
||||
let alphaUserActorId = alphaUserPerson?.actor_id;
|
||||
|
@ -196,12 +196,11 @@ export async function setupLogins() {
|
||||
export async function createPost(
|
||||
api: LemmyHttp,
|
||||
community_id: number,
|
||||
// use example.com for consistent title and embed description
|
||||
url: string = "https://example.com/",
|
||||
): Promise<PostResponse> {
|
||||
let name = randomString(5);
|
||||
let body = randomString(10);
|
||||
// switch from google.com to example.com for consistent title (embed_title and embed_description)
|
||||
// google switches description when a google doodle appears
|
||||
let url = "https://example.com/";
|
||||
let form: CreatePost = {
|
||||
name,
|
||||
url,
|
||||
@ -290,6 +289,7 @@ export async function searchPostLocal(
|
||||
q: post.name,
|
||||
type_: "Posts",
|
||||
sort: "TopAll",
|
||||
listing_type: "All",
|
||||
};
|
||||
return api.search(form);
|
||||
}
|
||||
@ -614,15 +614,22 @@ export async function deletePrivateMessage(
|
||||
|
||||
export async function registerUser(
|
||||
api: LemmyHttp,
|
||||
url: string,
|
||||
username: string = randomString(5),
|
||||
): Promise<LoginResponse> {
|
||||
): Promise<LemmyHttp> {
|
||||
let form: Register = {
|
||||
username,
|
||||
password,
|
||||
password_verify: password,
|
||||
show_nsfw: true,
|
||||
};
|
||||
return api.register(form);
|
||||
let login_response = await api.register(form);
|
||||
|
||||
expect(login_response.jwt).toBeDefined();
|
||||
let lemmy_http = new LemmyHttp(url, {
|
||||
headers: { Authorization: `Bearer ${login_response.jwt ?? ""}` },
|
||||
});
|
||||
return lemmy_http;
|
||||
}
|
||||
|
||||
export async function loginUser(
|
||||
|
@ -37,11 +37,7 @@ function assertUserFederation(userOne?: PersonView, userTwo?: PersonView) {
|
||||
}
|
||||
|
||||
test("Create user", async () => {
|
||||
let userRes = await registerUser(alpha);
|
||||
expect(userRes.jwt).toBeDefined();
|
||||
let user = new LemmyHttp(alphaUrl, {
|
||||
headers: { Authorization: `Bearer ${userRes.jwt ?? ""}` },
|
||||
});
|
||||
let user = await registerUser(alpha, alphaUrl);
|
||||
|
||||
let site = await getSite(user);
|
||||
expect(site.my_user).toBeDefined();
|
||||
@ -68,11 +64,7 @@ test("Set some user settings, check that they are federated", async () => {
|
||||
});
|
||||
|
||||
test("Delete user", async () => {
|
||||
let userRes = await registerUser(alpha);
|
||||
expect(userRes.jwt).toBeDefined();
|
||||
let user = new LemmyHttp(alphaUrl, {
|
||||
headers: { Authorization: `Bearer ${userRes.jwt ?? ""}` },
|
||||
});
|
||||
let user = await registerUser(alpha, alphaUrl);
|
||||
|
||||
// make a local post and comment
|
||||
let alphaCommunity = (await resolveCommunity(user, "!main@lemmy-alpha:8541"))
|
||||
@ -133,11 +125,7 @@ test("Requests with invalid auth should be treated as unauthenticated", async ()
|
||||
});
|
||||
|
||||
test("Create user with Arabic name", async () => {
|
||||
let userRes = await registerUser(alpha, "تجريب");
|
||||
expect(userRes.jwt).toBeDefined();
|
||||
let user = new LemmyHttp(alphaUrl, {
|
||||
headers: { Authorization: `Bearer ${userRes.jwt ?? ""}` },
|
||||
});
|
||||
let user = await registerUser(alpha, alphaUrl, "تجريب");
|
||||
|
||||
let site = await getSite(user);
|
||||
expect(site.my_user).toBeDefined();
|
||||
|
@ -344,7 +344,7 @@ fn queries<'a>() -> Queries<
|
||||
query = query.filter(post_aggregates::creator_id.eq(creator_id));
|
||||
}
|
||||
|
||||
if let (Some(listing_type), Some(person_id)) = (options.listing_type, person_id) {
|
||||
if let Some(person_id) = person_id {
|
||||
let is_subscribed = exists(
|
||||
community_follower::table.filter(
|
||||
post_aggregates::community_id
|
||||
@ -352,7 +352,7 @@ fn queries<'a>() -> Queries<
|
||||
.and(community_follower::person_id.eq(person_id)),
|
||||
),
|
||||
);
|
||||
match listing_type {
|
||||
match options.listing_type.unwrap_or_default() {
|
||||
ListingType::Subscribed => query = query.filter(is_subscribed),
|
||||
ListingType::Local => {
|
||||
query = query
|
||||
@ -370,6 +370,15 @@ fn queries<'a>() -> Queries<
|
||||
));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
match options.listing_type.unwrap_or_default() {
|
||||
ListingType::Local => {
|
||||
query = query
|
||||
.filter(community::local.eq(true))
|
||||
.filter(community::hidden.eq(false));
|
||||
}
|
||||
_ => query = query.filter(community::hidden.eq(false)),
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(url_search) = &options.url_search {
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 277e3c335bbb9c00c4a600bd4d655b273393f84a
|
||||
Subproject commit a36865ee8ca3658fea31ba948b67b75a812e84fc
|
@ -10,4 +10,7 @@
|
||||
database: {
|
||||
host: postgres_alpha
|
||||
}
|
||||
pictrs: {
|
||||
api_key: "my-pictrs-key"
|
||||
}
|
||||
}
|
||||
|
@ -10,4 +10,7 @@
|
||||
database: {
|
||||
host: postgres_beta
|
||||
}
|
||||
pictrs: {
|
||||
api_key: "my-pictrs-key"
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user