From ffee47d0f75d630073817815a6952fd3352b110c Mon Sep 17 00:00:00 2001 From: "Nathan.fooo" <86001920+appflowy@users.noreply.github.com> Date: Thu, 17 Oct 2024 17:43:00 +0800 Subject: [PATCH] chore: remove workspace and collab listener (#893) --- .../appflowy-collaborate/src/application.rs | 20 ++++++------ .../appflowy-collaborate/src/pg_listener.rs | 32 ++----------------- src/biz/pg_listener.rs | 26 +-------------- 3 files changed, 13 insertions(+), 65 deletions(-) diff --git a/services/appflowy-collaborate/src/application.rs b/services/appflowy-collaborate/src/application.rs index 10cdae715..f54669838 100644 --- a/services/appflowy-collaborate/src/application.rs +++ b/services/appflowy-collaborate/src/application.rs @@ -3,7 +3,7 @@ use std::sync::Arc; use std::time::Duration; use access_control::casbin::collab::{CollabAccessControlImpl, RealtimeCollabAccessControlImpl}; -use access_control::casbin::notification::spawn_listen_on_workspace_member_change; + use access_control::casbin::workspace::WorkspaceAccessControlImpl; use actix::Supervisor; use actix_web::dev::Server; @@ -23,7 +23,6 @@ use appflowy_ai_client::client::AppFlowyAIClient; use crate::api::{collab_scope, ws_scope}; -use crate::collab::notification::spawn_listen_on_collab_member_change; use crate::collab::storage::CollabStorageImpl; use crate::command::{CLCommandReceiver, CLCommandSender}; use crate::config::{Config, DatabaseSetting}; @@ -119,15 +118,14 @@ pub async fn init_state(config: &Config, rt_cmd_tx: CLCommandSender) -> Result Result { let user_listener = UserListener::new(pg_pool, "af_user_channel").await?; - - let workspace_member_listener = - WorkspaceMemberListener::new(pg_pool, "af_workspace_member_channel").await?; - - let collab_member_listener = - CollabMemberListener::new(pg_pool, "af_collab_member_channel").await?; - - Ok(Self { - user_listener, - workspace_member_listener, - collab_member_listener, - }) - } - - pub fn subscribe_workspace_member_change( - &self, - ) -> broadcast::Receiver { - self.workspace_member_listener.notify.subscribe() - } - - pub fn subscribe_collab_member_change(&self) -> broadcast::Receiver { - self.collab_member_listener.notify.subscribe() + Ok(Self { user_listener }) } pub fn subscribe_user_change(&self, uid: i64) -> tokio::sync::mpsc::Receiver { @@ -55,6 +29,6 @@ impl PgListeners { } } -pub type CollabMemberListener = PostgresDBListener; +// pub type CollabMemberListener = PostgresDBListener; +// pub type WorkspaceMemberListener = PostgresDBListener; pub type UserListener = PostgresDBListener; -pub type WorkspaceMemberListener = PostgresDBListener; diff --git a/src/biz/pg_listener.rs b/src/biz/pg_listener.rs index 5039aeaab..e04ba53d0 100644 --- a/src/biz/pg_listener.rs +++ b/src/biz/pg_listener.rs @@ -4,39 +4,15 @@ use appflowy_collaborate::collab::notification::CollabMemberNotification; use database::listener::PostgresDBListener; use database::pg_row::AFUserNotification; use sqlx::PgPool; -use tokio::sync::broadcast; pub struct PgListeners { user_listener: UserListener, - workspace_member_listener: WorkspaceMemberListener, - collab_member_listener: CollabMemberListener, } impl PgListeners { pub async fn new(pg_pool: &PgPool) -> Result { let user_listener = UserListener::new(pg_pool, "af_user_channel").await?; - - let workspace_member_listener = - WorkspaceMemberListener::new(pg_pool, "af_workspace_member_channel").await?; - - let collab_member_listener = - CollabMemberListener::new(pg_pool, "af_collab_member_channel").await?; - - Ok(Self { - user_listener, - workspace_member_listener, - collab_member_listener, - }) - } - - pub fn subscribe_workspace_member_change( - &self, - ) -> broadcast::Receiver { - self.workspace_member_listener.notify.subscribe() - } - - pub fn subscribe_collab_member_change(&self) -> broadcast::Receiver { - self.collab_member_listener.notify.subscribe() + Ok(Self { user_listener }) } pub fn subscribe_user_change(&self, uid: i64) -> tokio::sync::mpsc::Receiver {