Support website publishing #7

Merged
lx merged 61 commits from feature/website into master 2021-01-15 16:49:51 +00:00
2 changed files with 14 additions and 6 deletions
Showing only changes of commit d0eb6a457f - Show all commits

View file

@ -89,7 +89,7 @@ impl AdminRpcHandler {
} }
bucket bucket
.state .state
.update(BucketState::Present(crdt::LWWMap::new())); .update(BucketState::Present(BucketParams::new()));
bucket bucket
} }
None => Bucket::new(query.name.clone()), None => Bucket::new(query.name.clone()),
@ -157,6 +157,7 @@ impl AdminRpcHandler {
} }
BucketOperation::Website(query) => { BucketOperation::Website(query) => {
/*let bucket = self.get_existing_bucket(&query.bucket).await?; /*let bucket = self.get_existing_bucket(&query.bucket).await?;
if query.allow && query.deny { if query.allow && query.deny {
return Err(Error::Message(format!("Website can not be both allowed and denied on a bucket"))); return Err(Error::Message(format!("Website can not be both allowed and denied on a bucket")));
} }
@ -278,7 +279,8 @@ impl AdminRpcHandler {
allow_read: bool, allow_read: bool,
allow_write: bool, allow_write: bool,
) -> Result<(), Error> { ) -> Result<(), Error> {
if let BucketState::Present(ak) = bucket.state.get_mut() { if let BucketState::Present(params) = bucket.state.get_mut() {
let ak = &mut params.authorized_keys;
let old_ak = ak.take_and_clear(); let old_ak = ak.take_and_clear();
ak.merge(&old_ak.update_mutator( ak.merge(&old_ak.update_mutator(
key_id.to_string(), key_id.to_string(),

View file

@ -55,14 +55,20 @@ impl CRDT for BucketParams {
} }
} }
impl BucketParams {
pub fn new() -> Self {
BucketParams {
authorized_keys: crdt::LWWMap::new(),
website: crdt::LWW::new(false)
}
}
}
impl Bucket { impl Bucket {
pub fn new(name: String) -> Self { pub fn new(name: String) -> Self {
Bucket { Bucket {
name, name,
state: crdt::LWW::new(BucketState::Present(BucketParams { state: crdt::LWW::new(BucketState::Present(BucketParams::new())),
authorized_keys: crdt::LWWMap::new(),
website: crdt::LWW::new(false)
})),
} }
} }
pub fn is_deleted(&self) -> bool { pub fn is_deleted(&self) -> bool {