Allow datetimes as an id parameter in the WebSocket RPC message

This commit is contained in:
Tobie Morgan Hitchcock 2022-10-25 06:06:02 -07:00
parent 2e1d39fcf8
commit 3cbb5eed78
2 changed files with 11 additions and 4 deletions

View file

@ -589,6 +589,10 @@ impl Value {
matches!(self, Value::Number(v) if v.is_positive()) matches!(self, Value::Number(v) if v.is_positive())
} }
pub fn is_datetime(&self) -> bool {
matches!(self, Value::Datetime(_))
}
pub fn is_type_record(&self, types: &[Table]) -> bool { pub fn is_type_record(&self, types: &[Table]) -> bool {
match self { match self {
Value::Thing(v) => types.iter().any(|tb| tb.0 == v.tb), Value::Thing(v) => types.iter().any(|tb| tb.0 == v.tb),

View file

@ -146,10 +146,13 @@ impl Rpc {
}; };
// Fetch the 'id' argument // Fetch the 'id' argument
let id = match req.pick(&*ID) { let id = match req.pick(&*ID) {
v if v.is_uuid() || v.is_strand() || v.is_number() || v.is_none() || v.is_null() => { v if v.is_none() => None,
Some(v) v if v.is_null() => Some(v),
} v if v.is_uuid() => Some(v),
_ => return res::failure(None, Failure::INVALID_REQUEST).send(chn).await, v if v.is_number() => Some(v),
v if v.is_strand() => Some(v),
v if v.is_datetime() => Some(v),
_ => return res::failure(None, Failure::INVALID_REQUEST).send(out, chn).await,
}; };
// Fetch the 'method' argument // Fetch the 'method' argument
let method = match req.pick(&*METHOD) { let method = match req.pick(&*METHOD) {