fix: journal privacy
This commit is contained in:
parent
57a69eea50
commit
97b7e873ed
6 changed files with 95 additions and 15 deletions
|
@ -9,11 +9,14 @@ use crate::{
|
|||
routes::api::v1::{UpdateJournalPrivacy, CreateJournal, UpdateJournalTitle},
|
||||
State,
|
||||
};
|
||||
use tetratto_core::model::{
|
||||
journals::{Journal, JournalPrivacyPermission},
|
||||
oauth,
|
||||
permissions::FinePermission,
|
||||
ApiReturn, Error,
|
||||
use tetratto_core::{
|
||||
database::NAME_REGEX,
|
||||
model::{
|
||||
journals::{Journal, JournalPrivacyPermission},
|
||||
oauth,
|
||||
permissions::FinePermission,
|
||||
ApiReturn, Error,
|
||||
},
|
||||
};
|
||||
|
||||
pub async fn get_request(
|
||||
|
@ -101,6 +104,16 @@ pub async fn update_title_request(
|
|||
|
||||
props.title = props.title.replace(" ", "_");
|
||||
|
||||
// check name
|
||||
let regex = regex::RegexBuilder::new(NAME_REGEX)
|
||||
.multi_line(true)
|
||||
.build()
|
||||
.unwrap();
|
||||
|
||||
if regex.captures(&props.title).is_some() {
|
||||
return Json(Error::MiscError("This title contains invalid characters".to_string()).into());
|
||||
}
|
||||
|
||||
// make sure this title isn't already in use
|
||||
if data
|
||||
.get_journal_by_owner_title(user.id, &props.title)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue