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.

chore(channels): remove organization channel type (#3674)

Will Hutchinsonb69523f03485
diff --git a/js/app/packages/channel/Participants/ChannelParticipantsTab.tsx b/js/app/packages/channel/Participants/ChannelParticipantsTab.tsx
index 4916e79ca0..3af4aa8c35 100644
--- a/js/app/packages/channel/Participants/ChannelParticipantsTab.tsx
+++ b/js/app/packages/channel/Participants/ChannelParticipantsTab.tsx
@@ -27,10 +27,8 @@ export function ChannelParticipantsTab(props: { channelId: string }) {
const [searchQuery, setSearchQuery] = createSignal('');
const participants = () => participantsQuery.data ?? [];
- const canManageParticipants = () =>
- channelType() !== ChannelType.organization;
- const canAddParticipants = () =>
- canManageParticipants() && channelType() === ChannelType.private;
+ const canAddParticipants = () => channelType() === ChannelType.private;
+ const isEditable = () => canAddParticipants();
const filteredParticipants = () => {
const query = searchQuery().trim().toLowerCase();
@@ -47,7 +45,7 @@ export function ChannelParticipantsTab(props: { channelId: string }) {
};
const addParticipants = (participantIds: string[]) => {
- if (participantIds.length === 0) return;
+ if (!isEditable() || participantIds.length === 0) return;
addParticipantsMutation.mutate({
channelId: props.channelId,
@@ -56,6 +54,8 @@ export function ChannelParticipantsTab(props: { channelId: string }) {
};
const removeParticipant = (participantId: string) => {
+ if (!isEditable()) return;
+
removeParticipantsMutation.mutate({
channelId: props.channelId,
participants: [participantId],
@@ -88,7 +88,7 @@ export function ChannelParticipantsTab(props: { channelId: string }) {
</Panel.Toolbar>
<Panel.Body>
<div class="flex h-full flex-col">
- <Show when={canAddParticipants()}>
+ <Show when={isEditable()}>
<div class="px-6 py-3 border-b border-edge-muted shrink-0">
<ParticipantsAddPanel
participants={participants}
@@ -101,7 +101,7 @@ export function ChannelParticipantsTab(props: { channelId: string }) {
participants={filteredParticipants}
searchQuery={searchQuery}
currentUserId={userId() ?? undefined}
- editable={canManageParticipants()}
+ editable={isEditable()}
onParticipantClick={openDirectMessage}
onRemoveParticipant={removeParticipant}
/>
diff --git a/js/app/packages/core/component/EntityIcon.tsx b/js/app/packages/core/component/EntityIcon.tsx
index 3416c971c5..0708b4421f 100644
--- a/js/app/packages/core/component/EntityIcon.tsx
+++ b/js/app/packages/core/component/EntityIcon.tsx
@@ -72,6 +72,7 @@ export type EntityWithValidIcon =
| BlockName
| BlockAlias
| ChannelType
+ | 'organization'
| 'default'
| 'sharedProject'
| 'emailRead'
@@ -120,7 +121,7 @@ export const ENTITY_ICON_CONFIGS: Record<EntityWithValidIcon, IconConfig> = {
icon: Building,
foreground: 'text-default',
background: 'bg-default/20',
- prettyName: 'Organization Channel',
+ prettyName: 'Organization',
},
private: {
icon: WideChannel,
diff --git a/js/app/packages/entity/mocks/mockEntityData.ts b/js/app/packages/entity/mocks/mockEntityData.ts
index 45c43ff7c2..3f67f87928 100644
--- a/js/app/packages/entity/mocks/mockEntityData.ts
+++ b/js/app/packages/entity/mocks/mockEntityData.ts
@@ -320,12 +320,12 @@ const MOCK_CHANNEL_DIRECT_MESSAGE: ChannelEntity = {
frecencyScore: 0.87,
};
-const MOCK_CHANNEL_ORGANIZATION: ChannelEntity = {
+const MOCK_CHANNEL_ANNOUNCEMENTS: ChannelEntity = {
type: 'channel',
- id: 'channel_org_1',
+ id: 'channel_announcements_1',
name: 'company-announcements',
ownerId: MOCK_USER_IDS.owner,
- channelType: 'organization',
+ channelType: 'private',
createdAt: MOCK_TIMESTAMPS.lastYear,
updatedAt: MOCK_TIMESTAMPS.lastWeek,
interactedAt: MOCK_TIMESTAMPS.lastWeek,
@@ -710,7 +710,7 @@ const ALL_CHANNEL_ENTITIES = [
MOCK_CHANNEL_PUBLIC,
MOCK_CHANNEL_PRIVATE,
MOCK_CHANNEL_DIRECT_MESSAGE,
- MOCK_CHANNEL_ORGANIZATION,
+ MOCK_CHANNEL_ANNOUNCEMENTS,
MOCK_CHANNEL_EMPTY_MESSAGE,
];
diff --git a/js/app/packages/entity/src/types/entity.ts b/js/app/packages/entity/src/types/entity.ts
index 99e0fd73f1..86bba53cc3 100644
--- a/js/app/packages/entity/src/types/entity.ts
+++ b/js/app/packages/entity/src/types/entity.ts
@@ -18,12 +18,7 @@ export type EntityBase = {
export type ChannelEntity = EntityBase & {
type: 'channel';
- channelType:
- | 'direct_message'
- | 'private'
- | 'organization'
- | 'public'
- | 'team';
+ channelType: 'direct_message' | 'private' | 'public' | 'team';
interactedAt?: DateValue | null;
participantIds?: string[];
latestMessage?: {
diff --git a/js/app/packages/notifications/tests/notification-stacking.test.ts b/js/app/packages/notifications/tests/notification-stacking.test.ts
index 36bb0aec2a..96ca7d0af1 100644
--- a/js/app/packages/notifications/tests/notification-stacking.test.ts
+++ b/js/app/packages/notifications/tests/notification-stacking.test.ts
@@ -41,7 +41,7 @@ function createNewMessageNotification(
messageId,
messageContent: `Message ${id}`,
sender: 'user-1',
- channelType: 'organization',
+ channelType: 'private',
},
});
}
@@ -59,7 +59,7 @@ function createReplyNotification(
threadId,
messageContent: `Reply ${id}`,
userId: 'user-1',
- channelType: 'organization',
+ channelType: 'private',
},
});
}
@@ -76,7 +76,7 @@ function createMentionNotification(
messageId,
messageContent: `Mention ${id}`,
threadId: threadId ?? null,
- channelType: 'organization',
+ channelType: 'private',
},
});
}
diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/channelType.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/channelType.ts
index 3d1ff55a7c..fe82879434 100644
--- a/js/app/packages/service-clients/service-cognition/generated/schemas/channelType.ts
+++ b/js/app/packages/service-clients/service-cognition/generated/schemas/channelType.ts
@@ -10,7 +10,6 @@ export type ChannelType = (typeof ChannelType)[keyof typeof ChannelType];
// eslint-disable-next-line @typescript-eslint/no-redeclare
export const ChannelType = {
public: 'public',
- organization: 'organization',
private: 'private',
direct_message: 'direct_message',
team: 'team',
diff --git a/js/app/packages/service-clients/service-cognition/openapi.json b/js/app/packages/service-clients/service-cognition/openapi.json
index 1ff5b625a0..f4baf98e4a 100644
--- a/js/app/packages/service-clients/service-cognition/openapi.json
+++ b/js/app/packages/service-clients/service-cognition/openapi.json
@@ -1679,7 +1679,7 @@
},
"ChannelType": {
"type": "string",
- "enum": ["public", "organization", "private", "direct_message", "team"]
+ "enum": ["public", "private", "direct_message", "team"]
},
"Chat": {
"type": "object",
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/channelType.ts b/js/app/packages/service-clients/service-notification/generated/schemas/channelType.ts
index 1c999d84ff..25dee010e2 100644
--- a/js/app/packages/service-clients/service-notification/generated/schemas/channelType.ts
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/channelType.ts
@@ -10,7 +10,6 @@ export type ChannelType = (typeof ChannelType)[keyof typeof ChannelType];
// eslint-disable-next-line @typescript-eslint/no-redeclare
export const ChannelType = {
public: 'public',
- organization: 'organization',
private: 'private',
directMessage: 'directMessage',
team: 'team',
diff --git a/js/app/packages/service-clients/service-notification/generated/zod.ts b/js/app/packages/service-clients/service-notification/generated/zod.ts
index ee41e3b2b5..368a86a7f8 100644
--- a/js/app/packages/service-clients/service-notification/generated/zod.ts
+++ b/js/app/packages/service-clients/service-notification/generated/zod.ts
@@ -152,7 +152,6 @@ export const listTypedNotificationsResponse = zod
channelName: zod.string().optional(),
channelType: zod.enum([
'public',
- 'organization',
'private',
'directMessage',
'team',
@@ -186,7 +185,6 @@ export const listTypedNotificationsResponse = zod
channelName: zod.string().optional(),
channelType: zod.enum([
'public',
- 'organization',
'private',
'directMessage',
'team',
@@ -397,7 +395,6 @@ export const listTypedNotificationsResponse = zod
channelName: zod.string().optional(),
channelType: zod.enum([
'public',
- 'organization',
'private',
'directMessage',
'team',
@@ -429,7 +426,6 @@ export const listTypedNotificationsResponse = zod
channelName: zod.string().optional(),
channelType: zod.enum([
'public',
- 'organization',
'private',
'directMessage',
'team',
@@ -670,7 +666,6 @@ export const bulkGetTypedNotificationsByEventItemIdsResponse = zod
channelName: zod.string().optional(),
channelType: zod.enum([
'public',
- 'organization',
'private',
'directMessage',
'team',
@@ -704,7 +699,6 @@ export const bulkGetTypedNotificationsByEventItemIdsResponse = zod
channelName: zod.string().optional(),
channelType: zod.enum([
'public',
- 'organization',
'private',
'directMessage',
'team',
@@ -915,7 +909,6 @@ export const bulkGetTypedNotificationsByEventItemIdsResponse = zod
channelName: zod.string().optional(),
channelType: zod.enum([
'public',
- 'organization',
'private',
'directMessage',
'team',
@@ -947,7 +940,6 @@ export const bulkGetTypedNotificationsByEventItemIdsResponse = zod
channelName: zod.string().optional(),
channelType: zod.enum([
'public',
- 'organization',
'private',
'directMessage',
'team',
@@ -1182,7 +1174,6 @@ export const getTypedNotificationsByEventItemIdResponse = zod
channelName: zod.string().optional(),
channelType: zod.enum([
'public',
- 'organization',
'private',
'directMessage',
'team',
@@ -1216,7 +1207,6 @@ export const getTypedNotificationsByEventItemIdResponse = zod
channelName: zod.string().optional(),
channelType: zod.enum([
'public',
- 'organization',
'private',
'directMessage',
'team',
@@ -1427,7 +1417,6 @@ export const getTypedNotificationsByEventItemIdResponse = zod
channelName: zod.string().optional(),
channelType: zod.enum([
'public',
- 'organization',
'private',
'directMessage',
'team',
@@ -1459,7 +1448,6 @@ export const getTypedNotificationsByEventItemIdResponse = zod
channelName: zod.string().optional(),
channelType: zod.enum([
'public',
- 'organization',
'private',
'directMessage',
'team',
@@ -1705,7 +1693,6 @@ export const getTypedNotificationByIdResponse = zod
channelName: zod.string().optional(),
channelType: zod.enum([
'public',
- 'organization',
'private',
'directMessage',
'team',
@@ -1737,7 +1724,6 @@ export const getTypedNotificationByIdResponse = zod
channelName: zod.string().optional(),
channelType: zod.enum([
'public',
- 'organization',
'private',
'directMessage',
'team',
@@ -1930,7 +1916,6 @@ export const getTypedNotificationByIdResponse = zod
channelName: zod.string().optional(),
channelType: zod.enum([
'public',
- 'organization',
'private',
'directMessage',
'team',
@@ -1960,7 +1945,6 @@ export const getTypedNotificationByIdResponse = zod
channelName: zod.string().optional(),
channelType: zod.enum([
'public',
- 'organization',
'private',
'directMessage',
'team',
diff --git a/js/app/packages/service-clients/service-notification/openapi.json b/js/app/packages/service-clients/service-notification/openapi.json
index ddb4bf6534..d2bbeae9fe 100644
--- a/js/app/packages/service-clients/service-notification/openapi.json
+++ b/js/app/packages/service-clients/service-notification/openapi.json
@@ -1220,7 +1220,7 @@
},
"ChannelType": {
"type": "string",
- "enum": ["public", "organization", "private", "directMessage", "team"]
+ "enum": ["public", "private", "directMessage", "team"]
},
"CommentedOnDocumentMetadata": {
"type": "object",
diff --git a/js/app/packages/service-clients/service-storage/client.ts b/js/app/packages/service-clients/service-storage/client.ts
index eb77dcb0f4..ab82614d03 100644
--- a/js/app/packages/service-clients/service-storage/client.ts
+++ b/js/app/packages/service-clients/service-storage/client.ts
@@ -214,7 +214,6 @@ export type ChannelAttachmentType = 'static' | 'dss';
export const ChannelTypeEnum = {
Public: ChannelType.public,
- Organization: ChannelType.organization,
Private: ChannelType.private,
DirectMessage: ChannelType.direct_message,
Team: ChannelType.team,
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/channelType.ts b/js/app/packages/service-clients/service-storage/generated/schemas/channelType.ts
index d1c560ce7d..db43c05a6e 100644
--- a/js/app/packages/service-clients/service-storage/generated/schemas/channelType.ts
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/channelType.ts
@@ -13,7 +13,6 @@ export type ChannelType = (typeof ChannelType)[keyof typeof ChannelType];
// eslint-disable-next-line @typescript-eslint/no-redeclare
export const ChannelType = {
public: 'public',
- organization: 'organization',
private: 'private',
direct_message: 'direct_message',
team: 'team',
diff --git a/js/app/packages/service-clients/service-storage/generated/zod.ts b/js/app/packages/service-clients/service-storage/generated/zod.ts
index 4a2354bef0..25acd6adf2 100644
--- a/js/app/packages/service-clients/service-storage/generated/zod.ts
+++ b/js/app/packages/service-clients/service-storage/generated/zod.ts
@@ -1250,7 +1250,7 @@ export const ingestTranscriptBody = zod
export const createChannelBody = zod
.object({
channel_type: zod
- .enum(['public', 'organization', 'private', 'direct_message', 'team'])
+ .enum(['public', 'private', 'direct_message', 'team'])
.describe('Type of channel.'),
name: zod.string().nullish().describe('Optional channel name.'),
participants: zod
@@ -1509,13 +1509,7 @@ export const getBatchChannelPreviewResponse = zod
.string()
.describe('Resolved channel display name.'),
channel_type: zod
- .enum([
- 'public',
- 'organization',
- 'private',
- 'direct_message',
- 'team',
- ])
+ .enum(['public', 'private', 'direct_message', 'team'])
.describe('Type of channel.'),
})
.describe('Preview payload returned for accessible channels.')
@@ -1582,7 +1576,7 @@ export const getChannelResponse = zod
.string()
.describe("Resolved display name from the viewer's perspective."),
channel_type: zod
- .enum(['public', 'organization', 'private', 'direct_message', 'team'])
+ .enum(['public', 'private', 'direct_message', 'team'])
.describe('Type of channel.'),
messages: zod
.array(
@@ -6878,13 +6872,7 @@ export const getItemsSoupResponse = zod.object({
.object({
channel: zod.object({
channel_type: zod
- .enum([
- 'public',
- 'organization',
- 'private',
- 'direct_message',
- 'team',
- ])
+ .enum(['public', 'private', 'direct_message', 'team'])
.describe('Type of channel.'),
created_at: zod.iso.datetime({}),
id: zod.uuid(),
@@ -8731,13 +8719,7 @@ export const postItemsSoupResponse = zod.object({
.object({
channel: zod.object({
channel_type: zod
- .enum([
- 'public',
- 'organization',
- 'private',
- 'direct_message',
- 'team',
- ])
+ .enum(['public', 'private', 'direct_message', 'team'])
.describe('Type of channel.'),
created_at: zod.iso.datetime({}),
id: zod.uuid(),
@@ -10177,13 +10159,7 @@ export const postItemsSoupAstResponse = zod.object({
.object({
channel: zod.object({
channel_type: zod
- .enum([
- 'public',
- 'organization',
- 'private',
- 'direct_message',
- 'team',
- ])
+ .enum(['public', 'private', 'direct_message', 'team'])
.describe('Type of channel.'),
created_at: zod.iso.datetime({}),
id: zod.uuid(),
diff --git a/js/app/packages/service-clients/service-storage/openapi.json b/js/app/packages/service-clients/service-storage/openapi.json
index ddea1d055c..41da0d798d 100644
--- a/js/app/packages/service-clients/service-storage/openapi.json
+++ b/js/app/packages/service-clients/service-storage/openapi.json
@@ -10025,7 +10025,7 @@
"ChannelType": {
"type": "string",
"description": "Type of channel.",
- "enum": ["public", "organization", "private", "direct_message", "team"]
+ "enum": ["public", "private", "direct_message", "team"]
},
"ChannelWithParticipants": {
"type": "object",
diff --git a/js/app/tests/e2e/fixtures/local-e2e-seed.ts b/js/app/tests/e2e/fixtures/local-e2e-seed.ts
index 3d26dee403..e7b74968de 100644
--- a/js/app/tests/e2e/fixtures/local-e2e-seed.ts
+++ b/js/app/tests/e2e/fixtures/local-e2e-seed.ts
@@ -47,12 +47,7 @@ export type SeedDocument = {
export type SeedChannel = {
channel_id: string;
channel_name?: string;
- channel_type:
- | 'public'
- | 'private'
- | 'direct_message'
- | 'organization'
- | 'team';
+ channel_type: 'public' | 'private' | 'direct_message' | 'team';
participants: string[];
};
diff --git a/rust/cloud-storage/.sqlx/query-10843b4044bca618301e755b0b6b5aeca5fd398adc48ed9f755490fa25e7f3f9.json b/rust/cloud-storage/.sqlx/query-10843b4044bca618301e755b0b6b5aeca5fd398adc48ed9f755490fa25e7f3f9.json
index 1317474022..2c80a4edcb 100644
--- a/rust/cloud-storage/.sqlx/query-10843b4044bca618301e755b0b6b5aeca5fd398adc48ed9f755490fa25e7f3f9.json
+++ b/rust/cloud-storage/.sqlx/query-10843b4044bca618301e755b0b6b5aeca5fd398adc48ed9f755490fa25e7f3f9.json
@@ -16,7 +16,6 @@
"kind": {
"Enum": [
"public",
- "organization",
"private",
"direct_message",
"team"
diff --git a/rust/cloud-storage/.sqlx/query-3c53847bf278b4452c56d695306bb384f3a9354e7e078bfc73ffd0b95f46dd03.json b/rust/cloud-storage/.sqlx/query-3c53847bf278b4452c56d695306bb384f3a9354e7e078bfc73ffd0b95f46dd03.json
deleted file mode 100644
index 0d46873a60..0000000000
--- a/rust/cloud-storage/.sqlx/query-3c53847bf278b4452c56d695306bb384f3a9354e7e078bfc73ffd0b95f46dd03.json
+++ /dev/null
@@ -1,23 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n WITH user_channels AS (\n SELECT DISTINCT c.*\n FROM comms_channels c\n INNER JOIN comms_channel_participants cp ON cp.channel_id = c.id\n WHERE cp.user_id = $1 AND cp.left_at IS NULL\n \n UNION\n \n SELECT c.*\n FROM comms_channels c\n WHERE c.channel_type = 'organization'::comms_channel_type\n AND c.org_id = $2::bigint\n )\n SELECT \n id as \"id!\"\n FROM user_channels\n ORDER BY created_at DESC\n ",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "id!",
- "type_info": "Uuid"
- }
- ],
- "parameters": {
- "Left": [
- "Text",
- "Int8"
- ]
- },
- "nullable": [
- null
- ]
- },
- "hash": "3c53847bf278b4452c56d695306bb384f3a9354e7e078bfc73ffd0b95f46dd03"
-}
diff --git a/rust/cloud-storage/.sqlx/query-5c47456f9d7becea7d008197fd7693632c755978abb9b4ff9cff3fd95b09b535.json b/rust/cloud-storage/.sqlx/query-3fcda7a3b41d62cae64507950b3344b931487b41c9b146538d6d1769033c3046.json
similarity index 63%
rename from rust/cloud-storage/.sqlx/query-5c47456f9d7becea7d008197fd7693632c755978abb9b4ff9cff3fd95b09b535.json
rename to rust/cloud-storage/.sqlx/query-3fcda7a3b41d62cae64507950b3344b931487b41c9b146538d6d1769033c3046.json
index ef72c7e2b8..5bc1c5aaef 100644
--- a/rust/cloud-storage/.sqlx/query-5c47456f9d7becea7d008197fd7693632c755978abb9b4ff9cff3fd95b09b535.json
+++ b/rust/cloud-storage/.sqlx/query-3fcda7a3b41d62cae64507950b3344b931487b41c9b146538d6d1769033c3046.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "\n SELECT\n c.id,\n c.name,\n c.channel_type AS \"channel_type: ChannelType\",\n c.org_id,\n c.team_id,\n CASE WHEN (\n c.channel_type = 'public'\n OR\n (c.channel_type = 'organization' AND $3::bigint IS NOT NULL AND c.org_id = $3)\n OR\n (c.channel_type IN ('private', 'direct_message', 'team') AND EXISTS (\n SELECT 1 FROM comms_channel_participants cp\n WHERE cp.channel_id = c.id\n AND cp.user_id = $2\n AND cp.left_at IS NULL\n ))\n ) THEN true ELSE false END AS \"has_access!: bool\"\n FROM comms_channels c\n WHERE c.id::text = ANY($1)\n AND (c.channel_type != 'organization' OR $3::bigint IS NOT NULL)\n ",
+ "query": "\n SELECT\n c.id,\n c.name,\n c.channel_type AS \"channel_type: ChannelType\",\n c.org_id,\n c.team_id,\n CASE WHEN (\n c.channel_type = 'public'\n OR\n (c.channel_type IN ('private', 'direct_message', 'team') AND EXISTS (\n SELECT 1 FROM comms_channel_participants cp\n WHERE cp.channel_id = c.id\n AND cp.user_id = $2\n AND cp.left_at IS NULL\n ))\n ) THEN true ELSE false END AS \"has_access!: bool\"\n FROM comms_channels c\n WHERE c.id::text = ANY($1)\n ",
"describe": {
"columns": [
{
@@ -22,7 +22,6 @@
"kind": {
"Enum": [
"public",
- "organization",
"private",
"direct_message",
"team"
@@ -50,8 +49,7 @@
"parameters": {
"Left": [
"TextArray",
- "Text",
- "Int8"
+ "Text"
]
},
"nullable": [
@@ -63,5 +61,5 @@
null
]
},
- "hash": "5c47456f9d7becea7d008197fd7693632c755978abb9b4ff9cff3fd95b09b535"
+ "hash": "3fcda7a3b41d62cae64507950b3344b931487b41c9b146538d6d1769033c3046"
}
diff --git a/rust/cloud-storage/.sqlx/query-4465cdde5f953cd550e7190572d8e5e4c70fce8558763d56a3f57e99474a9aeb.json b/rust/cloud-storage/.sqlx/query-4465cdde5f953cd550e7190572d8e5e4c70fce8558763d56a3f57e99474a9aeb.json
index 8f303de688..a891deb671 100644
--- a/rust/cloud-storage/.sqlx/query-4465cdde5f953cd550e7190572d8e5e4c70fce8558763d56a3f57e99474a9aeb.json
+++ b/rust/cloud-storage/.sqlx/query-4465cdde5f953cd550e7190572d8e5e4c70fce8558763d56a3f57e99474a9aeb.json
@@ -21,7 +21,6 @@
"kind": {
"Enum": [
"public",
- "organization",
"private",
"direct_message",
"team"
diff --git a/rust/cloud-storage/.sqlx/query-45064c055927af781bc06e3a602a9efbefbd111110b9f0fab5cf029e70208c1e.json b/rust/cloud-storage/.sqlx/query-45064c055927af781bc06e3a602a9efbefbd111110b9f0fab5cf029e70208c1e.json
index ddaefc32ef..8e34d4b90f 100644
--- a/rust/cloud-storage/.sqlx/query-45064c055927af781bc06e3a602a9efbefbd111110b9f0fab5cf029e70208c1e.json
+++ b/rust/cloud-storage/.sqlx/query-45064c055927af781bc06e3a602a9efbefbd111110b9f0fab5cf029e70208c1e.json
@@ -22,7 +22,6 @@
"kind": {
"Enum": [
"public",
- "organization",
"private",
"direct_message",
"team"
diff --git a/rust/cloud-storage/.sqlx/query-5429a0ff80ba0e9394eb205bddbb2dc247030b9e6eb3a750e30cdd770bf92fa9.json b/rust/cloud-storage/.sqlx/query-5429a0ff80ba0e9394eb205bddbb2dc247030b9e6eb3a750e30cdd770bf92fa9.json
index c6eb93ad48..77d591f6f4 100644
--- a/rust/cloud-storage/.sqlx/query-5429a0ff80ba0e9394eb205bddbb2dc247030b9e6eb3a750e30cdd770bf92fa9.json
+++ b/rust/cloud-storage/.sqlx/query-5429a0ff80ba0e9394eb205bddbb2dc247030b9e6eb3a750e30cdd770bf92fa9.json
@@ -22,7 +22,6 @@
"kind": {
"Enum": [
"public",
- "organization",
"private",
"direct_message",
"team"
diff --git a/rust/cloud-storage/.sqlx/query-6038d459d2d8e60479180f5b8a756380bda195f4769b6420e601ed147a9439f9.json b/rust/cloud-storage/.sqlx/query-6038d459d2d8e60479180f5b8a756380bda195f4769b6420e601ed147a9439f9.json
index a8e38250f7..7f19805b0c 100644
--- a/rust/cloud-storage/.sqlx/query-6038d459d2d8e60479180f5b8a756380bda195f4769b6420e601ed147a9439f9.json
+++ b/rust/cloud-storage/.sqlx/query-6038d459d2d8e60479180f5b8a756380bda195f4769b6420e601ed147a9439f9.json
@@ -42,7 +42,6 @@
"kind": {
"Enum": [
"public",
- "organization",
"private",
"direct_message",
"team"
diff --git a/rust/cloud-storage/.sqlx/query-769d1b9f8e1e88c30aabe8698b9d64bfc2b69def0b66bbd9d4010f81617b4ce3.json b/rust/cloud-storage/.sqlx/query-769d1b9f8e1e88c30aabe8698b9d64bfc2b69def0b66bbd9d4010f81617b4ce3.json
deleted file mode 100644
index df6dfbd303..0000000000
--- a/rust/cloud-storage/.sqlx/query-769d1b9f8e1e88c30aabe8698b9d64bfc2b69def0b66bbd9d4010f81617b4ce3.json
+++ /dev/null
@@ -1,71 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n SELECT \n id as \"id!\",\n name as \"name!\",\n channel_type as \"channel_type!: ChannelType\",\n org_id, -- This can be NULL\n created_at as \"created_at!\",\n updated_at as \"updated_at!\",\n owner_id as \"owner_id!\"\n FROM comms_channels\n WHERE channel_type = 'organization'::comms_channel_type\n AND org_id = $1::bigint\n ORDER BY created_at DESC\n ",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "id!",
- "type_info": "Uuid"
- },
- {
- "ordinal": 1,
- "name": "name!",
- "type_info": "Varchar"
- },
- {
- "ordinal": 2,
- "name": "channel_type!: ChannelType",
- "type_info": {
- "Custom": {
- "name": "comms_channel_type",
- "kind": {
- "Enum": [
- "public",
- "organization",
- "private",
- "direct_message",
- "team"
- ]
- }
- }
- }
- },
- {
- "ordinal": 3,
- "name": "org_id",
- "type_info": "Int8"
- },
- {
- "ordinal": 4,
- "name": "created_at!",
- "type_info": "Timestamptz"
- },
- {
- "ordinal": 5,
- "name": "updated_at!",
- "type_info": "Timestamptz"
- },
- {
- "ordinal": 6,
- "name": "owner_id!",
- "type_info": "Text"
- }
- ],
- "parameters": {
- "Left": [
- "Int8"
- ]
- },
- "nullable": [
- false,
- true,
- false,
- true,
- false,
- false,
- false
- ]
- },
- "hash": "769d1b9f8e1e88c30aabe8698b9d64bfc2b69def0b66bbd9d4010f81617b4ce3"
-}
diff --git a/rust/cloud-storage/.sqlx/query-783fb2d2833135d5bf8aa7eb5983b773d4b7c9b508388987155815d8c7e1db3b.json b/rust/cloud-storage/.sqlx/query-783fb2d2833135d5bf8aa7eb5983b773d4b7c9b508388987155815d8c7e1db3b.json
index 07229f5fe0..3377919e1e 100644
--- a/rust/cloud-storage/.sqlx/query-783fb2d2833135d5bf8aa7eb5983b773d4b7c9b508388987155815d8c7e1db3b.json
+++ b/rust/cloud-storage/.sqlx/query-783fb2d2833135d5bf8aa7eb5983b773d4b7c9b508388987155815d8c7e1db3b.json
@@ -22,7 +22,6 @@
"kind": {
"Enum": [
"public",
- "organization",
"private",
"direct_message",
"team"
diff --git a/rust/cloud-storage/.sqlx/query-8b640c24a0a71ba83db60c1bd7a273aae232cbb8fab78cf029c66ec1e8576b61.json b/rust/cloud-storage/.sqlx/query-8b640c24a0a71ba83db60c1bd7a273aae232cbb8fab78cf029c66ec1e8576b61.json
deleted file mode 100644
index 238e214685..0000000000
--- a/rust/cloud-storage/.sqlx/query-8b640c24a0a71ba83db60c1bd7a273aae232cbb8fab78cf029c66ec1e8576b61.json
+++ /dev/null
@@ -1,23 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n SELECT\n c.id\n FROM\n comms_channels c\n WHERE\n c.id = ANY($1)\n AND c.channel_type = 'organization'\n AND c.org_id = $2\n ",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "id",
- "type_info": "Uuid"
- }
- ],
- "parameters": {
- "Left": [
- "UuidArray",
- "Int8"
- ]
- },
- "nullable": [
- false
- ]
- },
- "hash": "8b640c24a0a71ba83db60c1bd7a273aae232cbb8fab78cf029c66ec1e8576b61"
-}
diff --git a/rust/cloud-storage/.sqlx/query-908627bdd27f344ce26c501bb7431b621173c04bfda9678021360817c3f25103.json b/rust/cloud-storage/.sqlx/query-908627bdd27f344ce26c501bb7431b621173c04bfda9678021360817c3f25103.json
index d509d3fe6f..ad59b616b1 100644
--- a/rust/cloud-storage/.sqlx/query-908627bdd27f344ce26c501bb7431b621173c04bfda9678021360817c3f25103.json
+++ b/rust/cloud-storage/.sqlx/query-908627bdd27f344ce26c501bb7431b621173c04bfda9678021360817c3f25103.json
@@ -22,7 +22,6 @@
"kind": {
"Enum": [
"public",
- "organization",
"private",
"direct_message",
"team"
diff --git a/rust/cloud-storage/.sqlx/query-b2dc0d50f7cd7e961844c553feed81200e213e4f28cc7d2940a93aabe83877b0.json b/rust/cloud-storage/.sqlx/query-b2dc0d50f7cd7e961844c553feed81200e213e4f28cc7d2940a93aabe83877b0.json
new file mode 100644
index 0000000000..9f9c30968a
--- /dev/null
+++ b/rust/cloud-storage/.sqlx/query-b2dc0d50f7cd7e961844c553feed81200e213e4f28cc7d2940a93aabe83877b0.json
@@ -0,0 +1,22 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n WITH user_channels AS (\n SELECT DISTINCT c.id, c.created_at\n FROM comms_channels c\n INNER JOIN comms_channel_participants cp ON cp.channel_id = c.id\n WHERE cp.user_id = $1 AND cp.left_at IS NULL\n )\n SELECT\n id as \"id!\"\n FROM user_channels\n ORDER BY created_at DESC\n ",
+ "describe": {
+ "columns": [
+ {
+ "ordinal": 0,
+ "name": "id!",
+ "type_info": "Uuid"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "Text"
+ ]
+ },
+ "nullable": [
+ false
+ ]
+ },
+ "hash": "b2dc0d50f7cd7e961844c553feed81200e213e4f28cc7d2940a93aabe83877b0"
+}
diff --git a/rust/cloud-storage/.sqlx/query-c5d7f14d70f0de5fd07ae24e50441f5a5dd574ae4492f2adebd98021dbaab771.json b/rust/cloud-storage/.sqlx/query-c5d7f14d70f0de5fd07ae24e50441f5a5dd574ae4492f2adebd98021dbaab771.json
index 2310e27b0d..fd366fd300 100644
--- a/rust/cloud-storage/.sqlx/query-c5d7f14d70f0de5fd07ae24e50441f5a5dd574ae4492f2adebd98021dbaab771.json
+++ b/rust/cloud-storage/.sqlx/query-c5d7f14d70f0de5fd07ae24e50441f5a5dd574ae4492f2adebd98021dbaab771.json
@@ -22,7 +22,6 @@
"kind": {
"Enum": [
"public",
- "organization",
"private",
"direct_message",
"team"
diff --git a/rust/cloud-storage/authentication_service/src/api/webhooks/user/create_user_webhook.rs b/rust/cloud-storage/authentication_service/src/api/webhooks/user/create_user_webhook.rs
index 5403e36ee4..e1724211f3 100644
--- a/rust/cloud-storage/authentication_service/src/api/webhooks/user/create_user_webhook.rs
+++ b/rust/cloud-storage/authentication_service/src/api/webhooks/user/create_user_webhook.rs
@@ -4,14 +4,8 @@ use axum::{
http::StatusCode,
response::{IntoResponse, Response},
};
-use comms_db_client::{
- channels::get_channels::get_org_channels,
- participants::add_participant::{AddParticipantOptions, add_participant},
-};
use macro_middleware::auth::internal_access::ValidInternalKey;
-use model::comms::ParticipantRole;
use rand::Rng;
-use sqlx::{Pool, Postgres};
use crate::{api::context::ApiContext, rate_limit_config::RATE_LIMIT_CONFIG};
use authentication_service::service::user::create_user::create_user;
@@ -186,19 +180,6 @@ async fn create_user_webhook(ctx: &ApiContext, req: FusionAuthUserWebhook) -> an
}
});
- // If the user belongs to an organization,
- // we should add them to the organization's channels
- if let Some(org_id) = organization_id {
- let db = ctx.db.clone();
- let user_id = user_id.clone();
- tracing::trace!("adding user to org channels directly via db");
- tokio::spawn(async move {
- if let Err(err) = add_user_to_org_channels(&db, &user_id, org_id as i64).await {
- tracing::error!(error=?err, "failed to add user to org channels");
- }
- });
- }
-
tracing::trace!(email, fusionauth_user_id, elapsed=?start_time.elapsed(), "created user");
// Allow to fail silently
@@ -282,26 +263,3 @@ async fn initialize_user_experiments(
Ok(())
}
-
-/// Adds a user to all organization channels
-async fn add_user_to_org_channels(
- db: &Pool<Postgres>,
- user_id: &str,
- org_id: i64,
-) -> anyhow::Result<()> {
- let org_channels = get_org_channels(db, &org_id).await?;
-
- for channel in org_channels.iter() {
- add_participant(
- db,
- AddParticipantOptions {
- channel_id: &channel.id.0,
- user_id,
- participant_role: Some(ParticipantRole::Member),
- },
- )
- .await?;
- }
-
- Ok(())
-}
diff --git a/rust/cloud-storage/channels/src/domain/models.rs b/rust/cloud-storage/channels/src/domain/models.rs
index e8263e6883..00daf858e3 100644
--- a/rust/cloud-storage/channels/src/domain/models.rs
+++ b/rust/cloud-storage/channels/src/domain/models.rs
@@ -518,8 +518,6 @@ pub struct ThreadReplyRow {
pub enum ChannelType {
/// Public channel.
Public,
- /// Organization-wide channel.
- Organization,
/// Private group channel.
Private,
/// One-to-one direct message channel.
diff --git a/rust/cloud-storage/channels/src/domain/ports.rs b/rust/cloud-storage/channels/src/domain/ports.rs
index b09df3daee..87556cf046 100644
--- a/rust/cloud-storage/channels/src/domain/ports.rs
+++ b/rust/cloud-storage/channels/src/domain/ports.rs
@@ -136,7 +136,7 @@ pub trait ChannelRepo: Send + Sync + 'static {
) -> impl Future<Output = Result<ChannelMetadata, Self::Err>> + Send;
/// Batch fetch channel preview rows for the requested ids, computing
- /// per-channel access for the given viewer/org.
+ /// per-channel access for the given viewer.
fn batch_get_channel_previews(
&self,
channel_ids: &[String],
diff --git a/rust/cloud-storage/channels/src/domain/service.rs b/rust/cloud-storage/channels/src/domain/service.rs
index 8fc019cb41..ac29eab815 100644
--- a/rust/cloud-storage/channels/src/domain/service.rs
+++ b/rust/cloud-storage/channels/src/domain/service.rs
@@ -247,7 +247,7 @@ where
async fn create_channel(
&self,
actor: Sender,
- actor_org_id: Option<i64>,
+ _actor_org_id: Option<i64>,
req: crate::domain::models::CreateChannelRequest,
) -> Result<crate::domain::models::CreateChannelResponse, ChannelMutationErr> {
let actor = require_user_actor(&actor)?;
@@ -273,10 +273,7 @@ where
));
}
- let org_id = match req.channel_type {
- ChannelType::Organization => actor_org_id,
- _ => None,
- };
+ let org_id = None;
let participants = lower_macro_users(&req.participants);
if participants.is_empty() {
return Err(ChannelMutationErr::BadRequest(
@@ -930,11 +927,6 @@ where
.await
.map_err(|e| ChannelMutationErr::Repo(e.into()))?;
match (info.channel_type, participants.len()) {
- (ChannelType::Organization, _) => {
- return Err(ChannelMutationErr::BadRequest(
- "cannot leave organization channel".to_string(),
- ));
- }
(ChannelType::Private, 2) | (ChannelType::DirectMessage, _) => {
return Err(ChannelMutationErr::BadRequest(
"cannot leave channel with only 2 participants".to_string(),
@@ -1484,10 +1476,10 @@ where
async fn create_channel(
&self,
actor: Sender,
- actor_org_id: Option<i64>,
+ _actor_org_id: Option<i64>,
req: crate::domain::models::CreateChannelRequest,
) -> Result<crate::domain::models::CreateChannelResponse, ChannelMutationErr> {
- ChannelServiceImpl::create_channel(self, actor, actor_org_id, req).await
+ ChannelServiceImpl::create_channel(self, actor, None, req).await
}
async fn get_or_create_dm(
diff --git a/rust/cloud-storage/channels/src/outbound/notification_sender.rs b/rust/cloud-storage/channels/src/outbound/notification_sender.rs
index 8928d3e098..e8e069df19 100644
--- a/rust/cloud-storage/channels/src/outbound/notification_sender.rs
+++ b/rust/cloud-storage/channels/src/outbound/notification_sender.rs
@@ -33,7 +33,6 @@ impl<I> NotificationChannelSender<I> {
fn to_notification_channel_type(channel_type: ChannelType) -> model_notifications::ChannelType {
match channel_type {
ChannelType::Public => model_notifications::ChannelType::Public,
- ChannelType::Organization => model_notifications::ChannelType::Organization,
ChannelType::Private => model_notifications::ChannelType::Private,
ChannelType::DirectMessage => model_notifications::ChannelType::DirectMessage,
ChannelType::Team => model_notifications::ChannelType::Team,
diff --git a/rust/cloud-storage/channels/src/outbound/pg_channels_repo.rs b/rust/cloud-storage/channels/src/outbound/pg_channels_repo.rs
index 11523abb56..8fd3387e46 100644
--- a/rust/cloud-storage/channels/src/outbound/pg_channels_repo.rs
+++ b/rust/cloud-storage/channels/src/outbound/pg_channels_repo.rs
@@ -474,10 +474,6 @@ fn static_channel_name(
}
match channel_type {
- ChannelType::Organization => {
- tracing::warn!(channel_id=%channel_id, "organization channel should have a name");
- "Organization".to_string()
- }
ChannelType::Public => {
tracing::warn!(channel_id=%channel_id, "public channel should have a name");
"Public".to_string()
@@ -496,9 +492,11 @@ async fn resolve_channel_display_name(
viewer_user_id: MacroUserIdStr<'_>,
) -> anyhow::Result<String> {
match info.channel_type {
- ChannelType::Organization | ChannelType::Public | ChannelType::Team => Ok(
- static_channel_name(info.channel_type, info.name.as_deref(), info.id),
- ),
+ ChannelType::Public | ChannelType::Team => Ok(static_channel_name(
+ info.channel_type,
+ info.name.as_deref(),
+ info.id,
+ )),
ChannelType::Private
if info
.name
@@ -1606,7 +1604,7 @@ impl ChannelRepo for PgChannelsRepo {
&self,
channel_ids: &[String],
viewer_user_id: &str,
- org_id: Option<i64>,
+ _org_id: Option<i64>,
) -> Result<Vec<ChannelPreviewRow>, Self::Err> {
let rows = sqlx::query_as!(
ChannelPreviewQueryRow,
@@ -1620,8 +1618,6 @@ impl ChannelRepo for PgChannelsRepo {
CASE WHEN (
c.channel_type = 'public'
OR
- (c.channel_type = 'organization' AND $3::bigint IS NOT NULL AND c.org_id = $3)
- OR
(c.channel_type IN ('private', 'direct_message', 'team') AND EXISTS (
SELECT 1 FROM comms_channel_participants cp
WHERE cp.channel_id = c.id
@@ -1631,11 +1627,9 @@ impl ChannelRepo for PgChannelsRepo {
) THEN true ELSE false END AS "has_access!: bool"
FROM comms_channels c
WHERE c.id::text = ANY($1)
- AND (c.channel_type != 'organization' OR $3::bigint IS NOT NULL)
"#,
channel_ids,
viewer_user_id,
- org_id,
)
.fetch_all(&self.pool)
.await
@@ -1684,7 +1678,7 @@ impl ChannelRepo for PgChannelsRepo {
async fn create_channel(
&self,
owner_id: String,
- org_id: Option<i64>,
+ _org_id: Option<i64>,
req: CreateChannelRequest,
) -> Result<Uuid, Self::Err> {
let channel_id = macro_uuid::generate_uuid_v7();
@@ -1697,7 +1691,7 @@ impl ChannelRepo for PgChannelsRepo {
channel_id,
req.name.as_deref(),
&owner_id,
- org_id,
+ None::<i64>,
req.team_id,
req.channel_type as ChannelType,
)
diff --git a/rust/cloud-storage/comms/src/domain/models/channel_name.rs b/rust/cloud-storage/comms/src/domain/models/channel_name.rs
index a14af637fc..5a7909afc5 100644
--- a/rust/cloud-storage/comms/src/domain/models/channel_name.rs
+++ b/rust/cloud-storage/comms/src/domain/models/channel_name.rs
@@ -19,23 +19,31 @@ pub fn resolve_channel_name(
name_lookup: &NameLookup,
) -> ChannelName {
match channel_type {
- ChannelType::Organization | ChannelType::Public => channel_name.map(|name| name.to_string()).unwrap_or_else(|| {
- tracing::warn!(channel_id=?channel_id, "organization or public channel should have a name");
- match channel_type {
- ChannelType::Organization => "Organization".to_string(),
- ChannelType::Public => "Public".to_string(),
- _ => unreachable!(),
- }
+ ChannelType::Public => channel_name
+ .map(|name| name.to_string())
+ .unwrap_or_else(|| {
+ tracing::warn!(channel_id=?channel_id, "public channel should have a name");
+ "Public".to_string()
}),
- ChannelType::Private => resolve_private_channel_name(channel_name, participants, name_lookup),
- ChannelType::DirectMessage => match resolve_direct_message_channel_name(channel_name, participants, &channel_id.0, user_id, name_lookup) {
- Ok(c) | Err(c) => c,
- }
- ChannelType::Team => channel_name.map(|name| name.to_string()).unwrap_or_else(|| {
+ ChannelType::Private => {
+ resolve_private_channel_name(channel_name, participants, name_lookup)
+ }
+ ChannelType::DirectMessage => match resolve_direct_message_channel_name(
+ channel_name,
+ participants,
+ &channel_id.0,
+ user_id,
+ name_lookup,
+ ) {
+ Ok(c) | Err(c) => c,
+ },
+ ChannelType::Team => channel_name
+ .map(|name| name.to_string())
+ .unwrap_or_else(|| {
tracing::warn!(channel_id=?channel_id, "team channel should have a name");
"Team".to_string()
}),
- }
+ }
}
pub fn resolve_private_channel_name(
diff --git a/rust/cloud-storage/comms/src/domain/models/channel_name/tests.rs b/rust/cloud-storage/comms/src/domain/models/channel_name/tests.rs
index 69e02e2bcc..5ea6921629 100644
--- a/rust/cloud-storage/comms/src/domain/models/channel_name/tests.rs
+++ b/rust/cloud-storage/comms/src/domain/models/channel_name/tests.rs
@@ -159,18 +159,7 @@ fn test_resolve_direct_message_channel_name_whitespace_only_display_name() {
}
#[test]
-fn test_resolve_organization_and_public_channel_name() {
- let organization_channel = Channel {
- id: ChannelId(Default::default()),
- name: Some("organization_channel".to_string()),
- channel_type: ChannelType::Organization,
- org_id: None,
- team_id: None,
- created_at: chrono::Utc::now(),
- updated_at: chrono::Utc::now(),
- owner_id: MacroUserIdStr::parse_from_str("macro|[email protected]").unwrap(),
- };
-
+fn test_resolve_public_channel_name() {
let public_channel = Channel {
id: ChannelId(Default::default()),
name: Some("public_channel".to_string()),
@@ -182,26 +171,13 @@ fn test_resolve_organization_and_public_channel_name() {
owner_id: MacroUserIdStr::parse_from_str("macro|[email protected]").unwrap(),
};
- let org_participants = make_participants(&organization_channel.id.0);
- let pub_participants = make_participants(&public_channel.id.0);
-
- assert_eq!(
- resolve_channel_name(
- &organization_channel.channel_type,
- organization_channel.name.as_deref(),
- &org_participants,
- &organization_channel.id,
- MacroUserIdStr::parse_from_str("macro|[email protected]").unwrap(),
- &Default::default()
- ),
- "organization_channel"
- );
+ let participants = make_participants(&public_channel.id.0);
assert_eq!(
resolve_channel_name(
&public_channel.channel_type,
public_channel.name.as_deref(),
- &pub_participants,
+ &participants,
&public_channel.id,
MacroUserIdStr::parse_from_str("macro|[email protected]").unwrap(),
&Default::default()
diff --git a/rust/cloud-storage/comms/src/inbound/router.rs b/rust/cloud-storage/comms/src/inbound/router.rs
index f368b57c32..a2356f452b 100644
--- a/rust/cloud-storage/comms/src/inbound/router.rs
+++ b/rust/cloud-storage/comms/src/inbound/router.rs
@@ -195,7 +195,6 @@ pub struct LatestMessage {
#[serde(rename_all = "snake_case")]
pub enum ChannelType {
Public,
- Organization,
Private,
DirectMessage,
Team,
diff --git a/rust/cloud-storage/comms/src/outbound/fixtures/channels.sql b/rust/cloud-storage/comms/src/outbound/fixtures/channels.sql
index e82470f501..f1242b9145 100644
--- a/rust/cloud-storage/comms/src/outbound/fixtures/channels.sql
+++ b/rust/cloud-storage/comms/src/outbound/fixtures/channels.sql
@@ -1,9 +1,8 @@
-- Channels for dynamic query tests
--- Note: org_id can only be set when channel_type = 'organization'
INSERT INTO comms_channels (id, name, channel_type, org_id, owner_id, created_at, updated_at)
VALUES
- ('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', 'Org Channel A', 'organization', 1, 'macro|[email protected]', '2024-01-01 10:00:00', '2024-01-10 10:00:00'),
- ('bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb', 'Org Channel B', 'organization', 1, 'macro|[email protected]', '2024-01-02 10:00:00', '2024-01-09 10:00:00'),
+ ('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', 'Private Channel A', 'private', NULL, 'macro|[email protected]', '2024-01-01 10:00:00', '2024-01-10 10:00:00'),
+ ('bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb', 'Private Channel B', 'private', NULL, 'macro|[email protected]', '2024-01-02 10:00:00', '2024-01-09 10:00:00'),
('cccccccc-cccc-cccc-cccc-cccccccccccc', 'Public Channel C', 'public', NULL, 'macro|[email protected]', '2024-01-03 10:00:00', '2024-01-08 10:00:00'),
('dddddddd-dddd-dddd-dddd-dddddddddddd', NULL, 'direct_message', NULL, 'macro|[email protected]', '2024-01-04 10:00:00', '2024-01-07 10:00:00');
diff --git a/rust/cloud-storage/comms/src/outbound/postgres/comms_repo.rs b/rust/cloud-storage/comms/src/outbound/postgres/comms_repo.rs
index 5a6e320843..bd09e5af28 100644
--- a/rust/cloud-storage/comms/src/outbound/postgres/comms_repo.rs
+++ b/rust/cloud-storage/comms/src/outbound/postgres/comms_repo.rs
@@ -21,7 +21,6 @@ pub use dynamic::get_user_channels_dynamic;
#[dg(forward = models_comms::channel::ChannelType)]
pub enum ChannelType {
Public,
- Organization,
Private,
DirectMessage,
Team,
diff --git a/rust/cloud-storage/comms/src/outbound/postgres/comms_repo/dynamic/tests.rs b/rust/cloud-storage/comms/src/outbound/postgres/comms_repo/dynamic/tests.rs
index adf3678eb3..4e3c08cca9 100644
--- a/rust/cloud-storage/comms/src/outbound/postgres/comms_repo/dynamic/tests.rs
+++ b/rust/cloud-storage/comms/src/outbound/postgres/comms_repo/dynamic/tests.rs
@@ -79,16 +79,16 @@ async fn test_get_user_channels_dynamic_filter_by_channel_id(pool: Pool<sqlx::Po
migrator = "MACRO_DB_MIGRATIONS",
fixtures(path = "../../../fixtures", scripts("channels"))
)]
-async fn test_get_user_channels_dynamic_filter_by_org_id(pool: Pool<sqlx::Postgres>) {
+async fn test_get_user_channels_dynamic_filter_by_org_id_matches_no_channels(
+ pool: Pool<sqlx::Postgres>,
+) {
use filter_ast::ExpandFrame;
use item_filters::ChannelFilters;
let user_id = MacroUserIdStr::parse_from_str("macro|[email protected]").unwrap();
- let org_id = 1i64;
- // Create filter for specific organization
let channel_filters = ChannelFilters {
- org_id: Some(org_id),
+ org_id: Some(1),
..Default::default()
};
@@ -105,17 +105,10 @@ async fn test_get_user_channels_dynamic_filter_by_org_id(pool: Pool<sqlx::Postgr
let channels = get_user_channels_dynamic(&pool, &params).await.unwrap();
- // Should get channels A and B (both have org_id = 1)
- assert_eq!(channels.len(), 2, "Should return 2 channels with org_id=1");
-
- // All returned channels should have the specified org_id
- for channel in &channels {
- assert_eq!(
- channel.channel.org_id.as_ref().map(|o| o.0 as i64),
- Some(org_id),
- "All channels should belong to the specified org"
- );
- }
+ assert!(
+ channels.is_empty(),
+ "Legacy org filters should not match channel fixtures"
+ );
}
/// Tests that mixing supported (channel_id) and unsupported (thread_id) filters
@@ -322,15 +315,14 @@ async fn test_get_user_channels_dynamic_filter_by_notification_seen_and_done(
migrator = "MACRO_DB_MIGRATIONS",
fixtures(path = "../../../fixtures", scripts("channels"))
)]
-async fn test_get_user_channels_dynamic_filter_by_channel_type(pool: Pool<sqlx::Postgres>) {
+async fn test_get_user_channels_dynamic_filter_by_private_channel_type(pool: Pool<sqlx::Postgres>) {
use filter_ast::ExpandFrame;
use item_filters::ChannelFilters;
let user_id = MacroUserIdStr::parse_from_str("macro|[email protected]").unwrap();
- // Filter for organization channels only
let channel_filters = ChannelFilters {
- channel_types: vec!["organization".to_string()],
+ channel_types: vec!["private".to_string()],
..Default::default()
};
@@ -347,8 +339,8 @@ async fn test_get_user_channels_dynamic_filter_by_channel_type(pool: Pool<sqlx::
let channels = get_user_channels_dynamic(&pool, &params).await.unwrap();
- // Channels A and B are organization type
- assert_eq!(channels.len(), 2, "Should return 2 organization channels");
+ // Channels A and B are private type.
+ assert_eq!(channels.len(), 2, "Should return 2 private channels");
}
#[sqlx::test(
diff --git a/rust/cloud-storage/comms_db_client/src/channels/get_channels.rs b/rust/cloud-storage/comms_db_client/src/channels/get_channels.rs
index 5156acde36..838ea1ae91 100644
--- a/rust/cloud-storage/comms_db_client/src/channels/get_channels.rs
+++ b/rust/cloud-storage/comms_db_client/src/channels/get_channels.rs
@@ -1,8 +1,5 @@
use cached::proc_macro::cached;
-use macro_user_id::{cowlike::CowLike, user_id::MacroUserIdStr};
-#[allow(unused_imports)]
-use model::comms::{Channel, ChannelParticipant, ChannelType, ChannelWithParticipants};
-use model::comms::{ChannelId, OrganizationId};
+use model::comms::Channel;
use sqlx::{Pool, Postgres};
use uuid::Uuid;
@@ -30,7 +27,7 @@ pub async fn check_channels_for_user(
Ok(channels)
}
-#[tracing::instrument(skip(db))]
+#[tracing::instrument(skip(db, _user_org_id))]
#[cached(
time = 5,
result = true,
@@ -40,30 +37,22 @@ pub async fn check_channels_for_user(
pub async fn get_user_channel_ids(
db: &Pool<Postgres>,
user_id: &str,
- user_org_id: Option<i64>,
+ _user_org_id: Option<i64>,
) -> Result<Vec<Uuid>, sqlx::Error> {
let channels = sqlx::query!(
r#"
WITH user_channels AS (
- SELECT DISTINCT c.*
+ SELECT DISTINCT c.id, c.created_at
FROM comms_channels c
INNER JOIN comms_channel_participants cp ON cp.channel_id = c.id
WHERE cp.user_id = $1 AND cp.left_at IS NULL
-
- UNION
-
- SELECT c.*
- FROM comms_channels c
- WHERE c.channel_type = 'organization'::comms_channel_type
- AND c.org_id = $2::bigint
)
- SELECT
+ SELECT
id as "id!"
FROM user_channels
ORDER BY created_at DESC
"#,
user_id,
- user_org_id
)
.map(|row| row.id)
.fetch_all(db)
@@ -73,43 +62,10 @@ pub async fn get_user_channel_ids(
}
pub async fn get_org_channels(
- db: &Pool<Postgres>,
- org_id: &i64,
+ _db: &Pool<Postgres>,
+ _org_id: &i64,
) -> Result<Vec<Channel>, sqlx::Error> {
- let channels = sqlx::query!(
- r#"
- SELECT
- id as "id!",
- name as "name!",
- channel_type as "channel_type!: ChannelType",
- org_id, -- This can be NULL
- created_at as "created_at!",
- updated_at as "updated_at!",
- owner_id as "owner_id!"
- FROM comms_channels
- WHERE channel_type = 'organization'::comms_channel_type
- AND org_id = $1::bigint
- ORDER BY created_at DESC
- "#,
- org_id
- )
- .try_map(|row| {
- Ok(Channel {
- id: ChannelId(row.id),
- name: Some(row.name),
- channel_type: row.channel_type,
- org_id: row.org_id.map(|id| OrganizationId(id as u32)),
- created_at: row.created_at,
- updated_at: row.updated_at,
- owner_id: MacroUserIdStr::parse_from_str(&row.owner_id)
- .map_err(|e| sqlx::Error::Decode(Box::new(e)))?
- .into_owned(),
- })
- })
- .fetch_all(db)
- .await?;
-
- Ok(channels)
+ Ok(Vec::new())
}
/// Returns a paginated list of project IDs, sorting by ascending so we don't miss new ones
diff --git a/rust/cloud-storage/item_filters/src/ast/channel.rs b/rust/cloud-storage/item_filters/src/ast/channel.rs
index a56d94488e..d2e0c5c5e6 100644
--- a/rust/cloud-storage/item_filters/src/ast/channel.rs
+++ b/rust/cloud-storage/item_filters/src/ast/channel.rs
@@ -16,8 +16,6 @@ use crate::{
pub enum ChannelTypeFilter {
/// a public channel
Public,
- /// an organization channel
- Organization,
/// a private channel
Private,
/// a direct message channel
@@ -30,7 +28,6 @@ impl ParseFromStr for ChannelTypeFilter {
fn parse_from_str<T: AsRef<str>>(s: T) -> Result<Self, UnknownValue<Self>> {
match s.as_ref() {
"public" => Ok(Self::Public),
- "organization" => Ok(Self::Organization),
"private" => Ok(Self::Private),
"direct_message" => Ok(Self::DirectMessage),
"team" => Ok(Self::Team),
diff --git a/rust/cloud-storage/macro_db_client/migrations/20260601000000_remove_organization_channel_type.sql b/rust/cloud-storage/macro_db_client/migrations/20260601000000_remove_organization_channel_type.sql
new file mode 100644
index 0000000000..bd4a2c7b80
--- /dev/null
+++ b/rust/cloud-storage/macro_db_client/migrations/20260601000000_remove_organization_channel_type.sql
@@ -0,0 +1,44 @@
+UPDATE public.comms_channels
+SET channel_type = 'private'::public.comms_channel_type,
+ org_id = NULL
+WHERE channel_type = 'organization'::public.comms_channel_type;
+
+UPDATE public.notification
+SET metadata = jsonb_set(metadata, '{channelType}', to_jsonb('private'::text), false)
+WHERE metadata->>'channelType' IN ('organization', 'Organization');
+
+UPDATE public.notification
+SET metadata = jsonb_set(metadata, '{channel_type}', to_jsonb('private'::text), false)
+WHERE metadata->>'channel_type' IN ('organization', 'Organization');
+
+DROP INDEX IF EXISTS public.idx_comms_channels_org_id;
+
+ALTER TABLE public.comms_channels
+ DROP CONSTRAINT IF EXISTS valid_channel_name,
+ DROP CONSTRAINT IF EXISTS valid_org_channel,
+ DROP CONSTRAINT IF EXISTS valid_team_channel;
+
+ALTER TYPE public.comms_channel_type RENAME TO comms_channel_type_old;
+
+CREATE TYPE public.comms_channel_type AS ENUM ('public', 'private', 'direct_message', 'team');
+
+ALTER TABLE public.comms_channels
+ ALTER COLUMN channel_type TYPE public.comms_channel_type
+ USING channel_type::text::public.comms_channel_type;
+
+DROP TYPE public.comms_channel_type_old;
+
+ALTER TABLE public.comms_channels
+ ADD CONSTRAINT valid_channel_name CHECK (
+ (channel_type = 'direct_message'::public.comms_channel_type AND name IS NULL)
+ OR (channel_type = ANY (ARRAY [
+ 'public'::public.comms_channel_type,
+ 'team'::public.comms_channel_type
+ ]) AND name IS NOT NULL)
+ OR (channel_type = 'private'::public.comms_channel_type)
+ ),
+ ADD CONSTRAINT valid_team_channel CHECK (
+ (channel_type = 'team'::public.comms_channel_type AND team_id IS NOT NULL)
+ OR (channel_type <> 'team'::public.comms_channel_type AND team_id IS NULL)
+ ),
+ ADD CONSTRAINT no_channel_org_id CHECK (org_id IS NULL);
diff --git a/rust/cloud-storage/macro_db_client/src/items/filter/channel.rs b/rust/cloud-storage/macro_db_client/src/items/filter/channel.rs
index 5c1addb9d6..d0d451c713 100644
--- a/rust/cloud-storage/macro_db_client/src/items/filter/channel.rs
+++ b/rust/cloud-storage/macro_db_client/src/items/filter/channel.rs
@@ -1,30 +1,11 @@
//! This module contains db queries to filter out items by channel ids
-/// Given a list of channel ids and an org id, this will
-/// return all organization channel ids for the provided org id.
-#[tracing::instrument(skip(db), err)]
+/// Legacy org-channel filters no longer match any channels.
+#[tracing::instrument(skip_all, err)]
pub async fn filter_channels_by_org_id(
- db: &sqlx::PgPool,
- channel_ids: &[uuid::Uuid],
- org_id: i64,
+ _db: &sqlx::PgPool,
+ _channel_ids: &[uuid::Uuid],
+ _org_id: i64,
) -> anyhow::Result<Vec<uuid::Uuid>> {
- let channel_ids = sqlx::query!(
- r#"
- SELECT
- c.id
- FROM
- comms_channels c
- WHERE
- c.id = ANY($1)
- AND c.channel_type = 'organization'
- AND c.org_id = $2
- "#,
- channel_ids,
- org_id,
- )
- .map(|row| row.id)
- .fetch_all(db)
- .await?;
-
- Ok(channel_ids)
+ Ok(Vec::new())
}
diff --git a/rust/cloud-storage/model/src/comms/mod.rs b/rust/cloud-storage/model/src/comms/mod.rs
index 8199a8a14c..4b761df2bb 100644
--- a/rust/cloud-storage/model/src/comms/mod.rs
+++ b/rust/cloud-storage/model/src/comms/mod.rs
@@ -97,7 +97,6 @@ pub struct ChannelParticipant {
#[dg(backward = models_comms::channel::ChannelType)]
pub enum ChannelType {
Public,
- Organization,
Private,
DirectMessage,
Team,
diff --git a/rust/cloud-storage/model_notifications/src/metadata.rs b/rust/cloud-storage/model_notifications/src/metadata.rs
index b92093affe..fa08437ea8 100644
--- a/rust/cloud-storage/model_notifications/src/metadata.rs
+++ b/rust/cloud-storage/model_notifications/src/metadata.rs
@@ -32,8 +32,6 @@ pub struct AiResponseMetadata {
pub enum ChannelType {
#[serde(alias = "Public", alias = "public")]
Public,
- #[serde(alias = "Organization", alias = "organization")]
- Organization,
#[serde(alias = "Private", alias = "private")]
Private,
#[serde(alias = "DirectMessage", alias = "direct_message")]
@@ -46,7 +44,6 @@ impl ChannelType {
pub fn to_model_comms(self) -> models_comms::channel::ChannelType {
match self {
ChannelType::Public => models_comms::channel::ChannelType::Public,
- ChannelType::Organization => models_comms::channel::ChannelType::Organization,
ChannelType::Private => models_comms::channel::ChannelType::Private,
ChannelType::DirectMessage => models_comms::channel::ChannelType::DirectMessage,
ChannelType::Team => models_comms::channel::ChannelType::Team,
diff --git a/rust/cloud-storage/models_comms/src/channel.rs b/rust/cloud-storage/models_comms/src/channel.rs
index 9b70bbdae4..1193e3ebf4 100644
--- a/rust/cloud-storage/models_comms/src/channel.rs
+++ b/rust/cloud-storage/models_comms/src/channel.rs
@@ -11,7 +11,6 @@ use uuid::Uuid;
#[serde(rename_all = "snake_case")]
pub enum ChannelType {
Public,
- Organization,
Private,
DirectMessage,
Team,
diff --git a/rust/cloud-storage/models_soup/src/comms.rs b/rust/cloud-storage/models_soup/src/comms.rs
index acf630edfe..5b8a792a9b 100644
--- a/rust/cloud-storage/models_soup/src/comms.rs
+++ b/rust/cloud-storage/models_soup/src/comms.rs
@@ -72,7 +72,6 @@ pub struct Channel {
#[cfg_attr(feature = "schema", derive(utoipa::ToSchema))]
pub enum ChannelType {
Public,
- Organization,
Private,
DirectMessage,
Team,
diff --git a/rust/cloud-storage/seed_cli/src/entity/channel/mod.rs b/rust/cloud-storage/seed_cli/src/entity/channel/mod.rs
index 10426b2574..3de6f60320 100644
--- a/rust/cloud-storage/seed_cli/src/entity/channel/mod.rs
+++ b/rust/cloud-storage/seed_cli/src/entity/channel/mod.rs
@@ -62,8 +62,6 @@ struct SeedChannelRow {
pub enum CliChannelType {
/// Public channel
Public,
- /// Organization channel
- Organization,
/// Private channel
Private,
/// Direct message channel
@@ -74,7 +72,6 @@ impl From<CliChannelType> for ChannelType {
fn from(value: CliChannelType) -> Self {
match value {
CliChannelType::Public => ChannelType::Public,
- CliChannelType::Organization => ChannelType::Organization,
CliChannelType::Private => ChannelType::Private,
CliChannelType::DirectMessage => ChannelType::DirectMessage,
}
@@ -96,9 +93,6 @@ pub struct CreateArgs {
/// Comma-delimited list of member user IDs
#[arg(long, value_delimiter = ',')]
pub channel_members: Vec<String>,
- /// Organization ID (optional)
- #[arg(long)]
- pub org_id: Option<i64>,
}
impl ChannelArgs {
@@ -119,7 +113,7 @@ async fn create(args: CreateArgs, ctx: SeedCliContext) -> anyhow::Result<()> {
name: args.channel_name,
owner_id: args.channel_owner,
channel_type: args.channel_type.into(),
- org_id: args.org_id,
+ org_id: None,
participants: args.channel_members,
team_id: None,
};
diff --git a/rust/cloud-storage/seed_cli/src/entity/channel/test.rs b/rust/cloud-storage/seed_cli/src/entity/channel/test.rs
index fe13a26858..2450c3a27a 100644
--- a/rust/cloud-storage/seed_cli/src/entity/channel/test.rs
+++ b/rust/cloud-storage/seed_cli/src/entity/channel/test.rs
@@ -33,7 +33,6 @@ fn parse_channel_create_minimal() {
assert!(matches!(create.channel_type, CliChannelType::Public));
assert!(create.channel_name.is_none());
assert!(create.channel_members.is_empty());
- assert!(create.org_id.is_none());
}
other => panic!("expected Create, got {other:?}"),
},
@@ -52,11 +51,9 @@ fn parse_channel_create_full() {
"--channel-owner",
"--channel-type",
- "organization",
+ "private",
"--channel-members",
- "--org-id",
- "42",
])
.unwrap();
@@ -65,12 +62,11 @@ fn parse_channel_create_full() {
ChannelCommand::Create(create) => {
assert_eq!(create.channel_name.as_deref(), Some("general"));
assert_eq!(create.channel_owner, "macro|[email protected]");
- assert!(matches!(create.channel_type, CliChannelType::Organization));
+ assert!(matches!(create.channel_type, CliChannelType::Private));
assert_eq!(
create.channel_members,
vec!["macro|[email protected]", "macro|[email protected]"]
);
- assert_eq!(create.org_id, Some(42));
}
other => panic!("expected Create, got {other:?}"),
},
@@ -134,6 +130,36 @@ fn parse_channel_create_invalid_type_fails() {
assert!(result.is_err());
}
+#[test]
+fn parse_channel_create_organization_type_fails() {
+ let result = Cli::try_parse_from([
+ "seed_cli",
+ "channel",
+ "create",
+ "--channel-owner",
+ "--channel-type",
+ "organization",
+ ]);
+ assert!(result.is_err());
+}
+
+#[test]
+fn parse_channel_create_org_id_argument_fails() {
+ let result = Cli::try_parse_from([
+ "seed_cli",
+ "channel",
+ "create",
+ "--channel-owner",
+ "--channel-type",
+ "private",
+ "--org-id",
+ "42",
+ ]);
+ assert!(result.is_err());
+}
+
#[test]
fn parse_channel_seed() {
let cli = Cli::try_parse_from([
@@ -200,7 +226,6 @@ async fn create_channel_success() {
channel_owner: "macro|[email protected]".to_string(),
channel_type: CliChannelType::Public,
channel_members: vec!["macro|[email protected]".to_string()],
- org_id: None,
}),
};
@@ -223,7 +248,6 @@ async fn create_channel_without_name() {
channel_owner: "macro|[email protected]".to_string(),
channel_type: CliChannelType::DirectMessage,
channel_members: vec!["macro|[email protected]".to_string()],
- org_id: None,
}),
};
@@ -245,7 +269,6 @@ async fn create_channel_db_failure_propagates_error() {
channel_owner: "macro|[email protected]".to_string(),
channel_type: CliChannelType::Public,
channel_members: vec![],
- org_id: None,
}),
};