add: user links and location
This commit is contained in:
parent
5fafc8d7b9
commit
140a11ff72
18 changed files with 442 additions and 222 deletions
|
@ -709,15 +709,17 @@ impl DataManager {
|
|||
|
||||
self.cache_clear_user(&other_user).await;
|
||||
|
||||
// create audit log entry
|
||||
self.create_audit_log_entry(AuditLogEntry::new(
|
||||
user.id,
|
||||
format!(
|
||||
"invoked `update_user_is_deactivated` with x value `{}` and y value `{}`",
|
||||
other_user.id, x
|
||||
),
|
||||
))
|
||||
.await?;
|
||||
// create audit log entry (if we aren't the user that is being updated)
|
||||
if user.id != other_user.id {
|
||||
self.create_audit_log_entry(AuditLogEntry::new(
|
||||
user.id,
|
||||
format!(
|
||||
"invoked `update_user_is_deactivated` with x value `{}` and y value `{}`",
|
||||
other_user.id, x
|
||||
),
|
||||
))
|
||||
.await?;
|
||||
}
|
||||
|
||||
// ...
|
||||
Ok(())
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
use std::collections::HashMap;
|
||||
use crate::model::{Error, Result};
|
||||
|
||||
use super::{
|
||||
oauth::AuthGrant,
|
||||
permissions::{FinePermission, SecondaryPermission},
|
||||
|
@ -10,6 +12,7 @@ use tetratto_shared::{
|
|||
snow::Snowflake,
|
||||
unix_epoch_timestamp,
|
||||
};
|
||||
use serde_valid::Validate;
|
||||
|
||||
/// `(ip, token, creation timestamp)`
|
||||
pub type Token = (String, String, usize);
|
||||
|
@ -187,13 +190,16 @@ impl Default for DefaultProfileTabChoice {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, Default)]
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, Default, Validate)]
|
||||
pub struct UserSettings {
|
||||
#[serde(default)]
|
||||
#[validate(max_length = 32)]
|
||||
pub display_name: String,
|
||||
#[serde(default)]
|
||||
#[validate(max_length = 4096)]
|
||||
pub biography: String,
|
||||
#[serde(default)]
|
||||
#[validate(max_length = 2048)]
|
||||
pub warning: String,
|
||||
#[serde(default)]
|
||||
pub private_profile: bool,
|
||||
|
@ -303,6 +309,7 @@ pub struct UserSettings {
|
|||
pub private_mails: bool,
|
||||
/// The user's status. Shows over connection info.
|
||||
#[serde(default)]
|
||||
#[validate(max_length = 256)]
|
||||
pub status: String,
|
||||
/// The mime type of the user's banner.
|
||||
#[serde(default = "mime_avif")]
|
||||
|
@ -365,9 +372,11 @@ pub struct UserSettings {
|
|||
pub hide_social_follows: bool,
|
||||
/// The signature automatically attached to new mail letters.
|
||||
#[serde(default)]
|
||||
#[validate(max_length = 2048)]
|
||||
pub mail_signature: String,
|
||||
/// The signature automatically attached to new forum posts.
|
||||
#[serde(default)]
|
||||
#[validate(max_length = 2048)]
|
||||
pub forum_signature: String,
|
||||
/// If coin transfer requests are disabled.
|
||||
#[serde(default)]
|
||||
|
@ -381,6 +390,26 @@ pub struct UserSettings {
|
|||
/// If the user's system font is always used over Lexend.
|
||||
#[serde(default)]
|
||||
pub use_system_font: bool,
|
||||
/// The user's location. This isn't actually verified or anything, so it can really
|
||||
/// be whatever the user wants.
|
||||
#[serde(default)]
|
||||
#[validate(max_length = 128)]
|
||||
pub location: String,
|
||||
/// External links for the user's other profiles on other websites.
|
||||
#[serde(default)]
|
||||
#[validate(max_items = 5)]
|
||||
#[validate(unique_items)]
|
||||
pub links: Vec<(String, String)>,
|
||||
}
|
||||
|
||||
impl UserSettings {
|
||||
pub fn verify_values(&self) -> Result<()> {
|
||||
if let Err(e) = self.validate() {
|
||||
return Err(Error::MiscError(e.to_string()));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
fn mime_avif() -> String {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue