not so much clutter when addding notes
Some checks failed
CI/CD Pipeline / deploy-staging (push) Blocked by required conditions
CI/CD Pipeline / deploy-main (push) Blocked by required conditions
CI/CD Pipeline / test (push) Has been cancelled

This commit is contained in:
2025-05-14 08:04:56 +02:00
parent edcdc74c1c
commit ed6d05eb9e
3 changed files with 12 additions and 8 deletions

View File

@@ -17,11 +17,14 @@ pub struct Activity {
pub keep_until: Option<NaiveDateTime>,
}
// TODO: add `reason` as additional db field, to be able to query and show this to the users
pub enum Reason<'a> {
// `User` tried to login with `String` as UserAgent
SuccLogin(&'a User, String),
// `User` changed the data of `User`, explanation in `String`
UserDataChange(&'a ManageUserUser, &'a User, String),
// New Note for User
NewUserNote(&'a ManageUserUser, &'a User, String),
}
impl From<Reason<'_>> for ActivityBuilder {
@@ -36,6 +39,9 @@ impl From<Reason<'_>> for ActivityBuilder {
"{changed_by} hat die Daten von {changed_user} aktualisiert: {explanation}"
))
.relevant_for_user(changed_user),
Reason::NewUserNote(changed_by, user, explanation) => {
Self::new(&format!("({changed_by}) {explanation}")).relevant_for_user(user)
}
}
}
}

View File

@@ -17,7 +17,6 @@ impl User {
&self,
db: &SqlitePool,
updated_by: &ManageUserUser,
user: &User,
note: &str,
) -> Result<(), String> {
let note = note.trim();
@@ -25,7 +24,7 @@ impl User {
ActivityBuilder::from(activity::Reason::UserDataChange(
updated_by,
self,
format!("Neue Notizen: {note}"),
note.to_string(),
))
.save(db)
.await;