Browse Source

5min new user wait time for posts and comments

feature/better-newuser-experience
Dash8 1 year ago
parent
commit
285c5c6ea7
  1. 10
      server/src/api/comment.rs
  2. 4
      server/src/api/post.rs

10
server/src/api/comment.rs

@ -4,10 +4,7 @@ use actix_web::web::Data;
use log::error;
use lemmy_api_structs::{comment::*, APIError};
use lemmy_db::{
comment::*, comment_view::*, community_settings::*, moderator::*, post::*, site_view::*, user::*,
user_mention::*, Crud, Likeable, ListingType, Saveable, SortType,
};
use lemmy_db::{comment::*, comment_view::*, community_settings::*, moderator::*, post::*, site_view::*, user::*, user_mention::*, Crud, Likeable, ListingType, Saveable, SortType, naive_now};
use lemmy_utils::{
make_apub_endpoint, num_md_images, remove_slurs, scrape_text_for_mentions, send_email,
settings::Settings, ConnectionId, EndpointType, LemmyError, MentionData,
@ -30,6 +27,7 @@ use lemmy_db::{
community_view::{CommunityModeratorView, CommunityView},
post_view::PostView,
};
use crate::chrono::Duration;
#[async_trait::async_trait(?Send)]
impl Perform for GetComment {
@ -136,6 +134,10 @@ impl Perform for CreateComment {
let data: &CreateComment = &self;
let user = get_user_from_jwt(&data.auth, context.pool()).await?;
if (naive_now() - user.published) < Duration::minutes(5) {
return Err(APIError::err("new_user_5min_waiting_period_not_met").into());
}
let content_slurs_removed = remove_slurs(&data.content.to_owned());
// let content_pii_removed = remove_pii(&content_slurs_removed);

4
server/src/api/post.rs

@ -40,6 +40,10 @@ impl Perform for CreatePost {
let data: &CreatePost = &self;
let user = get_user_from_jwt(&data.auth, context.pool()).await?;
if (naive_now() - user.published) < chrono::Duration::minutes(5) {
return Err(APIError::err("new_user_5min_waiting_period_not_met").into());
}
check_slurs(&data.name)?;
check_slurs_opt(&data.body)?;
if !is_within_post_title_char_limit(&data.name) {

Loading…
Cancel
Save