Skip to content

Commit

Permalink
Merge pull request #277 from LemmyNet/main
Browse files Browse the repository at this point in the history
[pull] master from LemmyNet:main
  • Loading branch information
pull[bot] authored Feb 14, 2025
2 parents 35f5248 + d1eff90 commit b5e41b4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
22 changes: 15 additions & 7 deletions src/api_routes_v3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,13 @@ pub fn config(cfg: &mut ServiceConfig, rate_limit: &RateLimitCell) {
.wrap(rate_limit.image())
.route(post().to(upload_image)),
)
.service(resource("/pictrs/image/{filename}").route(get().to(get_image)))
.service(resource("/pictrs/image/delete/{token}/{filename}").route(get().to(delete_image)))
.service(resource("/pictrs/healthz").route(get().to(pictrs_health)))
.service(
scope("/pictrs")
.wrap(rate_limit.message())
.route("/image/{filename}", get().to(get_image))
.route("/image/delete/{token}/{filename}", get().to(delete_image))
.route("/healthz", get().to(pictrs_health)),
)
.service(
scope("/api/v3")
.route("/image_proxy", get().to(image_proxy))
Expand All @@ -165,7 +169,7 @@ pub fn config(cfg: &mut ServiceConfig, rate_limit: &RateLimitCell) {
)
.service(
resource("/resolve_object")
.wrap(rate_limit.message())
.wrap(rate_limit.search())
.route(get().to(resolve_object)),
)
// Community
Expand Down Expand Up @@ -198,12 +202,17 @@ pub fn config(cfg: &mut ServiceConfig, rate_limit: &RateLimitCell) {
)
// Post
.service(
// Handle POST to /post separately to add the post() rate limitter
resource("/post")
// Handle POST to /post separately to add the post() rate limitter
.guard(guard::Post())
.wrap(rate_limit.post())
.route(post().to(create_post)),
)
.service(
resource("/post/site_metadata")
.wrap(rate_limit.search())
.route(get().to(get_link_metadata)),
)
.service(
scope("/post")
.wrap(rate_limit.message())
Expand All @@ -220,8 +229,7 @@ pub fn config(cfg: &mut ServiceConfig, rate_limit: &RateLimitCell) {
.route("/like/list", get().to(list_post_likes))
.route("/save", put().to(save_post))
.route("/report", post().to(create_post_report))
.route("/report/resolve", put().to(resolve_post_report))
.route("/site_metadata", get().to(get_link_metadata)),
.route("/report/resolve", put().to(resolve_post_report)),
)
// Comment
.service(
Expand Down
16 changes: 12 additions & 4 deletions src/api_routes_v4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,11 @@ pub fn config(cfg: &mut ServiceConfig, rate_limit: &RateLimitCell) {
.wrap(rate_limit.search())
.route(get().to(search)),
)
.route("/resolve_object", get().to(resolve_object))
.service(
resource("/resolve_object")
.wrap(rate_limit.search())
.route(get().to(resolve_object)),
)
// Community
.service(
resource("/community")
Expand Down Expand Up @@ -233,12 +237,17 @@ pub fn config(cfg: &mut ServiceConfig, rate_limit: &RateLimitCell) {
.route("/federated_instances", get().to(get_federated_instances))
// Post
.service(
// Handle POST to /post separately to add the post() rate limitter
resource("/post")
// Handle POST to /post separately to add the post() rate limitter
.guard(guard::Post())
.wrap(rate_limit.post())
.route(post().to(create_post)),
)
.service(
resource("/post/site_metadata")
.wrap(rate_limit.search())
.route(get().to(get_link_metadata)),
)
.service(
scope("/post")
.route("", get().to(get_post))
Expand All @@ -255,8 +264,7 @@ pub fn config(cfg: &mut ServiceConfig, rate_limit: &RateLimitCell) {
.route("/like/list", get().to(list_post_likes))
.route("/save", put().to(save_post))
.route("/report", post().to(create_post_report))
.route("/report/resolve", put().to(resolve_post_report))
.route("/site_metadata", get().to(get_link_metadata)),
.route("/report/resolve", put().to(resolve_post_report)),
)
// Comment
.service(
Expand Down

0 comments on commit b5e41b4

Please sign in to comment.