mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-12-22 19:01:32 +00:00
Rearrange comments somewhat
This commit is contained in:
parent
d9905824eb
commit
a5ac8eca3d
4 changed files with 46 additions and 45 deletions
|
@ -1,5 +1,5 @@
|
|||
use activitypub_federation::config::Data;
|
||||
use actix_web::web::Json;
|
||||
use actix_web::web::{Json, Path};
|
||||
use lemmy_api_common::{
|
||||
build_response::{build_comment_response, send_local_notifs},
|
||||
comment::{CommentResponse, DeleteComment},
|
||||
|
@ -8,6 +8,7 @@ use lemmy_api_common::{
|
|||
utils::check_community_user_action,
|
||||
};
|
||||
use lemmy_db_schema::{
|
||||
newtypes::CommentId,
|
||||
source::comment::{Comment, CommentUpdateForm},
|
||||
traits::Crud,
|
||||
};
|
||||
|
@ -19,8 +20,9 @@ pub async fn delete_comment(
|
|||
data: Json<DeleteComment>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
path: Path<CommentId>,
|
||||
) -> LemmyResult<Json<CommentResponse>> {
|
||||
let comment_id = data.comment_id;
|
||||
let comment_id = path.into_inner();
|
||||
let orig_comment = CommentView::read(
|
||||
&mut context.pool(),
|
||||
comment_id,
|
||||
|
@ -67,7 +69,6 @@ pub async fn delete_comment(
|
|||
Some(&local_user_view),
|
||||
)
|
||||
.await?;
|
||||
let updated_comment_id = updated_comment.id;
|
||||
|
||||
ActivityChannel::submit_activity(
|
||||
SendActivityData::DeleteComment(
|
||||
|
@ -79,12 +80,6 @@ pub async fn delete_comment(
|
|||
)?;
|
||||
|
||||
Ok(Json(
|
||||
build_comment_response(
|
||||
&context,
|
||||
updated_comment_id,
|
||||
Some(local_user_view),
|
||||
recipient_ids,
|
||||
)
|
||||
.await?,
|
||||
build_comment_response(&context, comment_id, Some(local_user_view), recipient_ids).await?,
|
||||
))
|
||||
}
|
||||
|
|
|
@ -1,25 +1,24 @@
|
|||
use actix_web::web::{Data, Json, Query};
|
||||
use actix_web::web::{Data, Json, Path};
|
||||
use lemmy_api_common::{
|
||||
build_response::build_comment_response,
|
||||
comment::{CommentResponse, GetComment},
|
||||
context::LemmyContext,
|
||||
build_response::build_comment_response, comment::CommentResponse, context::LemmyContext,
|
||||
utils::check_private_instance,
|
||||
};
|
||||
use lemmy_db_schema::source::local_site::LocalSite;
|
||||
use lemmy_db_schema::{newtypes::CommentId, source::local_site::LocalSite};
|
||||
use lemmy_db_views::structs::LocalUserView;
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
|
||||
#[tracing::instrument(skip(context))]
|
||||
pub async fn get_comment(
|
||||
data: Query<GetComment>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: Option<LocalUserView>,
|
||||
path: Path<CommentId>,
|
||||
) -> LemmyResult<Json<CommentResponse>> {
|
||||
let id = path.into_inner();
|
||||
let local_site = LocalSite::read(&mut context.pool()).await?;
|
||||
|
||||
check_private_instance(&local_user_view, &local_site)?;
|
||||
|
||||
Ok(Json(
|
||||
build_comment_response(&context, data.id, local_user_view, vec![]).await?,
|
||||
build_comment_response(&context, id, local_user_view, vec![]).await?,
|
||||
))
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use activitypub_federation::config::Data;
|
||||
use actix_web::web::Json;
|
||||
use actix_web::web::{Json, Path};
|
||||
use chrono::Utc;
|
||||
use lemmy_api_common::{
|
||||
build_response::{build_comment_response, send_local_notifs},
|
||||
|
@ -7,14 +7,12 @@ use lemmy_api_common::{
|
|||
context::LemmyContext,
|
||||
send_activity::{ActivityChannel, SendActivityData},
|
||||
utils::{
|
||||
check_community_user_action,
|
||||
get_url_blocklist,
|
||||
local_site_to_slur_regex,
|
||||
process_markdown_opt,
|
||||
check_community_user_action, get_url_blocklist, local_site_to_slur_regex, process_markdown_opt,
|
||||
},
|
||||
};
|
||||
use lemmy_db_schema::{
|
||||
impls::actor_language::validate_post_language,
|
||||
newtypes::CommentId,
|
||||
source::{
|
||||
comment::{Comment, CommentUpdateForm},
|
||||
local_site::LocalSite,
|
||||
|
@ -32,10 +30,11 @@ pub async fn update_comment(
|
|||
data: Json<EditComment>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
path: Path<CommentId>,
|
||||
) -> LemmyResult<Json<CommentResponse>> {
|
||||
let comment_id = path.into_inner();
|
||||
let local_site = LocalSite::read(&mut context.pool()).await?;
|
||||
|
||||
let comment_id = data.comment_id;
|
||||
let orig_comment = CommentView::read(
|
||||
&mut context.pool(),
|
||||
comment_id,
|
||||
|
@ -70,7 +69,6 @@ pub async fn update_comment(
|
|||
is_valid_body_field(content, false)?;
|
||||
}
|
||||
|
||||
let comment_id = data.comment_id;
|
||||
let form = CommentUpdateForm {
|
||||
content,
|
||||
language_id: Some(language_id),
|
||||
|
|
|
@ -224,28 +224,37 @@ pub fn config(cfg: &mut ServiceConfig, rate_limit: &RateLimitCell) {
|
|||
.route("/site_metadata", get().to(get_link_metadata)),
|
||||
)
|
||||
// Comment
|
||||
.service(
|
||||
scope("/comments")
|
||||
.route("", get().to(list_comments))
|
||||
.service(
|
||||
// Handle POST to /comment separately to add the comment() rate limitter
|
||||
resource("/comment")
|
||||
resource("")
|
||||
.guard(guard::Post())
|
||||
.wrap(rate_limit.comment())
|
||||
.route(post().to(create_comment)),
|
||||
)
|
||||
.service(
|
||||
scope("/comment")
|
||||
scope("/{comment_id}")
|
||||
.route("", get().to(get_comment))
|
||||
.route("", put().to(update_comment))
|
||||
.route("/delete", post().to(delete_comment))
|
||||
.route("", delete().to(delete_comment))
|
||||
.route("/remove", post().to(remove_comment))
|
||||
.route("/mark_as_read", post().to(mark_reply_as_read))
|
||||
.route("/mark-as-read", post().to(mark_reply_as_read))
|
||||
.route("/distinguish", post().to(distinguish_comment))
|
||||
.route("/like", post().to(like_comment))
|
||||
.route("/like/list", get().to(list_comment_likes))
|
||||
.route("/save", put().to(save_comment))
|
||||
.route("/list", get().to(list_comments))
|
||||
.route("/report", post().to(create_comment_report))
|
||||
.route("/report/resolve", put().to(resolve_comment_report))
|
||||
.route("/report/list", get().to(list_comment_reports)),
|
||||
.service(
|
||||
resource("/likes")
|
||||
.route(get().to(list_comment_likes))
|
||||
.route(post().to(like_comment)),
|
||||
)
|
||||
.service(
|
||||
scope("/reports")
|
||||
.route("", get().to(list_comment_reports))
|
||||
.route("", post().to(create_comment_report))
|
||||
.service(scope("/{report_id}").route("", delete().to(resolve_comment_report))),
|
||||
),
|
||||
),
|
||||
)
|
||||
// Private Message
|
||||
.service(
|
||||
|
|
Loading…
Reference in a new issue