-use crate::newtypes::DbUrl;
+use crate::{newtypes::DbUrl, CommentSortType, SortType};
use activitypub_federation::{core::object_id::ObjectId, traits::ApubObject};
use chrono::NaiveDateTime;
use diesel::{
chrono::prelude::Utc::now().naive_utc()
}
+pub fn post_to_comment_sort_type(sort: SortType) -> CommentSortType {
+ match sort {
+ SortType::Active | SortType::Hot => CommentSortType::Hot,
+ SortType::New | SortType::NewComments | SortType::MostComments => CommentSortType::New,
+ SortType::Old => CommentSortType::Old,
+ SortType::TopDay
+ | SortType::TopAll
+ | SortType::TopWeek
+ | SortType::TopYear
+ | SortType::TopMonth => CommentSortType::Top,
+ }
+}
+
static EMAIL_REGEX: Lazy<Regex> = Lazy::new(|| {
Regex::new(r"^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$")
.expect("compile email regex")