mirror of
https://github.com/LemmyNet/lemmy.git
synced 2026-01-06 05:40:02 -06:00
* migration * update code * tests * triggers * fix * fmt * clippy * post aggregate migration * changes for post aggregate code * wip: update tests for post aggregate * format * fix partialeq * trigger fix * fix post insert trigger * wip * reorder * fixes * community aggregate migration * update code * triggers * person aggregate migration * person aggregate code * person triggers * test fixes * fix scheduled task * update api tests * site_aggregates to local_site migration * site_aggregates code changes * triggers, tests * more fixes * Rename PersonPostAggregates to PostActions * Merge local_user_vote_display_mode into local_user * fix schema * remove duplicate fields * remove "aggregates" from index names * uncomment indices * if count = 0 * remove commentaggregates * Fix triggers in remove aggregates tables pr (#5451) * prevent all db_schema test errors * fix the delete_comments_before_post problem in a way that doesn't affect the returned number of affected rows * remove unnecessary recursion checks and add comment to remaining check * clean up * Fixing SQL format. * Update triggers.sql * Update triggers.sql * Update triggers.sql * Update triggers.sql * remove update of deleted column --------- Co-authored-by: Dessalines <tyhou13@gmx.com> * rename migration * Fix migration errors * Move community.hidden to visibility (fixes #5458) * Fixing person_saved_combined. (#5481) * Remove comment and post specific action structs. #5473 * Doing reports * fix up migration by dropping index * also add enum variant `LocalOnlyPublic`, rename `LocalOnly` to `LocalOnlyPrivate` fixes #5351 * fix column order in down.sql * wip * Moving blocks. * Adding a few more views. * more wip * fixes * migration for modlog * fix migration * Working views and schema. * Fix ts_optionals. * wip * db_schema compiling * make the code compile * Merging from main. * lint * Fixing SQL format. * fix down migration * Fixing api tests. * Adding field comments for the actions tables. * Refactoring CommunityFollower to include follow_state * fix test * make hidden status federate * ts attr * fix * fix api test * Update crates/api/src/reports/post_report/resolve.rs Co-authored-by: Nutomic <me@nutomic.com> * Addressing PR comments * Fix ts export. * update api client * review * Extracting filter_not_hidden_or_is_subscribed (#5497) * Extracting filter_not_hidden_or_is_subscribed * Cleanup. * Cleanup 2. * Remove follower_state_helper function. * Cleaning up some utils functions. * rename hidden to unlisted --------- Co-authored-by: Felix Ableitner <me@nutomic.com> Co-authored-by: dullbananas <dull.bananas0@gmail.com>
39 lines
1.0 KiB
Rust
39 lines
1.0 KiB
Rust
use actix_web::web::{Data, Json};
|
|
use lemmy_api_common::{
|
|
comment::{CommentResponse, SaveComment},
|
|
context::LemmyContext,
|
|
};
|
|
use lemmy_db_schema::{
|
|
source::comment::{CommentActions, CommentSavedForm},
|
|
traits::Saveable,
|
|
};
|
|
use lemmy_db_views::structs::{CommentView, LocalUserView};
|
|
use lemmy_utils::error::LemmyResult;
|
|
|
|
pub async fn save_comment(
|
|
data: Json<SaveComment>,
|
|
context: Data<LemmyContext>,
|
|
local_user_view: LocalUserView,
|
|
) -> LemmyResult<Json<CommentResponse>> {
|
|
let comment_saved_form = CommentSavedForm::new(local_user_view.person.id, data.comment_id);
|
|
|
|
if data.save {
|
|
CommentActions::save(&mut context.pool(), &comment_saved_form).await?;
|
|
} else {
|
|
CommentActions::unsave(&mut context.pool(), &comment_saved_form).await?;
|
|
}
|
|
|
|
let comment_id = data.comment_id;
|
|
let comment_view = CommentView::read(
|
|
&mut context.pool(),
|
|
comment_id,
|
|
Some(&local_user_view.local_user),
|
|
)
|
|
.await?;
|
|
|
|
Ok(Json(CommentResponse {
|
|
comment_view,
|
|
recipient_ids: Vec::new(),
|
|
}))
|
|
}
|