Skip to content

Commit

Permalink
Merge branch 'main' into ci-faster-sql-fmt2
Browse files Browse the repository at this point in the history
  • Loading branch information
Nutomic authored Dec 19, 2023
2 parents abfd72e + a507a39 commit f8f4f87
Show file tree
Hide file tree
Showing 33 changed files with 897 additions and 840 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ query_testing/**/reports/*.json
api_tests/node_modules
api_tests/.yalc
api_tests/yalc.lock
api_tests/test.png
api_tests/pict-rs

# pictrs data
Expand Down
3 changes: 2 additions & 1 deletion .woodpecker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ variables:
- &slow_check_paths
- path:
# rust source code
- "**/*.rs"
- "crates/**"
- "src/**"
- "**/Cargo.toml"
- "Cargo.lock"
# database migrations
Expand Down
25 changes: 13 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 12 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace.package]
version = "0.19.0-rc.14"
version = "0.19.1-rc.1"
edition = "2021"
description = "A link aggregator for the fediverse"
license = "AGPL-3.0"
Expand Down Expand Up @@ -84,16 +84,16 @@ unused_self = "deny"
unwrap_used = "deny"

[workspace.dependencies]
lemmy_api = { version = "=0.19.0-rc.14", path = "./crates/api" }
lemmy_api_crud = { version = "=0.19.0-rc.14", path = "./crates/api_crud" }
lemmy_apub = { version = "=0.19.0-rc.14", path = "./crates/apub" }
lemmy_utils = { version = "=0.19.0-rc.14", path = "./crates/utils" }
lemmy_db_schema = { version = "=0.19.0-rc.14", path = "./crates/db_schema" }
lemmy_api_common = { version = "=0.19.0-rc.14", path = "./crates/api_common" }
lemmy_routes = { version = "=0.19.0-rc.14", path = "./crates/routes" }
lemmy_db_views = { version = "=0.19.0-rc.14", path = "./crates/db_views" }
lemmy_db_views_actor = { version = "=0.19.0-rc.14", path = "./crates/db_views_actor" }
lemmy_db_views_moderator = { version = "=0.19.0-rc.14", path = "./crates/db_views_moderator" }
lemmy_api = { version = "=0.19.1-rc.1", path = "./crates/api" }
lemmy_api_crud = { version = "=0.19.1-rc.1", path = "./crates/api_crud" }
lemmy_apub = { version = "=0.19.1-rc.1", path = "./crates/apub" }
lemmy_utils = { version = "=0.19.1-rc.1", path = "./crates/utils" }
lemmy_db_schema = { version = "=0.19.1-rc.1", path = "./crates/db_schema" }
lemmy_api_common = { version = "=0.19.1-rc.1", path = "./crates/api_common" }
lemmy_routes = { version = "=0.19.1-rc.1", path = "./crates/routes" }
lemmy_db_views = { version = "=0.19.1-rc.1", path = "./crates/db_views" }
lemmy_db_views_actor = { version = "=0.19.1-rc.1", path = "./crates/db_views_actor" }
lemmy_db_views_moderator = { version = "=0.19.1-rc.1", path = "./crates/db_views_moderator" }
activitypub_federation = { version = "0.5.0-beta.6", default-features = false, features = [
"actix-web",
] }
Expand Down Expand Up @@ -164,7 +164,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.14", path = "crates/federate" }
lemmy_federate = { version = "0.19.1-rc.1", path = "crates/federate" }
activitypub_federation = { workspace = true }
diesel = { workspace = true }
diesel-async = { workspace = true }
Expand Down
16 changes: 8 additions & 8 deletions api_tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@
"api-test-image": "jest -i image.spec.ts"
},
"devDependencies": {
"@types/jest": "^29.5.10",
"@types/node": "^20.9.4",
"@typescript-eslint/eslint-plugin": "^6.12.0",
"@typescript-eslint/parser": "^6.12.0",
"@types/jest": "^29.5.11",
"@types/node": "^20.10.4",
"@typescript-eslint/eslint-plugin": "^6.14.0",
"@typescript-eslint/parser": "^6.14.0",
"download-file-sync": "^1.0.4",
"eslint": "^8.54.0",
"eslint": "^8.55.0",
"eslint-plugin-prettier": "^5.0.1",
"jest": "^29.5.0",
"lemmy-js-client": "0.19.0-rc.19",
"prettier": "^3.1.0",
"lemmy-js-client": "0.19.0",
"prettier": "^3.1.1",
"ts-jest": "^29.1.0",
"typescript": "^5.3.2"
"typescript": "^5.3.3"
}
}
2 changes: 1 addition & 1 deletion api_tests/prepare-drone-federation-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export RUST_LOG="warn,lemmy_server=debug,lemmy_federate=debug,lemmy_api=debug,le
export LEMMY_TEST_FAST_FEDERATION=1 # by default, the persistent federation queue has delays in the scale of 30s-5min

# pictrs setup
if ! [ -f "pict-rs" ]; then
if [ ! -f "pict-rs" ]; then
curl "https://git.asonix.dog/asonix/pict-rs/releases/download/v0.5.0-beta.2/pict-rs-linux-amd64" -o api_tests/pict-rs
chmod +x api_tests/pict-rs
fi
Expand Down
18 changes: 15 additions & 3 deletions api_tests/src/comment.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,17 +344,26 @@ test("Federated comment like", async () => {
test("Reply to a comment from another instance, get notification", async () => {
await alpha.markAllAsRead();

let betaCommunity = (await resolveBetaCommunity(alpha)).community;
let betaCommunity = (
await waitUntil(
() => resolveBetaCommunity(alpha),
c => !!c.community?.community.instance_id,
)
).community;
if (!betaCommunity) {
throw "Missing beta community";
}

const postOnAlphaRes = await createPost(alpha, betaCommunity.community.id);

// Create a root-level trunk-branch comment on alpha
let commentRes = await createComment(alpha, postOnAlphaRes.post_view.post.id);
// find that comment id on beta
let betaComment = (
await resolveComment(beta, commentRes.comment_view.comment)
await waitUntil(
() => resolveComment(beta, commentRes.comment_view.comment),
c => c.comment?.counts.score === 1,
)
).comment;

if (!betaComment) {
Expand Down Expand Up @@ -405,7 +414,10 @@ test("Reply to a comment from another instance, get notification", async () => {
expect(alphaUnreadCountRes.replies).toBeGreaterThanOrEqual(1);

// check inbox of replies on alpha, fetching read/unread both
let alphaRepliesRes = await getReplies(alpha);
let alphaRepliesRes = await waitUntil(
() => getReplies(alpha),
r => r.replies.length > 0,
);
const alphaReply = alphaRepliesRes.replies.find(
r => r.comment.id === alphaComment.comment.id,
);
Expand Down
2 changes: 1 addition & 1 deletion api_tests/src/community.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ test("Admin actions in remote community are not federated to origin", async () =
expect(gammaPost2.post_view.creator_banned_from_community).toBe(false);
});

test.only("moderator view", async () => {
test("moderator view", async () => {
// register a new user with their own community on alpha and post to it
let otherUser = await registerUser(alpha, alphaUrl);

Expand Down
40 changes: 40 additions & 0 deletions api_tests/src/private_message.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
deletePrivateMessage,
unfollowRemotes,
waitUntil,
reportPrivateMessage,
} from "./shared";

let recipient_id: number;
Expand Down Expand Up @@ -109,3 +110,42 @@ test("Delete a private message", async () => {
betaPms1.private_messages.length,
);
});

test("Create a private message report", async () => {
let pmRes = await createPrivateMessage(alpha, recipient_id);
let betaPms1 = await waitUntil(
() => listPrivateMessages(beta),
m =>
!!m.private_messages.find(
e =>
e.private_message.ap_id ===
pmRes.private_message_view.private_message.ap_id,
),
);
let betaPm = betaPms1.private_messages[0];
expect(betaPm).toBeDefined();

// Make sure that only the recipient can report it, so this should fail
await expect(
reportPrivateMessage(
alpha,
pmRes.private_message_view.private_message.id,
"a reason",
),
).rejects.toStrictEqual(Error("couldnt_create_report"));

// This one should pass
let reason = "another reason";
let report = await reportPrivateMessage(
beta,
betaPm.private_message.id,
reason,
);

expect(report.private_message_report_view.private_message.id).toBe(
betaPm.private_message.id,
);
expect(report.private_message_report_view.private_message_report.reason).toBe(
reason,
);
});
15 changes: 15 additions & 0 deletions api_tests/src/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import {
BlockInstance,
BlockInstanceResponse,
CommunityId,
CreatePrivateMessageReport,
GetReplies,
GetRepliesResponse,
GetUnreadCountResponse,
InstanceId,
LemmyHttp,
PostView,
PrivateMessageReportResponse,
SuccessResponse,
} from "lemmy-js-client";
import { CreatePost } from "lemmy-js-client/dist/types/CreatePost";
Expand Down Expand Up @@ -781,6 +783,18 @@ export async function reportComment(
return api.createCommentReport(form);
}

export async function reportPrivateMessage(
api: LemmyHttp,
private_message_id: number,
reason: string,
): Promise<PrivateMessageReportResponse> {
let form: CreatePrivateMessageReport = {
private_message_id,
reason,
};
return api.createPrivateMessageReport(form);
}

export async function listCommentReports(
api: LemmyHttp,
): Promise<ListCommentReportsResponse> {
Expand Down Expand Up @@ -863,6 +877,7 @@ export function getCommentParentId(comment: Comment): number | undefined {
if (split.length > 1) {
return Number(split[split.length - 2]);
} else {
console.log(`Failed to extract comment parent id from ${comment.path}`);
return undefined;
}
}
Expand Down
Loading

0 comments on commit f8f4f87

Please sign in to comment.