Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(entity_access): channel share (#2721)

Will Hutchinson454aa510ac14
diff --git a/rust/cloud-storage/comms_service/src/channel_permissions.rs b/rust/cloud-storage/comms_service/src/channel_permissions.rs
index 217412bf22..d3bfe034ed 100644
--- a/rust/cloud-storage/comms_service/src/channel_permissions.rs
+++ b/rust/cloud-storage/comms_service/src/channel_permissions.rs
@@ -83,7 +83,7 @@ pub async fn update_channel_share_permission(
// Insert channel share permission
if let Err(e) =
macro_db_client::share_permission::channel_permission::create::insert_channel_share_permission(
- db,
+ &mut *transaction,
&share_permission_id,
channel_id,
&channel_share_permission_access_level,
@@ -111,5 +111,7 @@ pub async fn update_channel_share_permission(
)
.await?;
+ transaction.commit().await?;
+
Ok(())
}
diff --git a/rust/cloud-storage/macro_db_client/src/share_permission/channel_permission/create.rs b/rust/cloud-storage/macro_db_client/src/share_permission/channel_permission/create.rs
index 534fd132d6..cba0340676 100644
--- a/rust/cloud-storage/macro_db_client/src/share_permission/channel_permission/create.rs
+++ b/rust/cloud-storage/macro_db_client/src/share_permission/channel_permission/create.rs
@@ -1,6 +1,6 @@
use models_permissions::share_permission::access_level::AccessLevel;
use models_permissions::share_permission::channel_share_permission::ChannelSharePermission;
-use sqlx::{Postgres, Transaction};
+use sqlx::{Executor, Postgres, Transaction};
use super::ChannelSharePermissionParamaters;
@@ -56,13 +56,16 @@ pub async fn create_channel_share_permissions(
/// Attempts to insert a channel share permission
/// If there is a conflict this will error
-#[tracing::instrument(skip(db))]
-pub async fn insert_channel_share_permission(
- db: &sqlx::Pool<sqlx::Postgres>,
+#[tracing::instrument(skip(executor))]
+pub async fn insert_channel_share_permission<'e, E>(
+ executor: E,
share_permission_id: &str,
channel_id: &str,
access_level: &AccessLevel,
-) -> anyhow::Result<()> {
+) -> anyhow::Result<()>
+where
+ E: Executor<'e, Database = Postgres>,
+{
sqlx::query!(
r#"
INSERT INTO "ChannelSharePermission" ("share_permission_id", "channel_id", "access_level")
@@ -72,7 +75,7 @@ pub async fn insert_channel_share_permission(
channel_id,
access_level as _,
)
- .execute(db)
+ .execute(executor)
.await.map_err(|e| {
if e.to_string().contains("duplicate key value violates unique constraint") {
anyhow::anyhow!("channel permission already exists")