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.

chg(channels): remove admin / owner restriction on channel participant management (#913)

teo3321fd74bacf
diff --git a/js/app/packages/block-channel/component/ParticipantManager.tsx b/js/app/packages/block-channel/component/ParticipantManager.tsx
index 4a5336fb89..1e0502b1b5 100644
--- a/js/app/packages/block-channel/component/ParticipantManager.tsx
+++ b/js/app/packages/block-channel/component/ParticipantManager.tsx
@@ -1,7 +1,4 @@
-import {
- channelStore,
- isChannelAdminOrOwnerMemo,
-} from '@block-channel/signal/channel';
+import { channelStore } from '@block-channel/signal/channel';
import {
useAddParticipantsToChannel,
useRemoveParticipantsFromChannel,
@@ -51,13 +48,10 @@ export function ParticipantManager(props: { participantCount: number }) {
setUsersToInvite([]);
}
- const editable = () =>
- (canManageParticipants() && isChannelAdminOrOwnerMemo()) ?? false;
+ const editable = () => canManageParticipants();
const title = () =>
- canManageParticipants() && isChannelAdminOrOwnerMemo()
- ? 'Manage Participants'
- : 'View Participants';
+ canManageParticipants() ? 'Manage Participants' : 'View Participants';
const options = () =>
users()
@@ -106,7 +100,7 @@ export function ParticipantManager(props: { participantCount: number }) {
when={
channelType() &&
['private'].includes(channelType()!) &&
- isChannelAdminOrOwnerMemo()
+ canManageParticipants()
}
>
<div class="flex flex-row justify-between gap-2 min-h-[40px] text-ink-muted border-b border-edge-muted/50 p-2 items-center">
diff --git a/rust/cloud-storage/comms_service/src/api/channels/add_participants.rs b/rust/cloud-storage/comms_service/src/api/channels/add_participants.rs
index 5e0fa87c6d..01deadb9a7 100644
--- a/rust/cloud-storage/comms_service/src/api/channels/add_participants.rs
+++ b/rust/cloud-storage/comms_service/src/api/channels/add_participants.rs
@@ -1,7 +1,7 @@
use crate::api::channels::create_channel::to_lowercase;
use crate::api::context::{AppState, ChannelImpl};
use crate::api::extractors::{
- ChannelAdmin, ChannelId, ChannelName, ChannelParticipants, ChannelTypeExtractor,
+ ChannelId, ChannelMember, ChannelName, ChannelParticipants, ChannelTypeExtractor,
};
use crate::notification as comms_notification;
use anyhow::Result;
@@ -28,7 +28,7 @@ pub struct AddParticipantsRequest {
post,
tag = "channels",
operation_id = "add_participants",
- description = "adds a list of participants to the channel, user must be an owner or an admin",
+ description = "adds a list of participants to the channel, user must be a participant",
path = "/channels/{channel_id}/participants",
params(
("channel_id" = String, Path, description = "channel id"),
@@ -44,7 +44,7 @@ pub struct AddParticipantsRequest {
#[axum::debug_handler]
pub async fn handler(
State(ctx): State<AppState>,
- Cached(ChannelAdmin(channel_admin)): Cached<ChannelAdmin>,
+ Cached(ChannelMember(channel_member)): Cached<ChannelMember>,
Cached(ChannelName(channel_name, ..)): Cached<ChannelName<ChannelImpl>>,
Cached(ChannelTypeExtractor(channel_type)): Cached<ChannelTypeExtractor>,
Cached(ChannelParticipants(channel_participants)): Cached<ChannelParticipants>,
@@ -106,7 +106,7 @@ pub async fn handler(
comms_notification::dispatch_notifications_for_invite(
&ctx,
&channel_id,
- &MacroUserIdStr::parse_from_str(&channel_admin.context.user_id)
+ &MacroUserIdStr::parse_from_str(&channel_member.context.user_id)
.map_err(|_e| (StatusCode::BAD_REQUEST, "Invalid macro user id".to_string()))?
.into_owned(),
req.participants.clone(),
diff --git a/rust/cloud-storage/comms_service/src/api/channels/remove_participants.rs b/rust/cloud-storage/comms_service/src/api/channels/remove_participants.rs
index 40158af5c6..5fcd3d5de6 100644
--- a/rust/cloud-storage/comms_service/src/api/channels/remove_participants.rs
+++ b/rust/cloud-storage/comms_service/src/api/channels/remove_participants.rs
@@ -1,5 +1,5 @@
use crate::api::context::AppState;
-use crate::api::extractors::{ChannelAdmin, ChannelId, ChannelTypeExtractor};
+use crate::api::extractors::{ChannelId, ChannelMember, ChannelTypeExtractor};
use anyhow::Result;
use axum::extract::Json;
use axum::{extract::State, http::StatusCode};
@@ -21,7 +21,7 @@ pub struct RemoveParticipantsRequest {
delete,
tag = "channels",
operation_id = "remove_participants",
- description = "removes a list of participants to the channel, user must be an owner or an admin",
+ description = "removes a list of participants from the channel, user must be a participant",
path = "/channels/{channel_id}/participants",
params(
("channel_id" = String, Path, description = "channel id"),
@@ -36,7 +36,7 @@ pub struct RemoveParticipantsRequest {
#[tracing::instrument(skip(ctx))]
pub async fn handler(
State(ctx): State<AppState>,
- ChannelAdmin(_channel_admin): ChannelAdmin,
+ ChannelMember(_channel_member): ChannelMember,
Cached(ChannelTypeExtractor(channel_type)): Cached<ChannelTypeExtractor>,
Cached(ChannelId(channel_id)): Cached<ChannelId>,
req: Json<RemoveParticipantsRequest>,
diff --git a/rust/cloud-storage/comms_service/src/api/extractors.rs b/rust/cloud-storage/comms_service/src/api/extractors.rs
index ff83438aef..ef72608472 100644
--- a/rust/cloud-storage/comms_service/src/api/extractors.rs
+++ b/rust/cloud-storage/comms_service/src/api/extractors.rs
@@ -379,6 +379,7 @@ where
}
#[derive(Clone, Debug)]
+#[allow(dead_code)]
pub struct ChannelAdmin(pub UserContextWithRole);
#[async_trait]