Skip to content

Commit

Permalink
Merge branch 'LemmyNet:main' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
kroese authored Nov 6, 2024
2 parents 104f71d + 917e408 commit 0e49e34
Show file tree
Hide file tree
Showing 49 changed files with 634 additions and 88 deletions.
13 changes: 10 additions & 3 deletions .woodpecker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ steps:
environment:
CARGO_HOME: .cargo_home
commands:
- export LEMMY_CONFIG_LOCATION=./config/config.hjson
- ./scripts/update_config_defaults.sh config/defaults_current.hjson
- diff config/defaults.hjson config/defaults_current.hjson
when: *slow_check_paths
Expand All @@ -147,7 +146,6 @@ steps:
CARGO_HOME: .cargo_home
commands:
# same as scripts/db_perf.sh but without creating a new database server
- export LEMMY_CONFIG_LOCATION=config/config.hjson
- cargo run --package lemmy_db_perf -- --posts 10 --read-post-pages 1
when: *slow_check_paths

Expand Down Expand Up @@ -176,11 +174,20 @@ steps:
RUST_BACKTRACE: "1"
CARGO_HOME: .cargo_home
LEMMY_TEST_FAST_FEDERATION: "1"
LEMMY_CONFIG_LOCATION: ../../config/config.hjson
commands:
- export LEMMY_CONFIG_LOCATION=../../config/config.hjson
- cargo test --workspace --no-fail-fast
when: *slow_check_paths

check_ts_bindings:
image: *rust_image
environment:
CARGO_HOME: .cargo_home
commands:
- ./scripts/ts_bindings_check.sh
when:
- event: pull_request

check_diesel_migration:
# TODO: use willsquire/diesel-cli image when shared libraries become optional in lemmy_server
image: *rust_image
Expand Down
17 changes: 6 additions & 11 deletions Cargo.lock

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

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ doctest = false
[lints]
workspace = true

# See https://github.com/johnthagen/min-sized-rust for additional optimizations
[profile.release]
debug = 0
lto = "fat"
strip = true # Automatically strip symbols from the binary.
opt-level = 3 # Optimize for speed, not size.
codegen-units = 1 # Reduce parallel code generation.

Expand Down Expand Up @@ -142,10 +142,11 @@ itertools = "0.13.0"
futures = "0.3.30"
http = "1.1"
rosetta-i18n = "0.1.3"
ts-rs = { version = "7.1.1", features = [
ts-rs = { version = "10.0.0", features = [
"serde-compat",
"chrono-impl",
"no-serde-warnings",
"url-impl",
] }
rustls = { version = "0.23.12", features = ["ring"] }
futures-util = "0.3.30"
Expand Down
2 changes: 1 addition & 1 deletion api_tests/src/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export const fetchFunction = fetch;
export const imageFetchLimit = 50;
export const sampleImage =
"https://i.pinimg.com/originals/df/5f/5b/df5f5b1b174a2b4b6026cc6c8f9395c1.jpg";
export const sampleSite = "https://yahoo.com";
export const sampleSite = "https://w3.org";

export const alphaUrl = "http://127.0.0.1:8541";
export const betaUrl = "http://127.0.0.1:8551";
Expand Down
24 changes: 24 additions & 0 deletions crates/api_common/src/comment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ use ts_rs::TS;
pub struct CreateComment {
pub content: String,
pub post_id: PostId,
#[cfg_attr(feature = "full", ts(optional))]
pub parent_id: Option<CommentId>,
#[cfg_attr(feature = "full", ts(optional))]
pub language_id: Option<LanguageId>,
}

Expand All @@ -37,7 +39,9 @@ pub struct GetComment {
/// Edit a comment.
pub struct EditComment {
pub comment_id: CommentId,
#[cfg_attr(feature = "full", ts(optional))]
pub content: Option<String>,
#[cfg_attr(feature = "full", ts(optional))]
pub language_id: Option<LanguageId>,
}

Expand Down Expand Up @@ -69,6 +73,7 @@ pub struct DeleteComment {
pub struct RemoveComment {
pub comment_id: CommentId,
pub removed: bool,
#[cfg_attr(feature = "full", ts(optional))]
pub reason: Option<String>,
}

Expand Down Expand Up @@ -107,17 +112,29 @@ pub struct CreateCommentLike {
#[cfg_attr(feature = "full", ts(export))]
/// Get a list of comments.
pub struct GetComments {
#[cfg_attr(feature = "full", ts(optional))]
pub type_: Option<ListingType>,
#[cfg_attr(feature = "full", ts(optional))]
pub sort: Option<CommentSortType>,
#[cfg_attr(feature = "full", ts(optional))]
pub max_depth: Option<i32>,
#[cfg_attr(feature = "full", ts(optional))]
pub page: Option<i64>,
#[cfg_attr(feature = "full", ts(optional))]
pub limit: Option<i64>,
#[cfg_attr(feature = "full", ts(optional))]
pub community_id: Option<CommunityId>,
#[cfg_attr(feature = "full", ts(optional))]
pub community_name: Option<String>,
#[cfg_attr(feature = "full", ts(optional))]
pub post_id: Option<PostId>,
#[cfg_attr(feature = "full", ts(optional))]
pub parent_id: Option<CommentId>,
#[cfg_attr(feature = "full", ts(optional))]
pub saved_only: Option<bool>,
#[cfg_attr(feature = "full", ts(optional))]
pub liked_only: Option<bool>,
#[cfg_attr(feature = "full", ts(optional))]
pub disliked_only: Option<bool>,
}

Expand Down Expand Up @@ -161,12 +178,17 @@ pub struct ResolveCommentReport {
#[cfg_attr(feature = "full", ts(export))]
/// List comment reports.
pub struct ListCommentReports {
#[cfg_attr(feature = "full", ts(optional))]
pub comment_id: Option<CommentId>,
#[cfg_attr(feature = "full", ts(optional))]
pub page: Option<i64>,
#[cfg_attr(feature = "full", ts(optional))]
pub limit: Option<i64>,
/// Only shows the unresolved reports
#[cfg_attr(feature = "full", ts(optional))]
pub unresolved_only: Option<bool>,
/// if no community is given, it returns reports for all communities moderated by the auth user
#[cfg_attr(feature = "full", ts(optional))]
pub community_id: Option<CommunityId>,
}

Expand All @@ -185,7 +207,9 @@ pub struct ListCommentReportsResponse {
/// List comment likes. Admins-only.
pub struct ListCommentLikes {
pub comment_id: CommentId,
#[cfg_attr(feature = "full", ts(optional))]
pub page: Option<i64>,
#[cfg_attr(feature = "full", ts(optional))]
pub limit: Option<i64>,
}

Expand Down
32 changes: 32 additions & 0 deletions crates/api_common/src/community.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ use ts_rs::TS;
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "full", derive(TS))]
#[cfg_attr(feature = "full", ts(export))]
// TODO make this into a tagged enum
/// Get a community. Must provide either an id, or a name.
pub struct GetCommunity {
#[cfg_attr(feature = "full", ts(optional))]
pub id: Option<CommunityId>,
/// Example: star_trek , or [email protected]
#[cfg_attr(feature = "full", ts(optional))]
pub name: Option<String>,
}

Expand All @@ -33,6 +36,7 @@ pub struct GetCommunity {
/// The community response.
pub struct GetCommunityResponse {
pub community_view: CommunityView,
#[cfg_attr(feature = "full", ts(optional))]
pub site: Option<Site>,
pub moderators: Vec<CommunityModeratorView>,
pub discussion_languages: Vec<LanguageId>,
Expand All @@ -49,18 +53,26 @@ pub struct CreateCommunity {
/// A longer title.
pub title: String,
/// A sidebar for the community in markdown.
#[cfg_attr(feature = "full", ts(optional))]
pub sidebar: Option<String>,
/// A shorter, one line description of your community.
#[cfg_attr(feature = "full", ts(optional))]
pub description: Option<String>,
/// An icon URL.
#[cfg_attr(feature = "full", ts(optional))]
pub icon: Option<String>,
/// A banner URL.
#[cfg_attr(feature = "full", ts(optional))]
pub banner: Option<String>,
/// Whether its an NSFW community.
#[cfg_attr(feature = "full", ts(optional))]
pub nsfw: Option<bool>,
/// Whether to restrict posting only to moderators.
#[cfg_attr(feature = "full", ts(optional))]
pub posting_restricted_to_mods: Option<bool>,
#[cfg_attr(feature = "full", ts(optional))]
pub discussion_languages: Option<Vec<LanguageId>>,
#[cfg_attr(feature = "full", ts(optional))]
pub visibility: Option<CommunityVisibility>,
}

Expand All @@ -79,10 +91,15 @@ pub struct CommunityResponse {
#[cfg_attr(feature = "full", ts(export))]
/// Fetches a list of communities.
pub struct ListCommunities {
#[cfg_attr(feature = "full", ts(optional))]
pub type_: Option<ListingType>,
#[cfg_attr(feature = "full", ts(optional))]
pub sort: Option<CommunitySortType>,
#[cfg_attr(feature = "full", ts(optional))]
pub show_nsfw: Option<bool>,
#[cfg_attr(feature = "full", ts(optional))]
pub page: Option<i64>,
#[cfg_attr(feature = "full", ts(optional))]
pub limit: Option<i64>,
}

Expand All @@ -105,11 +122,14 @@ pub struct BanFromCommunity {
pub ban: bool,
/// Optionally remove or restore all their data. Useful for new troll accounts.
/// If ban is true, then this means remove. If ban is false, it means restore.
#[cfg_attr(feature = "full", ts(optional))]
pub remove_or_restore_data: Option<bool>,
#[cfg_attr(feature = "full", ts(optional))]
pub reason: Option<String>,
/// A time that the ban will expire, in unix epoch seconds.
///
/// An i64 unix timestamp is used for a simpler API client implementation.
#[cfg_attr(feature = "full", ts(optional))]
pub expires: Option<i64>,
}

Expand Down Expand Up @@ -148,20 +168,29 @@ pub struct AddModToCommunityResponse {
pub struct EditCommunity {
pub community_id: CommunityId,
/// A longer title.
#[cfg_attr(feature = "full", ts(optional))]
pub title: Option<String>,
/// A sidebar for the community in markdown.
#[cfg_attr(feature = "full", ts(optional))]
pub sidebar: Option<String>,
/// A shorter, one line description of your community.
#[cfg_attr(feature = "full", ts(optional))]
pub description: Option<String>,
/// An icon URL.
#[cfg_attr(feature = "full", ts(optional))]
pub icon: Option<String>,
/// A banner URL.
#[cfg_attr(feature = "full", ts(optional))]
pub banner: Option<String>,
/// Whether its an NSFW community.
#[cfg_attr(feature = "full", ts(optional))]
pub nsfw: Option<bool>,
/// Whether to restrict posting only to moderators.
#[cfg_attr(feature = "full", ts(optional))]
pub posting_restricted_to_mods: Option<bool>,
#[cfg_attr(feature = "full", ts(optional))]
pub discussion_languages: Option<Vec<LanguageId>>,
#[cfg_attr(feature = "full", ts(optional))]
pub visibility: Option<CommunityVisibility>,
}

Expand All @@ -173,6 +202,7 @@ pub struct EditCommunity {
pub struct HideCommunity {
pub community_id: CommunityId,
pub hidden: bool,
#[cfg_attr(feature = "full", ts(optional))]
pub reason: Option<String>,
}

Expand All @@ -194,6 +224,7 @@ pub struct DeleteCommunity {
pub struct RemoveCommunity {
pub community_id: CommunityId,
pub removed: bool,
#[cfg_attr(feature = "full", ts(optional))]
pub reason: Option<String>,
}

Expand Down Expand Up @@ -240,5 +271,6 @@ pub struct TransferCommunity {
#[cfg_attr(feature = "full", ts(export))]
/// Fetches a random community
pub struct GetRandomCommunity {
#[cfg_attr(feature = "full", ts(optional))]
pub type_: Option<ListingType>,
}
4 changes: 4 additions & 0 deletions crates/api_common/src/custom_emoji.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,12 @@ pub struct ListCustomEmojisResponse {
#[cfg_attr(feature = "full", ts(export))]
/// Fetches a list of custom emojis.
pub struct ListCustomEmojis {
#[cfg_attr(feature = "full", ts(optional))]
pub page: Option<i64>,
#[cfg_attr(feature = "full", ts(optional))]
pub limit: Option<i64>,
#[cfg_attr(feature = "full", ts(optional))]
pub category: Option<String>,
#[cfg_attr(feature = "full", ts(optional))]
pub ignore_page_limits: Option<bool>,
}
Loading

0 comments on commit 0e49e34

Please sign in to comment.