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.

feat(channels): port channel previews (POST /preview) to channels hex (#3615)

teod600fb459f18
diff --git a/js/app/packages/core/component/TopBar/ShareButton.tsx b/js/app/packages/core/component/TopBar/ShareButton.tsx
index eca75d6dae..c37411dd36 100644
--- a/js/app/packages/core/component/TopBar/ShareButton.tsx
+++ b/js/app/packages/core/component/TopBar/ShareButton.tsx
@@ -47,7 +47,6 @@ import IconEdit from '@phosphor/pencil.svg';
import IconShared from '@phosphor/share.svg';
import IconX from '@phosphor/x.svg';
import { cognitionApiServiceClient } from '@service-cognition/client';
-import { commsServiceClient } from '@service-comms/client';
import {
blockNameToItemType,
type ItemType,
@@ -602,7 +601,7 @@ export function ShareModal(props: ShareModalProps) {
);
return { channel_ids };
},
- commsServiceClient.getBatchChannelPreviews,
+ storageServiceClient.getBatchChannelPreviews,
{ initialValue: undefined }
);
diff --git a/js/app/packages/queries/preview/fetchers.ts b/js/app/packages/queries/preview/fetchers.ts
index 31d6f51e0f..257601020c 100644
--- a/js/app/packages/queries/preview/fetchers.ts
+++ b/js/app/packages/queries/preview/fetchers.ts
@@ -1,7 +1,6 @@
import { itemToSafeName } from '@core/constant/allBlocks';
import { cognitionApiServiceClient } from '@service-cognition/client';
-import { commsServiceClient } from '@service-comms/client';
import { emailClient } from '@service-email/client';
import { storageServiceClient } from '@service-storage/client';
import type { FileType } from '@service-storage/generated/schemas/fileType';
@@ -11,7 +10,7 @@ import type { ItemEntity, MessageContext, PreviewItem } from './types';
async function fetchChannelPreviews(
channelIds: string[]
): Promise<PreviewItem[]> {
- const result = await commsServiceClient.getBatchChannelPreviews({
+ const result = await storageServiceClient.getBatchChannelPreviews({
channel_ids: channelIds,
});
diff --git a/js/app/packages/service-clients/service-storage/client.ts b/js/app/packages/service-clients/service-storage/client.ts
index 22c2bdaade..2a4d796d17 100644
--- a/js/app/packages/service-clients/service-storage/client.ts
+++ b/js/app/packages/service-clients/service-storage/client.ts
@@ -75,6 +75,8 @@ import type { EditAnchorResponse } from './generated/schemas/editAnchorResponse'
import type { EditCommentResponse } from './generated/schemas/editCommentResponse';
import type { ExportDocumentResponse } from './generated/schemas/exportDocumentResponse';
import type { GetAttachmentReferencesResponse } from './generated/schemas/getAttachmentReferencesResponse';
+import type { GetBatchChannelPreviewRequest } from './generated/schemas/getBatchChannelPreviewRequest';
+import type { GetBatchChannelPreviewResponse } from './generated/schemas/getBatchChannelPreviewResponse';
import type { GetBatchProjectPreviewResponse } from './generated/schemas/getBatchProjectPreviewResponse';
import type { GetDocumentPermissionsResponseDataV2 } from './generated/schemas/getDocumentPermissionsResponseDataV2';
import type { GetDocumentProcessingResultResponse } from './generated/schemas/getDocumentProcessingResultResponse';
@@ -549,6 +551,16 @@ export const storageServiceClient = {
).map((result) => result);
},
+ async getBatchChannelPreviews(args: GetBatchChannelPreviewRequest) {
+ const { channel_ids } = args;
+ return (
+ await dssFetch<GetBatchChannelPreviewResponse>(`/channels/preview`, {
+ method: 'POST',
+ body: JSON.stringify({ channel_ids }),
+ })
+ ).map((result) => result);
+ },
+
async getChannelMessages(
args: WithChannelId & {
limit: number;
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/channelPreview.ts b/js/app/packages/service-clients/service-storage/generated/schemas/channelPreview.ts
new file mode 100644
index 0000000000..33fcd63a16
--- /dev/null
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/channelPreview.ts
@@ -0,0 +1,17 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+import type { ChannelPreviewOneOf } from './channelPreviewOneOf';
+import type { ChannelPreviewOneOfFour } from './channelPreviewOneOfFour';
+import type { ChannelPreviewOneOfSeven } from './channelPreviewOneOfSeven';
+
+/**
+ * Preview entry for a single channel id.
+ */
+export type ChannelPreview =
+ | ChannelPreviewOneOf
+ | ChannelPreviewOneOfFour
+ | ChannelPreviewOneOfSeven;
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/channelPreviewData.ts b/js/app/packages/service-clients/service-storage/generated/schemas/channelPreviewData.ts
new file mode 100644
index 0000000000..b1aebf251a
--- /dev/null
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/channelPreviewData.ts
@@ -0,0 +1,19 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+import type { ChannelType } from './channelType';
+
+/**
+ * Preview payload returned for accessible channels.
+ */
+export interface ChannelPreviewData {
+ /** Channel id. */
+ channel_id: string;
+ /** Resolved channel display name. */
+ channel_name: string;
+ /** Channel type. */
+ channel_type: ChannelType;
+}
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/channelPreviewOneOf.ts b/js/app/packages/service-clients/service-storage/generated/schemas/channelPreviewOneOf.ts
new file mode 100644
index 0000000000..5a345fecc3
--- /dev/null
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/channelPreviewOneOf.ts
@@ -0,0 +1,13 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+import type { ChannelPreviewData } from './channelPreviewData';
+import type { ChannelPreviewOneOfAllOf } from './channelPreviewOneOfAllOf';
+
+/**
+ * Viewer can access the channel.
+ */
+export type ChannelPreviewOneOf = ChannelPreviewData & ChannelPreviewOneOfAllOf;
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/channelPreviewOneOfAllOf.ts b/js/app/packages/service-clients/service-storage/generated/schemas/channelPreviewOneOfAllOf.ts
new file mode 100644
index 0000000000..483519a856
--- /dev/null
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/channelPreviewOneOfAllOf.ts
@@ -0,0 +1,11 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+import type { ChannelPreviewOneOfAllOfType } from './channelPreviewOneOfAllOfType';
+
+export type ChannelPreviewOneOfAllOf = {
+ type: ChannelPreviewOneOfAllOfType;
+};
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/channelPreviewOneOfAllOfType.ts b/js/app/packages/service-clients/service-storage/generated/schemas/channelPreviewOneOfAllOfType.ts
new file mode 100644
index 0000000000..e2c13a6ba4
--- /dev/null
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/channelPreviewOneOfAllOfType.ts
@@ -0,0 +1,14 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+export type ChannelPreviewOneOfAllOfType =
+ (typeof ChannelPreviewOneOfAllOfType)[keyof typeof ChannelPreviewOneOfAllOfType];
+
+// eslint-disable-next-line @typescript-eslint/no-redeclare
+export const ChannelPreviewOneOfAllOfType = {
+ access: 'access',
+} as const;
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/channelPreviewOneOfFour.ts b/js/app/packages/service-clients/service-storage/generated/schemas/channelPreviewOneOfFour.ts
new file mode 100644
index 0000000000..177e8612f6
--- /dev/null
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/channelPreviewOneOfFour.ts
@@ -0,0 +1,15 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+import type { ChannelPreviewOneOfFourAllOf } from './channelPreviewOneOfFourAllOf';
+import type { WithChannelId } from './withChannelId';
+
+/**
+ * Viewer cannot access the channel.
+ */
+export type ChannelPreviewOneOfFour = WithChannelId &
+ ChannelPreviewOneOfFourAllOf;
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/channelPreviewOneOfFourAllOf.ts b/js/app/packages/service-clients/service-storage/generated/schemas/channelPreviewOneOfFourAllOf.ts
new file mode 100644
index 0000000000..1a30599f0f
--- /dev/null
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/channelPreviewOneOfFourAllOf.ts
@@ -0,0 +1,11 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+import type { ChannelPreviewOneOfFourAllOfType } from './channelPreviewOneOfFourAllOfType';
+
+export type ChannelPreviewOneOfFourAllOf = {
+ type: ChannelPreviewOneOfFourAllOfType;
+};
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/channelPreviewOneOfFourAllOfType.ts b/js/app/packages/service-clients/service-storage/generated/schemas/channelPreviewOneOfFourAllOfType.ts
new file mode 100644
index 0000000000..870a929d99
--- /dev/null
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/channelPreviewOneOfFourAllOfType.ts
@@ -0,0 +1,14 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+export type ChannelPreviewOneOfFourAllOfType =
+ (typeof ChannelPreviewOneOfFourAllOfType)[keyof typeof ChannelPreviewOneOfFourAllOfType];
+
+// eslint-disable-next-line @typescript-eslint/no-redeclare
+export const ChannelPreviewOneOfFourAllOfType = {
+ no_access: 'no_access',
+} as const;
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/channelPreviewOneOfSeven.ts b/js/app/packages/service-clients/service-storage/generated/schemas/channelPreviewOneOfSeven.ts
new file mode 100644
index 0000000000..315dcd7c2e
--- /dev/null
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/channelPreviewOneOfSeven.ts
@@ -0,0 +1,15 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+import type { ChannelPreviewOneOfSevenAllOf } from './channelPreviewOneOfSevenAllOf';
+import type { WithChannelId } from './withChannelId';
+
+/**
+ * Channel does not exist.
+ */
+export type ChannelPreviewOneOfSeven = WithChannelId &
+ ChannelPreviewOneOfSevenAllOf;
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/channelPreviewOneOfSevenAllOf.ts b/js/app/packages/service-clients/service-storage/generated/schemas/channelPreviewOneOfSevenAllOf.ts
new file mode 100644
index 0000000000..7a21ddd94d
--- /dev/null
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/channelPreviewOneOfSevenAllOf.ts
@@ -0,0 +1,11 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+import type { ChannelPreviewOneOfSevenAllOfType } from './channelPreviewOneOfSevenAllOfType';
+
+export type ChannelPreviewOneOfSevenAllOf = {
+ type: ChannelPreviewOneOfSevenAllOfType;
+};
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/channelPreviewOneOfSevenAllOfType.ts b/js/app/packages/service-clients/service-storage/generated/schemas/channelPreviewOneOfSevenAllOfType.ts
new file mode 100644
index 0000000000..f59558d55f
--- /dev/null
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/channelPreviewOneOfSevenAllOfType.ts
@@ -0,0 +1,14 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+export type ChannelPreviewOneOfSevenAllOfType =
+ (typeof ChannelPreviewOneOfSevenAllOfType)[keyof typeof ChannelPreviewOneOfSevenAllOfType];
+
+// eslint-disable-next-line @typescript-eslint/no-redeclare
+export const ChannelPreviewOneOfSevenAllOfType = {
+ does_not_exist: 'does_not_exist',
+} as const;
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/getBatchChannelPreviewRequest.ts b/js/app/packages/service-clients/service-storage/generated/schemas/getBatchChannelPreviewRequest.ts
new file mode 100644
index 0000000000..7235f49c11
--- /dev/null
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/getBatchChannelPreviewRequest.ts
@@ -0,0 +1,14 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * Request for a batched channel preview lookup.
+ */
+export interface GetBatchChannelPreviewRequest {
+ /** Channel ids to look up. */
+ channel_ids: string[];
+}
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/getBatchChannelPreviewResponse.ts b/js/app/packages/service-clients/service-storage/generated/schemas/getBatchChannelPreviewResponse.ts
new file mode 100644
index 0000000000..ca91457a06
--- /dev/null
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/getBatchChannelPreviewResponse.ts
@@ -0,0 +1,15 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+import type { ChannelPreview } from './channelPreview';
+
+/**
+ * Response for a batched channel preview lookup.
+ */
+export interface GetBatchChannelPreviewResponse {
+ /** Resolved channel previews, one per requested channel id. */
+ previews: ChannelPreview[];
+}
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/index.ts b/js/app/packages/service-clients/service-storage/generated/schemas/index.ts
index a1eef3969f..aeaf57bfa8 100644
--- a/js/app/packages/service-clients/service-storage/generated/schemas/index.ts
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/index.ts
@@ -146,6 +146,17 @@ export * from './channelName';
export * from './channelOrgId';
export * from './channelParticipant';
export * from './channelParticipantLeftAt';
+export * from './channelPreview';
+export * from './channelPreviewData';
+export * from './channelPreviewOneOf';
+export * from './channelPreviewOneOfAllOf';
+export * from './channelPreviewOneOfAllOfType';
+export * from './channelPreviewOneOfFour';
+export * from './channelPreviewOneOfFourAllOf';
+export * from './channelPreviewOneOfFourAllOfType';
+export * from './channelPreviewOneOfSeven';
+export * from './channelPreviewOneOfSevenAllOf';
+export * from './channelPreviewOneOfSevenAllOfType';
export * from './channelSharePermission';
export * from './channelTeamId';
export * from './channelType';
@@ -422,6 +433,8 @@ export * from './getActivitiesResponseData';
export * from './getAttachmentReferencesResponse';
export * from './getBatchCallRecordPreviewRequest';
export * from './getBatchCallRecordPreviewResponse';
+export * from './getBatchChannelPreviewRequest';
+export * from './getBatchChannelPreviewResponse';
export * from './getBatchPreviewRequest';
export * from './getBatchPreviewResponse';
export * from './getBatchProjectPreviewRequest';
@@ -810,5 +823,6 @@ export * from './viewPatch';
export * from './viewPatchName';
export * from './viewsResponse';
export * from './withCallId';
+export * from './withChannelId';
export * from './withDocumentId';
export * from './withProjectId';
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/withChannelId.ts b/js/app/packages/service-clients/service-storage/generated/schemas/withChannelId.ts
new file mode 100644
index 0000000000..1e7eb90341
--- /dev/null
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/withChannelId.ts
@@ -0,0 +1,14 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * Preview payload returned for channels with only id information.
+ */
+export interface WithChannelId {
+ /** Channel id. */
+ channel_id: string;
+}
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 7e5b278c27..635f6455ef 100644
--- a/js/app/packages/service-clients/service-storage/generated/zod.ts
+++ b/js/app/packages/service-clients/service-storage/generated/zod.ts
@@ -1427,6 +1427,77 @@ export const deleteEntityMentionResponse = zod
})
.describe('Response body for `DELETE \/channels\/mentions\/{mention_id}`.');
+/**
+ * @summary Handler for `POST /channels/preview`.
+ */
+export const getBatchChannelPreviewBody = zod
+ .object({
+ channel_ids: zod.array(zod.string()).describe('Channel ids to look up.'),
+ })
+ .describe('Request for a batched channel preview lookup.');
+
+export const getBatchChannelPreviewResponse = zod
+ .object({
+ previews: zod
+ .array(
+ zod
+ .union([
+ zod
+ .object({
+ channel_id: zod.string().describe('Channel id.'),
+ channel_name: zod
+ .string()
+ .describe('Resolved channel display name.'),
+ channel_type: zod
+ .enum([
+ 'public',
+ 'organization',
+ 'private',
+ 'direct_message',
+ 'team',
+ ])
+ .describe('Type of channel.'),
+ })
+ .describe('Preview payload returned for accessible channels.')
+ .and(
+ zod.object({
+ type: zod.enum(['access']),
+ })
+ )
+ .describe('Viewer can access the channel.'),
+ zod
+ .object({
+ channel_id: zod.string().describe('Channel id.'),
+ })
+ .describe(
+ 'Preview payload returned for channels with only id information.'
+ )
+ .and(
+ zod.object({
+ type: zod.enum(['no_access']),
+ })
+ )
+ .describe('Viewer cannot access the channel.'),
+ zod
+ .object({
+ channel_id: zod.string().describe('Channel id.'),
+ })
+ .describe(
+ 'Preview payload returned for channels with only id information.'
+ )
+ .and(
+ zod.object({
+ type: zod.enum(['does_not_exist']),
+ })
+ )
+ .describe('Channel does not exist.'),
+ ])
+ .describe('Preview entry for a single channel id.')
+ )
+ .describe('Resolved channel previews, one per requested channel id.'),
+ })
+ .describe('Response for a batched channel preview lookup.');
+
/**
* @summary Handler for `DELETE /channels/{channel_id}`.
*/
diff --git a/js/app/packages/service-clients/service-storage/openapi.json b/js/app/packages/service-clients/service-storage/openapi.json
index 3e261cd638..6ec3e2ed1c 100644
--- a/js/app/packages/service-clients/service-storage/openapi.json
+++ b/js/app/packages/service-clients/service-storage/openapi.json
@@ -1642,6 +1642,65 @@
}
}
},
+ "/channels/preview": {
+ "post": {
+ "tags": ["channels"],
+ "summary": "Handler for `POST /channels/preview`.",
+ "operationId": "get_batch_channel_preview",
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/GetBatchChannelPreviewRequest"
+ }
+ }
+ },
+ "required": true
+ },
+ "responses": {
+ "200": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/GetBatchChannelPreviewResponse"
+ }
+ }
+ }
+ },
+ "400": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ErrorResponse"
+ }
+ }
+ }
+ },
+ "401": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ErrorResponse"
+ }
+ }
+ }
+ },
+ "500": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ErrorResponse"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
"/channels/{channel_id}": {
"delete": {
"tags": ["channels"],
@@ -9105,6 +9164,87 @@
}
}
},
+ "ChannelPreview": {
+ "oneOf": [
+ {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/ChannelPreviewData",
+ "description": "Viewer can access the channel."
+ },
+ {
+ "type": "object",
+ "required": ["type"],
+ "properties": {
+ "type": {
+ "type": "string",
+ "enum": ["access"]
+ }
+ }
+ }
+ ],
+ "description": "Viewer can access the channel."
+ },
+ {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/WithChannelId",
+ "description": "Viewer cannot access the channel."
+ },
+ {
+ "type": "object",
+ "required": ["type"],
+ "properties": {
+ "type": {
+ "type": "string",
+ "enum": ["no_access"]
+ }
+ }
+ }
+ ],
+ "description": "Viewer cannot access the channel."
+ },
+ {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/WithChannelId",
+ "description": "Channel does not exist."
+ },
+ {
+ "type": "object",
+ "required": ["type"],
+ "properties": {
+ "type": {
+ "type": "string",
+ "enum": ["does_not_exist"]
+ }
+ }
+ }
+ ],
+ "description": "Channel does not exist."
+ }
+ ],
+ "description": "Preview entry for a single channel id."
+ },
+ "ChannelPreviewData": {
+ "type": "object",
+ "description": "Preview payload returned for accessible channels.",
+ "required": ["channel_id", "channel_name", "channel_type"],
+ "properties": {
+ "channel_id": {
+ "type": "string",
+ "description": "Channel id."
+ },
+ "channel_name": {
+ "type": "string",
+ "description": "Resolved channel display name."
+ },
+ "channel_type": {
+ "$ref": "#/components/schemas/ChannelType",
+ "description": "Channel type."
+ }
+ }
+ },
"ChannelSharePermission": {
"type": "object",
"description": "The channel share permission",
@@ -11758,6 +11898,34 @@
}
}
},
+ "GetBatchChannelPreviewRequest": {
+ "type": "object",
+ "description": "Request for a batched channel preview lookup.",
+ "required": ["channel_ids"],
+ "properties": {
+ "channel_ids": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "description": "Channel ids to look up."
+ }
+ }
+ },
+ "GetBatchChannelPreviewResponse": {
+ "type": "object",
+ "description": "Response for a batched channel preview lookup.",
+ "required": ["previews"],
+ "properties": {
+ "previews": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ChannelPreview"
+ },
+ "description": "Resolved channel previews, one per requested channel id."
+ }
+ }
+ },
"GetBatchPreviewRequest": {
"type": "object",
"required": ["document_ids"],
@@ -15368,6 +15536,17 @@
}
}
},
+ "WithChannelId": {
+ "type": "object",
+ "description": "Preview payload returned for channels with only id information.",
+ "required": ["channel_id"],
+ "properties": {
+ "channel_id": {
+ "type": "string",
+ "description": "Channel id."
+ }
+ }
+ },
"WithDocumentId": {
"type": "object",
"required": ["document_id"],
diff --git a/rust/cloud-storage/.sqlx/query-5c47456f9d7becea7d008197fd7693632c755978abb9b4ff9cff3fd95b09b535.json b/rust/cloud-storage/.sqlx/query-5c47456f9d7becea7d008197fd7693632c755978abb9b4ff9cff3fd95b09b535.json
new file mode 100644
index 0000000000..ef72c7e2b8
--- /dev/null
+++ b/rust/cloud-storage/.sqlx/query-5c47456f9d7becea7d008197fd7693632c755978abb9b4ff9cff3fd95b09b535.json
@@ -0,0 +1,67 @@
+{
+ "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 ",
+ "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": "team_id",
+ "type_info": "Uuid"
+ },
+ {
+ "ordinal": 5,
+ "name": "has_access!: bool",
+ "type_info": "Bool"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "TextArray",
+ "Text",
+ "Int8"
+ ]
+ },
+ "nullable": [
+ false,
+ true,
+ false,
+ true,
+ true,
+ null
+ ]
+ },
+ "hash": "5c47456f9d7becea7d008197fd7693632c755978abb9b4ff9cff3fd95b09b535"
+}
diff --git a/rust/cloud-storage/channels/src/domain/models.rs b/rust/cloud-storage/channels/src/domain/models.rs
index 86b2c4057d..c57c43f91c 100644
--- a/rust/cloud-storage/channels/src/domain/models.rs
+++ b/rust/cloud-storage/channels/src/domain/models.rs
@@ -786,6 +786,64 @@ pub struct ChannelInfo {
pub team_id: Option<Uuid>,
}
+/// Request for a batched channel preview lookup.
+#[derive(Debug, Clone, Serialize, Deserialize)]
+#[cfg_attr(feature = "inbound", derive(utoipa::ToSchema))]
+pub struct GetBatchChannelPreviewRequest {
+ /// Channel ids to look up.
+ pub channel_ids: Vec<String>,
+}
+
+/// Response for a batched channel preview lookup.
+#[derive(Debug, Clone, Serialize, Deserialize)]
+#[cfg_attr(feature = "inbound", derive(utoipa::ToSchema))]
+pub struct GetBatchChannelPreviewResponse {
+ /// Resolved channel previews, one per requested channel id.
+ pub previews: Vec<ChannelPreview>,
+}
+
+/// Preview entry for a single channel id.
+#[derive(Debug, Clone, Serialize, Deserialize)]
+#[cfg_attr(feature = "inbound", derive(utoipa::ToSchema))]
+#[serde(tag = "type", rename_all = "snake_case")]
+pub enum ChannelPreview {
+ /// Viewer can access the channel.
+ Access(ChannelPreviewData),
+ /// Viewer cannot access the channel.
+ NoAccess(WithChannelId),
+ /// Channel does not exist.
+ DoesNotExist(WithChannelId),
+}
+
+/// Preview payload returned for accessible channels.
+#[derive(Debug, Clone, Serialize, Deserialize)]
+#[cfg_attr(feature = "inbound", derive(utoipa::ToSchema))]
+pub struct ChannelPreviewData {
+ /// Channel id.
+ pub channel_id: String,
+ /// Resolved channel display name.
+ pub channel_name: String,
+ /// Channel type.
+ pub channel_type: ChannelType,
+}
+
+/// Preview payload returned for channels with only id information.
+#[derive(Debug, Clone, Serialize, Deserialize)]
+#[cfg_attr(feature = "inbound", derive(utoipa::ToSchema))]
+pub struct WithChannelId {
+ /// Channel id.
+ pub channel_id: String,
+}
+
+/// Raw preview row returned from the repository.
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub struct ChannelPreviewRow {
+ /// Channel info.
+ pub info: ChannelInfo,
+ /// Whether the viewer can access the channel.
+ pub has_access: bool,
+}
+
/// Persisted entity-to-entity mention.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "inbound", derive(utoipa::ToSchema))]
diff --git a/rust/cloud-storage/channels/src/domain/ports.rs b/rust/cloud-storage/channels/src/domain/ports.rs
index b14e9ef3c1..50bc40872a 100644
--- a/rust/cloud-storage/channels/src/domain/ports.rs
+++ b/rust/cloud-storage/channels/src/domain/ports.rs
@@ -2,13 +2,14 @@ use crate::domain::events::ChannelEvent;
use crate::domain::models::{
AddParticipantsRequest, AttachmentEntityReference, ChannelAttachment, ChannelAttachmentType,
ChannelContextMessage, ChannelInfo, ChannelMessageFilters, ChannelMetadata, ChannelParticipant,
- CountedReaction, CreateChannelRequest, CreateChannelResponse, CreateEntityMentionOptions,
- DeleteMessageQuery, EntityMention, GetOrCreateChannelResponse, GetOrCreateDmRequest,
- GetOrCreatePrivateRequest, MessageAttachment, MessagePageDirection, MutatedAttachment,
- MutatedMessage, NewChannelAttachment, PatchChannelRequest, PatchMessageRequest,
- PostMessageRequest, PostMessageResponse, PostReactionRequest, PostTypingRequest,
- ReferencedShareItem, RemoveParticipantsRequest, ResolvedChannelMessage, SimpleMention,
- ThreadData, ThreadReply, ThreadReplyRow, TopLevelMessageRow,
+ ChannelPreview, ChannelPreviewRow, CountedReaction, CreateChannelRequest,
+ CreateChannelResponse, CreateEntityMentionOptions, DeleteMessageQuery, EntityMention,
+ GetOrCreateChannelResponse, GetOrCreateDmRequest, GetOrCreatePrivateRequest, MessageAttachment,
+ MessagePageDirection, MutatedAttachment, MutatedMessage, NewChannelAttachment,
+ PatchChannelRequest, PatchMessageRequest, PostMessageRequest, PostMessageResponse,
+ PostReactionRequest, PostTypingRequest, ReferencedShareItem, RemoveParticipantsRequest,
+ ResolvedChannelMessage, SimpleMention, ThreadData, ThreadReply, ThreadReplyRow,
+ TopLevelMessageRow,
};
use crate::domain::side_effects::{
ChannelDocumentMention, ChannelNotificationEffect, ChannelRealtimeEffect,
@@ -134,6 +135,22 @@ pub trait ChannelRepo: Send + Sync + 'static {
viewer_user_id: MacroUserIdStr<'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.
+ fn batch_get_channel_previews(
+ &self,
+ channel_ids: &[String],
+ viewer_user_id: &str,
+ org_id: Option<i64>,
+ ) -> impl Future<Output = Result<Vec<ChannelPreviewRow>, Self::Err>> + Send;
+
+ /// Resolve a channel's display name from the viewer's perspective.
+ fn resolve_channel_name(
+ &self,
+ info: &ChannelInfo,
+ viewer_user_id: MacroUserIdStr<'static>,
+ ) -> impl Future<Output = Result<String, Self::Err>> + Send;
+
/// Check whether a user belongs to a team.
fn user_has_team(
&self,
@@ -370,6 +387,16 @@ pub trait ChannelService: Send + Sync + 'static {
channel_id: Uuid,
) -> impl Future<Output = Result<Vec<ChannelParticipant>, ChannelMessagesErr>> + Send;
+ /// Batch fetch channel previews for the requested ids.
+ fn batch_get_channel_previews(
+ &self,
+ _viewer_user_id: MacroUserIdStr<'static>,
+ _org_id: Option<i64>,
+ _channel_ids: Vec<String>,
+ ) -> impl Future<Output = Result<Vec<ChannelPreview>, ChannelMessagesErr>> + Send {
+ async move { Ok(Vec::new()) }
+ }
+
/// Fetch messages around a target message in chronological order.
fn get_message_context(
&self,
diff --git a/rust/cloud-storage/channels/src/domain/service.rs b/rust/cloud-storage/channels/src/domain/service.rs
index 20304adde8..00a34ab831 100644
--- a/rust/cloud-storage/channels/src/domain/service.rs
+++ b/rust/cloud-storage/channels/src/domain/service.rs
@@ -3,13 +3,13 @@ use crate::domain::{
models::{
AddParticipantsRequest, AttachmentEntityReference, ChannelAttachmentType,
ChannelContextMessage, ChannelMessage, ChannelMessageFilters, ChannelParticipant,
- ChannelType, CreateEntityMentionOptions, DeleteMessageQuery, EntityMention,
- GetOrCreateAction, GetOrCreateChannelResponse, GetOrCreateDmRequest,
- GetOrCreatePrivateRequest, MessagePageDirection, NewChannelAttachment, ParticipantRole,
- PatchChannelRequest, PatchMessageRequest, PostMessageRequest, PostMessageResponse,
- PostReactionRequest, PostTypingRequest, ReactionAction, ReferencedShareItem,
- RemoveParticipantsRequest, ResolvedChannelMessage, SimpleMention, ThreadInfo, ThreadReply,
- TopLevelMessageRow,
+ ChannelPreview, ChannelPreviewData, ChannelType, CreateEntityMentionOptions,
+ DeleteMessageQuery, EntityMention, GetOrCreateAction, GetOrCreateChannelResponse,
+ GetOrCreateDmRequest, GetOrCreatePrivateRequest, MessagePageDirection,
+ NewChannelAttachment, ParticipantRole, PatchChannelRequest, PatchMessageRequest,
+ PostMessageRequest, PostMessageResponse, PostReactionRequest, PostTypingRequest,
+ ReactionAction, ReferencedShareItem, RemoveParticipantsRequest, ResolvedChannelMessage,
+ SimpleMention, ThreadInfo, ThreadReply, TopLevelMessageRow, WithChannelId,
},
ports::{
ChannelAttachmentsPage, ChannelEventDispatcher, ChannelMessagesErr,
@@ -1212,6 +1212,49 @@ where
Ok(participants)
}
+ #[tracing::instrument(err, skip(self, channel_ids))]
+ async fn batch_get_channel_previews(
+ &self,
+ viewer_user_id: MacroUserIdStr<'static>,
+ org_id: Option<i64>,
+ channel_ids: Vec<String>,
+ ) -> Result<Vec<ChannelPreview>, ChannelMessagesErr> {
+ let rows = self
+ .repo
+ .batch_get_channel_previews(&channel_ids, viewer_user_id.as_ref(), org_id)
+ .await
+ .map_err(anyhow::Error::from)?;
+
+ let mut previews: Vec<ChannelPreview> = Vec::with_capacity(channel_ids.len());
+ let mut found: std::collections::HashSet<String> = std::collections::HashSet::new();
+
+ for row in rows {
+ let channel_id_str = row.info.id.to_string();
+ found.insert(channel_id_str.clone());
+ let channel_type = row.info.channel_type;
+ let channel_name = self
+ .repo
+ .resolve_channel_name(&row.info, viewer_user_id.clone())
+ .await
+ .map_err(anyhow::Error::from)?;
+ previews.push(ChannelPreview::Access(ChannelPreviewData {
+ channel_id: channel_id_str,
+ channel_name,
+ channel_type,
+ }));
+ }
+
+ for id in channel_ids {
+ if !found.contains(&id) {
+ previews.push(ChannelPreview::DoesNotExist(WithChannelId {
+ channel_id: id,
+ }));
+ }
+ }
+
+ Ok(previews)
+ }
+
#[tracing::instrument(err, skip(self))]
async fn get_message_context(
&self,
diff --git a/rust/cloud-storage/channels/src/domain/service/test.rs b/rust/cloud-storage/channels/src/domain/service/test.rs
index f9779bb6ee..183099cbe0 100644
--- a/rust/cloud-storage/channels/src/domain/service/test.rs
+++ b/rust/cloud-storage/channels/src/domain/service/test.rs
@@ -369,6 +369,23 @@ impl ChannelRepo for FakeMutationRepo {
})
}
+ async fn batch_get_channel_previews(
+ &self,
+ _channel_ids: &[String],
+ _viewer_user_id: &str,
+ _org_id: Option<i64>,
+ ) -> Result<Vec<crate::domain::models::ChannelPreviewRow>, Self::Err> {
+ Ok(vec![])
+ }
+
+ async fn resolve_channel_name(
+ &self,
+ _info: &ChannelInfo,
+ _viewer_user_id: MacroUserIdStr<'static>,
+ ) -> Result<String, Self::Err> {
+ Ok("Project".to_string())
+ }
+
async fn user_has_team(&self, _user_id: String, _team_id: Uuid) -> Result<bool, Self::Err> {
Ok(true)
}
diff --git a/rust/cloud-storage/channels/src/inbound/axum_router.rs b/rust/cloud-storage/channels/src/inbound/axum_router.rs
index 7d3f5760f5..3afc10dd18 100644
--- a/rust/cloud-storage/channels/src/inbound/axum_router.rs
+++ b/rust/cloud-storage/channels/src/inbound/axum_router.rs
@@ -2,11 +2,13 @@
mod test;
pub use crate::domain::models::{
- AddParticipantsRequest, CreateChannelRequest, CreateChannelResponse,
- CreateEntityMentionRequest, CreateEntityMentionResponse, DeleteEntityMentionResponse,
- DeleteMessageQuery, GetOrCreateChannelResponse, GetOrCreateDmRequest,
+ AddParticipantsRequest, ChannelPreview, ChannelPreviewData, CreateChannelRequest,
+ CreateChannelResponse, CreateEntityMentionRequest, CreateEntityMentionResponse,
+ DeleteEntityMentionResponse, DeleteMessageQuery, GetBatchChannelPreviewRequest,
+ GetBatchChannelPreviewResponse, GetOrCreateChannelResponse, GetOrCreateDmRequest,
GetOrCreatePrivateRequest, PatchChannelRequest, PatchMessageRequest, PostMessageRequest,
PostMessageResponse, PostReactionRequest, PostTypingRequest, RemoveParticipantsRequest,
+ WithChannelId,
};
use crate::domain::models::{
AttachmentChannelReference, AttachmentEntityReference, AttachmentGenericReference,
@@ -302,6 +304,10 @@ where
"/{channel_id}/participants",
get(get_channel_participants_handler::<S, Svc>),
)
+ .route(
+ "/preview",
+ post(get_batch_channel_preview_handler::<S, Svc>),
+ )
.route(
"/attachments/{entity_type}/{entity_id}/references",
get(get_attachment_references_handler::<S, Svc>),
@@ -1283,6 +1289,38 @@ pub async fn get_channel_participants_handler<S: ChannelService, Svc: EntityAcce
))
}
+/// Handler for `POST /channels/preview`.
+#[utoipa::path(
+ post,
+ tag = "channels",
+ operation_id = "get_batch_channel_preview",
+ path = "/channels/preview",
+ request_body = GetBatchChannelPreviewRequest,
+ responses(
+ (status = 200, body = GetBatchChannelPreviewResponse),
+ (status = 400, body = ErrorResponse),
+ (status = 401, body = ErrorResponse),
+ (status = 500, body = ErrorResponse),
+ )
+)]
+#[tracing::instrument(err, skip_all)]
+pub async fn get_batch_channel_preview_handler<S: ChannelService, Svc: EntityAccessService>(
+ State(state): State<ChannelsRouterState<S, Svc>>,
+ MacroUserExtractor {
+ macro_user_id,
+ user_context,
+ ..
+ }: MacroUserExtractor,
+ Json(req): Json<GetBatchChannelPreviewRequest>,
+) -> Result<Json<GetBatchChannelPreviewResponse>, ChannelsHandlerErr> {
+ let org_id = user_context.organization_id.map(i64::from);
+ let previews = state
+ .service
+ .batch_get_channel_previews(macro_user_id, org_id, req.channel_ids)
+ .await?;
+ Ok(Json(GetBatchChannelPreviewResponse { previews }))
+}
+
/// Handler for `GET /channels/attachments/{entity_type}/{entity_id}/references`.
#[utoipa::path(
get,
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 9edb848d64..3041213e5b 100644
--- a/rust/cloud-storage/channels/src/outbound/pg_channels_repo.rs
+++ b/rust/cloud-storage/channels/src/outbound/pg_channels_repo.rs
@@ -6,10 +6,11 @@ use crate::domain::{
AttachmentChannelReference, AttachmentEntityReference, AttachmentGenericReference,
ChannelAttachment, ChannelAttachmentType, ChannelContextMessage, ChannelInfo,
ChannelMessageFilters, ChannelMessageKind, ChannelMetadata, ChannelParticipant,
- ChannelType, CountedReaction, CreateChannelRequest, CreateEntityMentionOptions,
- EntityMention, MessageAttachment, MessagePageDirection, MutatedAttachment, MutatedMessage,
- NewChannelAttachment, ParticipantRole, PatchChannelRequest, ResolvedChannelMessage,
- SimpleMention, ThreadData, ThreadReplyRow, TopLevelMessageRow,
+ ChannelPreviewRow, ChannelType, CountedReaction, CreateChannelRequest,
+ CreateEntityMentionOptions, EntityMention, MessageAttachment, MessagePageDirection,
+ MutatedAttachment, MutatedMessage, NewChannelAttachment, ParticipantRole,
+ PatchChannelRequest, ResolvedChannelMessage, SimpleMention, ThreadData, ThreadReplyRow,
+ TopLevelMessageRow,
},
ports::{ChannelRepo, TopLevelMessagesQueryResult},
};
@@ -201,6 +202,17 @@ struct ChannelInfoRow {
team_id: Option<Uuid>,
}
+/// Intermediate row for batch channel preview lookups.
+#[derive(Debug, sqlx::FromRow)]
+struct ChannelPreviewQueryRow {
+ id: Uuid,
+ name: Option<String>,
+ channel_type: ChannelType,
+ org_id: Option<i64>,
+ team_id: Option<Uuid>,
+ has_access: bool,
+}
+
/// Intermediate row for user display-name lookups.
#[derive(Debug, sqlx::FromRow)]
struct UserDisplayNameRow {
@@ -1570,6 +1582,68 @@ impl ChannelRepo for PgChannelsRepo {
})
}
+ async fn batch_get_channel_previews(
+ &self,
+ channel_ids: &[String],
+ viewer_user_id: &str,
+ org_id: Option<i64>,
+ ) -> Result<Vec<ChannelPreviewRow>, Self::Err> {
+ let rows = sqlx::query_as!(
+ ChannelPreviewQueryRow,
+ r#"
+ SELECT
+ c.id,
+ c.name,
+ c.channel_type AS "channel_type: ChannelType",
+ c.org_id,
+ c.team_id,
+ 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
+ AND cp.user_id = $2
+ AND cp.left_at IS NULL
+ ))
+ ) 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
+ .context("unable to batch get channel previews")?;
+
+ Ok(rows
+ .into_iter()
+ .map(|row| ChannelPreviewRow {
+ info: ChannelInfo {
+ id: row.id,
+ name: row.name,
+ channel_type: row.channel_type,
+ org_id: row.org_id,
+ team_id: row.team_id,
+ },
+ has_access: row.has_access,
+ })
+ .collect())
+ }
+
+ async fn resolve_channel_name(
+ &self,
+ info: &ChannelInfo,
+ viewer_user_id: MacroUserIdStr<'static>,
+ ) -> Result<String, Self::Err> {
+ resolve_channel_display_name(&self.pool, info, viewer_user_id).await
+ }
+
async fn user_has_team(&self, user_id: String, team_id: Uuid) -> Result<bool, Self::Err> {
let has_team = sqlx::query_scalar!(
r#"
diff --git a/rust/cloud-storage/channels/src/outbound/pg_channels_repo/tests.rs b/rust/cloud-storage/channels/src/outbound/pg_channels_repo/tests.rs
index f21bc582ab..068a291bf1 100644
--- a/rust/cloud-storage/channels/src/outbound/pg_channels_repo/tests.rs
+++ b/rust/cloud-storage/channels/src/outbound/pg_channels_repo/tests.rs
@@ -1174,6 +1174,21 @@ async fn notification_filter_requires_requesting_user(pool: Pool<Postgres>) -> a
Ok(())
}
+#[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(path = "../../../fixtures", scripts("channels_repo"))
+)]
+async fn batch_preview_returns_existing_public_channel(pool: Pool<Postgres>) -> anyhow::Result<()> {
+ let rows = repo(pool)
+ .batch_get_channel_previews(&[CH1.to_string()], USER_A, None)
+ .await?;
+
+ assert_eq!(rows.len(), 1);
+ assert_eq!(rows[0].info.id, CH1);
+ assert!(rows[0].has_access);
+ Ok(())
+}
+
fn mention_opts(
source_id: &str,
entity_type: &str,
@@ -1313,6 +1328,21 @@ async fn attachment_references_returns_channel_reference_for_participant(
Ok(())
}
+#[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(path = "../../../fixtures", scripts("channels_repo"))
+)]
+async fn batch_preview_omits_missing_channels(pool: Pool<Postgres>) -> anyhow::Result<()> {
+ let missing = Uuid::from_u128(0x00000000_0000_0000_0000_0000000099ff);
+ let rows = repo(pool)
+ .batch_get_channel_previews(&[CH1.to_string(), missing.to_string()], USER_A, None)
+ .await?;
+
+ assert_eq!(rows.len(), 1);
+ assert_eq!(rows[0].info.id, CH1);
+ Ok(())
+}
+
#[sqlx::test(
fixtures(path = "../../../fixtures", scripts("channels_repo")),
migrator = "MACRO_DB_MIGRATIONS"
diff --git a/rust/cloud-storage/document_storage_service/src/api/swagger.rs b/rust/cloud-storage/document_storage_service/src/api/swagger.rs
index 8c434b5762..6bc63b271c 100644
--- a/rust/cloud-storage/document_storage_service/src/api/swagger.rs
+++ b/rust/cloud-storage/document_storage_service/src/api/swagger.rs
@@ -216,6 +216,7 @@ use utoipa::OpenApi;
channels::inbound::axum_router::resolve_channel_message_handler,
channels::inbound::axum_router::get_channel_attachments_handler,
channels::inbound::axum_router::get_channel_participants_handler,
+ channels::inbound::axum_router::get_batch_channel_preview_handler,
channels::inbound::axum_router::create_mention_handler,
channels::inbound::axum_router::delete_mention_handler,
channels::inbound::axum_router::get_attachment_references_handler,
@@ -408,6 +409,11 @@ use utoipa::OpenApi;
channels::domain::models::PostTypingRequest,
channels::domain::models::AddParticipantsRequest,
channels::domain::models::RemoveParticipantsRequest,
+ channels::domain::models::GetBatchChannelPreviewRequest,
+ channels::domain::models::GetBatchChannelPreviewResponse,
+ channels::domain::models::ChannelPreview,
+ channels::domain::models::ChannelPreviewData,
+ channels::domain::models::WithChannelId,
CreateEntityMentionRequest,
CreateEntityMentionResponse,
DeleteEntityMentionResponse,