chore: update create collab list api endpoint (#657)
* chore: update create collab list api endpoint * chore: clippy * chore: fix compile
This commit is contained in:
parent
80e1dce500
commit
50ed9f4a6a
|
|
@ -12,7 +12,7 @@ use collab::core::collab::{MutexCollab, WeakMutexCollab};
|
|||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
use tokio::sync::mpsc;
|
||||
use tokio::time::{interval, sleep};
|
||||
use tokio::time::interval;
|
||||
use tracing::{error, trace, warn};
|
||||
|
||||
pub(crate) struct GroupPersistence<S> {
|
||||
|
|
@ -55,9 +55,6 @@ where
|
|||
|
||||
pub async fn run(self, mut destroy_group_rx: mpsc::Receiver<MutexCollab>) {
|
||||
let mut interval = interval(self.persistence_interval);
|
||||
// TODO(nathan): remove this sleep when creating a new collab, applying all the updates
|
||||
// workarounds for the issue that the collab doesn't contain the required data when first created
|
||||
sleep(Duration::from_secs(5)).await;
|
||||
loop {
|
||||
tokio::select! {
|
||||
_ = interval.tick() => {
|
||||
|
|
|
|||
|
|
@ -666,15 +666,27 @@ async fn create_collab_list_handler(
|
|||
if valid_items.is_empty() {
|
||||
return Err(AppError::InvalidRequest("Empty collab params list".to_string()).into());
|
||||
}
|
||||
let mut transaction = state
|
||||
.pg_pool
|
||||
.begin()
|
||||
.await
|
||||
.map_err(|err| AppError::Internal(anyhow!("Failed to start inserting collab: {}", err)))?;
|
||||
|
||||
for params in valid_items {
|
||||
let _object_id = params.object_id.clone();
|
||||
state
|
||||
.collab_access_control_storage
|
||||
.insert_new_collab(&workspace_id, &uid, params)
|
||||
.insert_new_collab_with_transaction(&workspace_id, &uid, params, &mut transaction)
|
||||
.await?;
|
||||
}
|
||||
|
||||
transaction.commit().await.map_err(|err| {
|
||||
AppError::Internal(anyhow!(
|
||||
"Failed to finish inserting list of collab: {}",
|
||||
err
|
||||
))
|
||||
})?;
|
||||
|
||||
Ok(Json(AppResponse::Ok()))
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue