Simplify the logic to fallback to the FQN when no display name is available

This commit is contained in:
Bat
2018-07-26 16:36:19 +02:00
parent 15477875da
commit 5980c7b299
7 changed files with 17 additions and 40 deletions
+5
View File
@@ -370,6 +370,11 @@ impl User {
pub fn to_json(&self, conn: &PgConnection) -> serde_json::Value {
let mut json = serde_json::to_value(self).unwrap();
json["fqn"] = serde_json::Value::String(self.get_fqn(conn));
json["name"] = if self.display_name.len() > 0 {
json!(self.display_name)
} else {
json!(self.get_fqn(conn))
};
json
}