default empty presence string to offline.

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-04-14 03:44:04 -07:00 committed by June
parent cdb2dff7dd
commit 287887224f

View file

@ -136,9 +136,14 @@ impl Service {
/// Adds a presence event which will be saved until a new event replaces it. /// Adds a presence event which will be saved until a new event replaces it.
pub fn set_presence( pub fn set_presence(
&self, user_id: &UserId, presence_state: &PresenceState, currently_active: Option<bool>, &self, user_id: &UserId, state: &PresenceState, currently_active: Option<bool>, last_active_ago: Option<UInt>,
last_active_ago: Option<UInt>, status_msg: Option<String>, status_msg: Option<String>,
) -> Result<()> { ) -> Result<()> {
let presence_state = match state.as_str() {
"" => &PresenceState::Offline, // default an empty string to 'offline'
&_ => state,
};
self.db self.db
.set_presence(user_id, presence_state, currently_active, last_active_ago, status_msg)?; .set_presence(user_id, presence_state, currently_active, last_active_ago, status_msg)?;