Fix building the Message
s in getMessage
This commit is contained in:
@@ -478,6 +478,17 @@ pub enum MsgType {
|
||||
Text = 0,
|
||||
}
|
||||
|
||||
impl TryFrom<u8> for MsgType {
|
||||
type Error = String;
|
||||
|
||||
fn try_from(value: u8) -> Result<Self, Self::Error> {
|
||||
match value {
|
||||
0 => Ok(Self::Text),
|
||||
_ => Err("Unknown MessageType".to_string()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct Query;
|
||||
|
||||
@@ -617,13 +628,12 @@ impl Query {
|
||||
sender: message.try_get::<String, _>("sender_id")?.into(),
|
||||
msg_type: message.try_get::<u8,_>("msg_type")?.try_into()?,
|
||||
content: message.try_get("content")?,
|
||||
hide_for: message.try_get("hide_for")?
|
||||
hide_for: message.try_get::<Option<String>, _>("hide_for")?
|
||||
.map(|array| from_sql_formatted_array(array, "hide_for"))
|
||||
.transpose()?
|
||||
.map(|u: String| u.into())
|
||||
.collect(),
|
||||
.map(|iter| iter.map(|u: String| u.into()).collect()),
|
||||
seen_by: from_sql_formatted_array(message.try_get("seen_by")?, "seen_by")?
|
||||
.map(|s| s.into())
|
||||
.map(|s: String| s.into())
|
||||
.collect(),
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user