Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Combined modlog #5253

Merged
merged 101 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from 56 commits
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
39b3ec2
Combined tables try 2
dessalines Nov 26, 2024
1ff8ae0
Finishing up combined report table.
dessalines Nov 26, 2024
2351c7a
Fix ts optionals.
dessalines Nov 26, 2024
0ba961f
Adding tests, triggers, and history updates for report_combined.
dessalines Nov 27, 2024
d8dda44
Adding profile.
dessalines Nov 27, 2024
d68c0a6
Merge remote-tracking branch 'origin/main' into combined_tables_2
dessalines Nov 28, 2024
a9f28af
Merge remote-tracking branch 'origin/main' into combined_tables_2
dessalines Nov 28, 2024
3adadf9
Merge remote-tracking branch 'origin/main' into combined_tables_2
dessalines Nov 30, 2024
588e1f6
Add cursor pagination to report_combined view (#5244)
dullbananas Dec 2, 2024
f25d346
Merge branch 'combined_tables_2' of https://github.com/LemmyNet/lemmy…
dessalines Dec 2, 2024
7fdbb58
Fixing migration and paged API.
dessalines Dec 2, 2024
00beccd
Using dullbananas trigger procedure
dessalines Dec 2, 2024
1776de2
Removing pointless list routes, reorganizing tests.
dessalines Dec 2, 2024
612c2e9
Fixing column XOR check.
dessalines Dec 2, 2024
5a8b9de
Merge remote-tracking branch 'origin/main' into combined_tables_2
dessalines Dec 2, 2024
0c854d2
Forgot to remove list report actions.
dessalines Dec 2, 2024
802a8a6
Cleanup.
dessalines Dec 2, 2024
4674821
Merge remote-tracking branch 'origin/main' into combined_tables_2
dessalines Dec 2, 2024
91ca6d3
Merge branch 'main' into combined_tables_2
dessalines Dec 2, 2024
4cac67c
Use internal tagging.
dessalines Dec 2, 2024
83988cd
Merge branch 'combined_tables_2' of https://github.com/LemmyNet/lemmy…
dessalines Dec 2, 2024
82a14fc
Fixing api tests.
dessalines Dec 2, 2024
1f28407
Adding a few indexes.
dessalines Dec 2, 2024
34a440a
Fixing migration name.
dessalines Dec 2, 2024
1a739a1
Fixing unique constraints.
dessalines Dec 3, 2024
e1affa8
Merge remote-tracking branch 'origin/main' into combined_tables_2
dessalines Dec 4, 2024
921d532
Addressing PR comments.
dessalines Dec 4, 2024
724856d
Start working on profile combined
dessalines Dec 6, 2024
1053df1
Adding views and replaceable schema.
dessalines Dec 6, 2024
32b5411
A few changes to profile view.
dessalines Dec 7, 2024
3abc46f
Finishing up combined person_saved and person_content.
dessalines Dec 7, 2024
a940ce3
Merge remote-tracking branch 'origin/main' into combined_tables_2
dessalines Dec 7, 2024
67d72e3
Fixing api tests.
dessalines Dec 8, 2024
a4de41d
Merge branch 'combined_tables_2' into combined_profile
dessalines Dec 8, 2024
5d2b611
Moving to api-v4 routes.
dessalines Dec 8, 2024
a0f2966
Fixing imports.
dessalines Dec 8, 2024
165c7f4
Update crates/db_views/src/report_combined_view.rs
dessalines Dec 8, 2024
dc0ec15
Update crates/db_views/src/report_combined_view.rs
dessalines Dec 8, 2024
22d8697
Update crates/db_views/src/report_combined_view.rs
dessalines Dec 8, 2024
fa31fc3
Update migrations/2024-12-02-181601_add_report_combined_table/up.sql
dessalines Dec 8, 2024
10f5e37
Update migrations/2024-12-02-181601_add_report_combined_table/up.sql
dessalines Dec 8, 2024
02bd2f6
Fixing import and fmt.
dessalines Dec 8, 2024
40fead2
Merge branch 'combined_tables_2' into combined_profile
dessalines Dec 8, 2024
2d482b3
Fixing null types in postgres.
dessalines Dec 8, 2024
3e31e1c
Comment out err.
dessalines Dec 8, 2024
cf2b00e
Merge branch 'combined_tables_2' into combined_profile
dessalines Dec 8, 2024
58e62d5
Fixing TS issues.
dessalines Dec 8, 2024
15d1faa
Adding types, fixing allow and blocklist crud.
dessalines Dec 8, 2024
a8951ef
Starting to work on combined views.
dessalines Dec 9, 2024
a320f5a
Merge remote-tracking branch 'origin/main' into combined_profile
dessalines Dec 9, 2024
63b7f72
Using dullbananas trigger procedure
dessalines Dec 9, 2024
5c2205a
Merge remote-tracking branch 'origin/main' into combined_modlog
dessalines Dec 9, 2024
6363e7d
Merge branch 'combined_profile' into combined_modlog
dessalines Dec 9, 2024
9d36f1f
Adding the full combined view queries.
dessalines Dec 9, 2024
c157b8f
Adding tests.
dessalines Dec 10, 2024
cdd5f65
taplo fmt.
dessalines Dec 10, 2024
6318cac
Upgrading package.json deps.
dessalines Dec 10, 2024
b3b8efd
Updating pnpm
dessalines Dec 10, 2024
1e6b3fb
Merge remote-tracking branch 'origin/main' into combined_tables_2
dessalines Dec 12, 2024
c72d5e8
Addressing PR comments.
dessalines Dec 12, 2024
942da64
Merge remote-tracking branch 'origin/main' into combined_modlog
dessalines Dec 12, 2024
7c962d6
Removing serialization
dessalines Dec 13, 2024
ae9da4d
Merge remote-tracking branch 'origin/main' into combined_tables_2
dessalines Dec 13, 2024
af543cc
Merge branch 'combined_tables_2' into combined_profile
dessalines Dec 13, 2024
b4ce1d9
Removing serialization
dessalines Dec 13, 2024
154cea9
Merge remote-tracking branch 'origin/main' into combined_tables_2
dessalines Dec 19, 2024
0b514c5
Merge branch 'combined_tables_2' into combined_profile
dessalines Dec 19, 2024
a1792bb
Merge remote-tracking branch 'origin/main' into combined_profile
dessalines Dec 19, 2024
cfd302d
Fixing duped trigger.
dessalines Dec 19, 2024
9a0e050
Remove saved_only test.
dessalines Dec 19, 2024
776c500
Remove pointless post_tags types.
dessalines Dec 19, 2024
bd5210a
Merge remote-tracking branch 'origin/main' into combined_profile
dessalines Dec 23, 2024
8d856a0
Merge remote-tracking branch 'origin/main' into combined_profile
dessalines Dec 24, 2024
4bc4876
Remove pointless index.
dessalines Dec 24, 2024
918c5e8
Merge remote-tracking branch 'origin/main' into combined_profile
dessalines Jan 2, 2025
2244fd0
Changing published to saved for person_saved_combined.
dessalines Jan 2, 2025
b6d0ecf
Merge branch 'combined_profile' into combined_modlog
dessalines Jan 3, 2025
5cf0bb8
Merge remote-tracking branch 'origin/main' into combined_profile
dessalines Jan 3, 2025
b46fdab
Merge branch 'combined_profile' into combined_modlog
dessalines Jan 3, 2025
e5e11c1
Merge branch 'main' into combined_modlog
dessalines Jan 5, 2025
03e876b
Removing comment.
dessalines Jan 6, 2025
d27a634
Renaming modlog when_ columns to published.
dessalines Jan 8, 2025
be4a05e
Merge remote-tracking branch 'origin/main' into combined_modlog
dessalines Jan 8, 2025
15f1671
Adding strum and simplifying imports.
dessalines Jan 8, 2025
4317917
Avoiding clone in map_to_enum
dessalines Jan 8, 2025
0723ef2
Changing modded_person to other_person.
dessalines Jan 8, 2025
d64a086
Merge remote-tracking branch 'origin/main' into combined_modlog
dessalines Jan 10, 2025
9b561df
Update crates/db_views_moderator/src/modlog_combined_view.rs
dessalines Jan 10, 2025
d09616c
Update crates/db_views_moderator/src/modlog_combined_view.rs
dessalines Jan 10, 2025
b1d4e9c
Update crates/db_views_moderator/src/modlog_combined_view.rs
dessalines Jan 10, 2025
0a7d88f
Addressing PR comments.
dessalines Jan 10, 2025
46bbf2f
Merge branch 'combined_modlog' of https://github.com/LemmyNet/lemmy i…
dessalines Jan 10, 2025
4b71bc6
Fixing split.
dessalines Jan 10, 2025
45e312f
Revert "Adding strum and simplifying imports."
dessalines Jan 10, 2025
11e9514
Running fmt.
dessalines Jan 10, 2025
50043af
Merge remote-tracking branch 'origin/main' into combined_modlog
dessalines Jan 10, 2025
b021e4b
Merge remote-tracking branch 'origin/main' into combined_modlog
dessalines Jan 13, 2025
143da4b
Merge remote-tracking branch 'origin/main' into combined_modlog
dessalines Jan 13, 2025
c3a74f9
Using assert + matches instead of filter_map.
dessalines Jan 13, 2025
85d8810
Merge branch 'main' into combined_modlog
dessalines Jan 14, 2025
38f5f4e
Adding listPersonContent check.
dessalines Jan 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion api_tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"eslint": "^9.14.0",
"eslint-plugin-prettier": "^5.1.3",
"jest": "^29.5.0",
"lemmy-js-client": "0.20.0-api-v4.16",
"lemmy-js-client": "0.20.0-reports-combined.3",
"prettier": "^3.2.5",
"ts-jest": "^29.1.0",
"typescript": "^5.5.4",
Expand Down
10 changes: 5 additions & 5 deletions api_tests/pnpm-lock.yaml

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

37 changes: 28 additions & 9 deletions api_tests/src/comment.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {
createCommunity,
registerUser,
reportComment,
listCommentReports,
randomString,
unfollows,
getComments,
Expand All @@ -38,8 +37,15 @@ import {
blockCommunity,
delay,
saveUserSettings,
listReports,
} from "./shared";
import { CommentView, CommunityView, SaveUserSettings } from "lemmy-js-client";
import {
CommentReportView,
CommentView,
CommunityView,
ReportCombinedView,
SaveUserSettings,
} from "lemmy-js-client";

let betaCommunity: CommunityView | undefined;
let postOnAlphaRes: PostResponse;
Expand Down Expand Up @@ -796,13 +802,17 @@ test("Report a comment", async () => {
let alphaReport = (await reportComment(alpha, alphaComment.id, reason))
.comment_report_view.comment_report;

let betaReport = (await waitUntil(
() =>
listCommentReports(beta).then(r =>
r.comment_reports.find(rep => rep.comment_report.reason === reason),
),
e => !!e,
))!.comment_report;
let betaReport = (
(await waitUntil(
() =>
listReports(beta).then(p =>
p.reports.find(r => {
return checkCommentReportReason(r, reason);
}),
),
e => !!e,
)!) as CommentReportView
).comment_report;
expect(betaReport).toBeDefined();
expect(betaReport.resolved).toBe(false);
expect(betaReport.original_comment_text).toBe(
Expand Down Expand Up @@ -877,3 +887,12 @@ test.skip("Fetch a deeply nested comment", async () => {
expect(betaComment!.comment!.comment).toBeDefined();
expect(betaComment?.comment?.post).toBeDefined();
});

function checkCommentReportReason(rcv: ReportCombinedView, reason: string) {
switch (rcv.type_) {
case "Comment":
return rcv.comment_report.reason === reason;
default:
return false;
}
}
5 changes: 2 additions & 3 deletions api_tests/src/community.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
followCommunity,
banPersonFromCommunity,
resolvePerson,
getSite,
createPost,
getPost,
resolvePost,
Expand All @@ -36,7 +35,7 @@ import {
userBlockInstance,
} from "./shared";
import { AdminAllowInstanceParams } from "lemmy-js-client/dist/types/AdminAllowInstanceParams";
import { EditCommunity, EditSite, GetPosts } from "lemmy-js-client";
import { EditCommunity, GetPosts } from "lemmy-js-client";

beforeAll(setupLogins);
afterAll(unfollows);
Expand Down Expand Up @@ -573,7 +572,7 @@ test("Remote mods can edit communities", async () => {
communityRes.community_view.community.id,
);

await expect(alphaCommunity.community_view.community.description).toBe(
expect(alphaCommunity.community_view.community.description).toBe(
"Example description",
);
});
Expand Down
1 change: 0 additions & 1 deletion api_tests/src/follow.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
setupLogins,
resolveBetaCommunity,
followCommunity,
getSite,
waitUntil,
beta,
betaUrl,
Expand Down
1 change: 0 additions & 1 deletion api_tests/src/image.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
epsilon,
followCommunity,
gamma,
getSite,
imageFetchLimit,
registerUser,
resolveBetaCommunity,
Expand Down
66 changes: 45 additions & 21 deletions api_tests/src/post.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,27 @@ import {
followCommunity,
banPersonFromCommunity,
reportPost,
listPostReports,
randomString,
registerUser,
getSite,
unfollows,
resolveCommunity,
waitUntil,
waitForPost,
alphaUrl,
loginUser,
createCommunity,
listReports,
getMyUser,
} 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";
import {
EditSite,
PostReport,
PostReportView,
ReportCombinedView,
ResolveObject,
} from "lemmy-js-client";

let betaCommunity: CommunityView | undefined;

Expand Down Expand Up @@ -688,16 +693,17 @@ test("Report a post", async () => {
expect(gammaReport).toBeDefined();

// Report was federated to community instance
let betaReport = (await waitUntil(
() =>
listPostReports(beta).then(p =>
p.post_reports.find(
r =>
r.post_report.original_post_name === gammaReport.original_post_name,
let betaReport = (
(await waitUntil(
() =>
listReports(beta).then(p =>
p.reports.find(r => {
return checkReportName(r, gammaReport);
}),
),
),
res => !!res,
))!.post_report;
res => !!res,
))! as PostReportView
).post_report;
expect(betaReport).toBeDefined();
expect(betaReport.resolved).toBe(false);
expect(betaReport.original_post_name).toBe(gammaReport.original_post_name);
Expand All @@ -707,16 +713,25 @@ test("Report a post", async () => {
await unfollowRemotes(alpha);

// Report was federated to poster's instance
let alphaReport = (await waitUntil(
() =>
listPostReports(alpha).then(p =>
p.post_reports.find(
r =>
r.post_report.original_post_name === gammaReport.original_post_name,
let alphaReport = (
(await waitUntil(
() =>
listReports(alpha).then(p =>
p.reports.find(r => {
switch (r.type_) {
case "Post":
return (
r.post_report.original_post_name ===
gammaReport.original_post_name
);
default:
return false;
}
}),
),
),
res => !!res,
))!.post_report;
res => !!res,
))! as PostReportView
).post_report;
expect(alphaReport).toBeDefined();
expect(alphaReport.resolved).toBe(false);
expect(alphaReport.original_post_name).toBe(gammaReport.original_post_name);
Expand Down Expand Up @@ -817,3 +832,12 @@ test("Rewrite markdown links", async () => {
`[link](http://lemmy-alpha:8541/post/${alphaPost1.post?.post.id})`,
);
});

function checkReportName(rcv: ReportCombinedView, report: PostReport) {
switch (rcv.type_) {
case "Post":
return rcv.post_report.original_post_name === report.original_post_name;
default:
return false;
}
}
26 changes: 9 additions & 17 deletions api_tests/src/shared.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
AdminBlockInstanceParams,
ApproveCommunityPendingFollower,
BlockCommunity,
BlockCommunityResponse,
Expand All @@ -16,6 +15,8 @@ import {
LemmyHttp,
ListCommunityPendingFollows,
ListCommunityPendingFollowsResponse,
ListReports,
ListReportsResponse,
MyUserInfo,
PersonId,
PostView,
Expand Down Expand Up @@ -75,12 +76,8 @@ import { PrivateMessagesResponse } from "lemmy-js-client/dist/types/PrivateMessa
import { GetPrivateMessages } from "lemmy-js-client/dist/types/GetPrivateMessages";
import { PostReportResponse } from "lemmy-js-client/dist/types/PostReportResponse";
import { CreatePostReport } from "lemmy-js-client/dist/types/CreatePostReport";
import { ListPostReportsResponse } from "lemmy-js-client/dist/types/ListPostReportsResponse";
import { ListPostReports } from "lemmy-js-client/dist/types/ListPostReports";
import { CommentReportResponse } from "lemmy-js-client/dist/types/CommentReportResponse";
import { CreateCommentReport } from "lemmy-js-client/dist/types/CreateCommentReport";
import { ListCommentReportsResponse } from "lemmy-js-client/dist/types/ListCommentReportsResponse";
import { ListCommentReports } from "lemmy-js-client/dist/types/ListCommentReports";
import { GetPostsResponse } from "lemmy-js-client/dist/types/GetPostsResponse";
import { GetPosts } from "lemmy-js-client/dist/types/GetPosts";
import { GetPersonDetailsResponse } from "lemmy-js-client/dist/types/GetPersonDetailsResponse";
Expand Down Expand Up @@ -210,7 +207,9 @@ async function allowInstance(api: LemmyHttp, instance: string) {
// Ignore errors from duplicate allows (because setup gets called for each test file)
try {
await api.adminAllowInstance(params);
} catch {}
} catch (error) {
// console.error(error);
}
}

export async function createPost(
Expand Down Expand Up @@ -809,11 +808,11 @@ export async function reportPost(
return api.createPostReport(form);
}

export async function listPostReports(
export async function listReports(
api: LemmyHttp,
): Promise<ListPostReportsResponse> {
let form: ListPostReports = {};
return api.listPostReports(form);
): Promise<ListReportsResponse> {
let form: ListReports = {};
return api.listReports(form);
}

export async function reportComment(
Expand All @@ -840,13 +839,6 @@ export async function reportPrivateMessage(
return api.createPrivateMessageReport(form);
}

export async function listCommentReports(
api: LemmyHttp,
): Promise<ListCommentReportsResponse> {
let form: ListCommentReports = {};
return api.listCommentReports(form);
}

export function getPosts(
api: LemmyHttp,
listingType?: ListingType,
Expand Down
5 changes: 1 addition & 4 deletions crates/api/src/comment/save.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ pub async fn save_comment(
context: Data<LemmyContext>,
local_user_view: LocalUserView,
) -> LemmyResult<Json<CommentResponse>> {
let comment_saved_form = CommentSavedForm {
comment_id: data.comment_id,
person_id: local_user_view.person.id,
};
let comment_saved_form = CommentSavedForm::new(data.comment_id, local_user_view.person.id);

if data.save {
CommentSaved::save(&mut context.pool(), &comment_saved_form)
Expand Down
37 changes: 0 additions & 37 deletions crates/api/src/comment_report/list.rs

This file was deleted.

Loading