diff --git a/src/model/client.rs b/src/model/client.rs index f5f5e9d..e434a84 100644 --- a/src/model/client.rs +++ b/src/model/client.rs @@ -1,4 +1,4 @@ -use crate::Backend; +use crate::{random_names::get_name_by_uuid, Backend}; use serde::{Deserialize, Serialize}; use sqlx::FromRow; use uuid::Uuid; @@ -9,6 +9,15 @@ pub struct Client { pub name: Option, } +impl Client { + pub(crate) fn get_display_name(&self) -> String { + match &self.name { + Some(name) => name.to_string(), + None => get_name_by_uuid(&self.uuid).to_string(), + } + } +} + impl Backend { pub(crate) async fn get_client(&self, uuid: &Uuid) -> Client { let uuid = uuid.to_string();