/messages/send now correctyl tells the user they're wrong about sendingmessages to a non-existant channel
This commit is contained in:
@@ -124,15 +124,32 @@ impl Message {
|
||||
(time, content, author_id, channel_id)
|
||||
VALUES (:time, :content, :author, :channel)";
|
||||
let now = Utc::now().timestamp();
|
||||
|
||||
conn.prep_exec(q, params!{
|
||||
|
||||
let res = conn.prep_exec(q, params!{
|
||||
"time" => now,
|
||||
"content" => content,
|
||||
"author" => uid,
|
||||
"channel" => cid
|
||||
}).await?;
|
||||
}).await;
|
||||
if let Err(e) = res {
|
||||
return match e {
|
||||
SqlError::Server(err) => {
|
||||
if err.code == 1452 {
|
||||
return Ok(Response::RestrictedInput("Channel not found".into()))
|
||||
}
|
||||
else {
|
||||
Ok(Response::Other(sql_err!("db::messages::send")))
|
||||
}
|
||||
},
|
||||
_ => Ok(Response::Other(sql_err!("db::messages::send")))
|
||||
}
|
||||
|
||||
}
|
||||
// all good response
|
||||
else {
|
||||
return Ok(Response::Empty);
|
||||
}
|
||||
|
||||
return Ok(Response::Empty);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user