v0.4.2
This commit is contained in:
@@ -26,7 +26,7 @@ use jmap_proto::{
|
||||
error::method::MethodError,
|
||||
method::get::{GetRequest, GetResponse, RequestArguments},
|
||||
object::Object,
|
||||
types::{collection::Collection, property::Property, type_state::TypeState, value::Value},
|
||||
types::{collection::Collection, property::Property, type_state::DataType, value::Value},
|
||||
};
|
||||
use store::{write::now, BitmapKey, ValueKey};
|
||||
use utils::map::bitmap::Bitmap;
|
||||
@@ -74,7 +74,7 @@ impl JMAP {
|
||||
// Obtain the push subscription object
|
||||
let document_id = id.document_id();
|
||||
if !push_ids.contains(document_id) {
|
||||
response.not_found.push(id);
|
||||
response.not_found.push(id.into());
|
||||
continue;
|
||||
}
|
||||
let mut push = if let Some(push) = self
|
||||
@@ -88,7 +88,7 @@ impl JMAP {
|
||||
{
|
||||
push
|
||||
} else {
|
||||
response.not_found.push(id);
|
||||
response.not_found.push(id.into());
|
||||
continue;
|
||||
};
|
||||
let mut result = Object::with_capacity(properties.len());
|
||||
@@ -215,7 +215,7 @@ impl JMAP {
|
||||
for type_state in value {
|
||||
if let Some(type_state) = type_state
|
||||
.as_string()
|
||||
.and_then(|type_state| TypeState::try_from(type_state).ok())
|
||||
.and_then(|type_state| DataType::try_from(type_state).ok())
|
||||
{
|
||||
type_states.insert(type_state);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ pub mod set;
|
||||
|
||||
use std::time::Instant;
|
||||
|
||||
use jmap_proto::types::{id::Id, state::StateChange, type_state::TypeState};
|
||||
use jmap_proto::types::{id::Id, state::StateChange, type_state::DataType};
|
||||
use utils::map::bitmap::Bitmap;
|
||||
|
||||
#[derive(Debug)]
|
||||
@@ -47,7 +47,7 @@ pub struct PushSubscription {
|
||||
pub id: u32,
|
||||
pub url: String,
|
||||
pub expires: u64,
|
||||
pub types: Bitmap<TypeState>,
|
||||
pub types: Bitmap<DataType>,
|
||||
pub keys: Option<EncryptionKeys>,
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ use jmap_proto::{
|
||||
collection::Collection,
|
||||
date::UTCDate,
|
||||
property::Property,
|
||||
type_state::TypeState,
|
||||
type_state::DataType,
|
||||
value::{MaybePatchValue, Value},
|
||||
},
|
||||
};
|
||||
@@ -99,12 +99,13 @@ impl JMAP {
|
||||
}
|
||||
|
||||
// Add expiry time if missing
|
||||
if !push.properties.contains_key(&Property::Expires) {
|
||||
push.append(
|
||||
Property::Expires,
|
||||
Value::Date(UTCDate::from_timestamp(now() as i64 + EXPIRES_MAX)),
|
||||
)
|
||||
}
|
||||
let expires = if let Some(expires) = push.properties.get(&Property::Expires) {
|
||||
expires.clone()
|
||||
} else {
|
||||
let expires = Value::Date(UTCDate::from_timestamp(now() as i64 + EXPIRES_MAX));
|
||||
push.append(Property::Expires, expires.clone());
|
||||
expires
|
||||
};
|
||||
|
||||
// Generate random verification code
|
||||
push.append(
|
||||
@@ -130,7 +131,13 @@ impl JMAP {
|
||||
.value(Property::Value, push, F_VALUE);
|
||||
push_ids.insert(document_id);
|
||||
self.write_batch(batch).await?;
|
||||
response.created(id, document_id);
|
||||
response.created.insert(
|
||||
id,
|
||||
Object::with_capacity(1)
|
||||
.with_property(Property::Id, Value::Id(document_id.into()))
|
||||
.with_property(Property::Keys, Value::Null)
|
||||
.with_property(Property::Expires, expires),
|
||||
);
|
||||
}
|
||||
|
||||
// Process updates
|
||||
@@ -258,7 +265,7 @@ fn validate_push_value(
|
||||
if value.iter().all(|value| {
|
||||
value
|
||||
.as_string()
|
||||
.and_then(|value| TypeState::try_from(value).ok())
|
||||
.and_then(|value| DataType::try_from(value).ok())
|
||||
.is_some()
|
||||
}) =>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user