server: remove deprecated fields from CreateUserRequest

The fields first_name, last_name, and avatar have all been moved
to regular attributes in the database, and are available through
the GraphQL API as such as well. This commit removes the legacy
fields for each on the internal CreateUserRequest type, leaving
these to only be updateable through attributes.

The fields are still available in the GraphQL CreateUserInput
type, preserving backwards compatiblity, and if set, they will
be used for the corresponding attribute values. If both fields
and attributes are set, the values given through attributes will
superceed the fields, and be used. This change also fixes a bug,
where creation of a user would fail if either of these attributes
were set as both attribute and field, as it would attempt to
insert the attribute twice, violating a unique constraint in the
database.
This commit is contained in:
Simon Broeng Jensen
2025-02-03 21:41:30 +01:00
committed by nitnelave
parent 37a683dcb2
commit 4c6cfeee9e
6 changed files with 303 additions and 129 deletions
+1 -7
View File
@@ -1,7 +1,7 @@
use serde::{Deserialize, Serialize};
use crate::types::{
AttributeName, AttributeType, AttributeValue, Email, GroupId, GroupName, JpegPhoto, UserId,
AttributeName, AttributeType, AttributeValue, Email, GroupId, GroupName, UserId,
};
#[derive(PartialEq, Eq, Debug, Serialize, Deserialize, Clone, Default)]
@@ -10,9 +10,6 @@ pub struct CreateUserRequest {
pub user_id: UserId,
pub email: Email,
pub display_name: Option<String>,
pub first_name: Option<String>,
pub last_name: Option<String>,
pub avatar: Option<JpegPhoto>,
pub attributes: Vec<AttributeValue>,
}
@@ -22,9 +19,6 @@ pub struct UpdateUserRequest {
pub user_id: UserId,
pub email: Option<Email>,
pub display_name: Option<String>,
pub first_name: Option<String>,
pub last_name: Option<String>,
pub avatar: Option<JpegPhoto>,
pub delete_attributes: Vec<AttributeName>,
pub insert_attributes: Vec<AttributeValue>,
}