Query string parameter 'type' is now enforced by the api
+ Flag is literally called 'type'
This commit is contained in:
@@ -11,20 +11,21 @@ const MAX_MESSAGES: u64 = 1000;
|
||||
|
||||
|
||||
impl crate::Message {
|
||||
pub async fn send(p: &Pool, content: &str, cid: UBigInt, uid: UBigInt) -> Result<Response<Self>, SqlError> {
|
||||
pub async fn send(p: &Pool, content: &str, content_type: &str, cid: UBigInt, uid: UBigInt) -> Result<Response<Self>, SqlError> {
|
||||
//! @returns on_sucess -> empty
|
||||
//! @returns on_failure Err(SqlErr)
|
||||
|
||||
use chrono::Utc;
|
||||
let conn = p.get_conn().await?;
|
||||
let q = "INSERT INTO messages
|
||||
(time, content, author_id, channel_id)
|
||||
VALUES (:time, :content, :author, :channel)";
|
||||
(time, content, content_type, author_id, channel_id)
|
||||
VALUES (:time, :content, :ctype, :author, :channel)";
|
||||
let now = Utc::now().timestamp();
|
||||
|
||||
let res = conn.prep_exec(q, params!{
|
||||
"time" => now,
|
||||
"content" => content,
|
||||
"ctype" => content_type,
|
||||
"author" => uid,
|
||||
"channel" => cid
|
||||
}).await;
|
||||
@@ -102,6 +103,7 @@ impl crate::Message {
|
||||
|
||||
pub async fn get_from_id(p: &Pool, channel_id: UBigInt, start: UBigInt, limit: Option<UBigInt>) -> Result<Response<Self>, SqlError> {
|
||||
//! @returns on success : Set(Vec<Messages>)
|
||||
//! @returns on user failure : RestrictedInput(String)
|
||||
//! @returns on failure : Err(SqlError)
|
||||
let conn = p.get_conn().await?;
|
||||
let limit = if let Some(limit) = limit{
|
||||
|
||||
Reference in New Issue
Block a user