Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
chore(comms): move models out of models crate (#4147)
Sean Ayeab0975174fd8
diff --git a/.github/workspace-dep-closures.json b/.github/workspace-dep-closures.jsonindex 91e3a6102e..209f2f2edb 100644--- a/.github/workspace-dep-closures.json+++ b/.github/workspace-dep-closures.json@@ -611,21 +611,62 @@"ai_toolset","ai_usage","attachment",+ "authentication_service_client",+ "bot_id",+ "channels","comms_db_client",+ "connection_gateway_client",+ "connection_gateway_models",+ "contacts","cowlike",+ "crm",+ "decode_jwt","document_sub_type",+ "email",+ "email_utils",+ "entity_access",+ "entity_access_db_utils",+ "filter_ast",+ "frecency",+ "invite_email",+ "ip_extractor",+ "item_filters",+ "last_online_tracker",+ "macro_auth",+ "macro_db_client",+ "macro_env","macro_env_var",+ "macro_middleware",+ "macro_service_urls","macro_user_id","macro_uuid",+ "mention_utils","model","model-entity","model-error-response","model_file_type",+ "model_notifications","model_user","models_bulk_upload",+ "models_dcs",+ "models_email",+ "models_entity_access_management",+ "models_opensearch","models_pagination","models_permissions",+ "models_properties",+ "models_team","non_empty",+ "notification",+ "rate_limit",+ "remote_env_var",+ "s3_key",+ "share_permission_db_utils",+ "sqs_client",+ "sqs_worker",+ "system_properties",+ "unfurl",+ "user_quota","workspace-hack"],"connection": [@@ -3580,24 +3621,45 @@"ai_toolset","ai_usage","attachment",+ "authentication_service_client",+ "bot_id",+ "channels","comms_db_client",+ "connection_gateway_client",+ "connection_gateway_models",+ "contacts","cowlike",+ "crm",+ "decode_jwt","document_sub_type",+ "email","email_db_client","email_utils",+ "entity_access","entity_access_db_utils",+ "filter_ast",+ "frecency","fusionauth",+ "invite_email",+ "ip_extractor",+ "item_filters",+ "last_online_tracker",+ "macro_auth","macro_aws_config","macro_db_client","macro_entrypoint","macro_env","macro_env_var",+ "macro_middleware",+ "macro_service_urls","macro_user_id","macro_uuid",+ "mention_utils","model","model-entity","model-error-response","model_file_type",+ "model_notifications","model_user","models_bulk_upload","models_dcs",@@ -3609,8 +3671,16 @@"models_properties","models_team","non_empty",+ "notification",+ "rate_limit",+ "remote_env_var",+ "s3_key","seed_cli",+ "share_permission_db_utils",+ "sqs_client",+ "sqs_worker","system_properties",+ "unfurl","user_quota","workspace-hack"],diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/channel.ts b/js/app/packages/service-clients/service-storage/generated/schemas/channel.tsindex 131e294866..a9823ffcc2 100644--- a/js/app/packages/service-clients/service-storage/generated/schemas/channel.ts+++ b/js/app/packages/service-clients/service-storage/generated/schemas/channel.ts@@ -10,24 +10,27 @@ import type { ChannelOrgId } from './channelOrgId';import type { ChannelTeamId } from './channelTeamId';import type { ChannelType } from './channelType';+/**+ * Channel metadata in soup payloads.+ */export interface Channel {- /** type of the channel */+ /** Channel type. */channel_type: ChannelType;- /** timestamp of when the channel was created */+ /** Creation timestamp. */created_at: string;- /** uuid of the channel */+ /** Channel id. */id: string;- /** string name of the channel */+ /** Channel display name. */name?: ChannelName;/**- * id of the organization this channel belongs too+ * Organization id.* @minimum 0*/org_id?: ChannelOrgId;- /** id of the user who created the channel */+ /** Channel owner. */owner_id: string;- /** id of the team this channel belongs to */+ /** Team id. */team_id?: ChannelTeamId;- /** timestamp of when the channel was last updated */+ /** Update timestamp. */updated_at: string;}diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/channelMessage.ts b/js/app/packages/service-clients/service-storage/generated/schemas/channelMessage.tsindex d67e02f540..4e0f95c03a 100644--- a/js/app/packages/service-clients/service-storage/generated/schemas/channelMessage.ts+++ b/js/app/packages/service-clients/service-storage/generated/schemas/channelMessage.ts@@ -7,14 +7,24 @@import type { ChannelMessageDeletedAt } from './channelMessageDeletedAt';import type { ChannelMessageThreadId } from './channelMessageThreadId';+/**+ * Lightweight channel message for soup payloads.+ */export interface ChannelMessage {+ /** Message content. */content: string;+ /** Creation timestamp. */created_at: string;+ /** Deletion timestamp. */deleted_at?: ChannelMessageDeletedAt;- /** message mentions formatted as `{ENTITY_TYPE}:{ENTITY_ID}` */+ /** Message mentions formatted as `{ENTITY_TYPE}:{ENTITY_ID}`. */mentions: string[];+ /** Message id. */message_id: string;+ /** Sender id. */sender_id: string;+ /** Thread parent id. */thread_id?: ChannelMessageThreadId;+ /** Update timestamp. */updated_at: string;}diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/channelMessageDeletedAt.ts b/js/app/packages/service-clients/service-storage/generated/schemas/channelMessageDeletedAt.tsindex d836cbd15a..22fdd3da4e 100644--- a/js/app/packages/service-clients/service-storage/generated/schemas/channelMessageDeletedAt.ts+++ b/js/app/packages/service-clients/service-storage/generated/schemas/channelMessageDeletedAt.ts@@ -5,4 +5,7 @@* OpenAPI spec version: 0.1.0*/+/**+ * Deletion timestamp.+ */export type ChannelMessageDeletedAt = string | null;diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/channelMessageThreadId.ts b/js/app/packages/service-clients/service-storage/generated/schemas/channelMessageThreadId.tsindex 9a9e64459c..5dd1416c8b 100644--- a/js/app/packages/service-clients/service-storage/generated/schemas/channelMessageThreadId.ts+++ b/js/app/packages/service-clients/service-storage/generated/schemas/channelMessageThreadId.ts@@ -5,4 +5,7 @@* OpenAPI spec version: 0.1.0*/+/**+ * Thread parent id.+ */export type ChannelMessageThreadId = string | null;diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/channelName.ts b/js/app/packages/service-clients/service-storage/generated/schemas/channelName.tsindex 1041b280c1..114d5b7516 100644--- a/js/app/packages/service-clients/service-storage/generated/schemas/channelName.ts+++ b/js/app/packages/service-clients/service-storage/generated/schemas/channelName.ts@@ -6,6 +6,6 @@*//**- * string name of the channel+ * Channel display name.*/export type ChannelName = string | null;diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/channelOrgId.ts b/js/app/packages/service-clients/service-storage/generated/schemas/channelOrgId.tsindex a199b927db..407b709956 100644--- a/js/app/packages/service-clients/service-storage/generated/schemas/channelOrgId.ts+++ b/js/app/packages/service-clients/service-storage/generated/schemas/channelOrgId.ts@@ -6,7 +6,7 @@*//**- * id of the organization this channel belongs too+ * Organization id.* @minimum 0*/export type ChannelOrgId = number | null;diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/channelTeamId.ts b/js/app/packages/service-clients/service-storage/generated/schemas/channelTeamId.tsindex 557898877d..eeb275714b 100644--- a/js/app/packages/service-clients/service-storage/generated/schemas/channelTeamId.ts+++ b/js/app/packages/service-clients/service-storage/generated/schemas/channelTeamId.ts@@ -6,6 +6,6 @@*//**- * id of the team this channel belongs to+ * Team id.*/export type ChannelTeamId = string | null;diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/latestMessage.ts b/js/app/packages/service-clients/service-storage/generated/schemas/latestMessage.tsindex 91364b9bd5..2c2ea200ff 100644--- a/js/app/packages/service-clients/service-storage/generated/schemas/latestMessage.ts+++ b/js/app/packages/service-clients/service-storage/generated/schemas/latestMessage.ts@@ -7,6 +7,9 @@import type { LatestMessageLatestMessage } from './latestMessageLatestMessage';import type { LatestMessageLatestNonThreadMessage } from './latestMessageLatestNonThreadMessage';+/**+ * Latest-message bundle for soup payloads.+ */export interface LatestMessage {latest_message?: LatestMessageLatestMessage;latest_non_thread_message?: LatestMessageLatestNonThreadMessage;diff --git a/js/app/packages/service-clients/service-storage/generated/zod.ts b/js/app/packages/service-clients/service-storage/generated/zod.tsindex 26ddbe352a..1748739bd5 100644--- a/js/app/packages/service-clients/service-storage/generated/zod.ts+++ b/js/app/packages/service-clients/service-storage/generated/zod.ts@@ -7352,34 +7352,31 @@ export const getItemsSoupResponse = zod.object({zod.object({data: zod.object({- channel: zod.object({- channel_type: zod- .enum(['public', 'private', 'direct_message', 'team'])- .describe('Type of channel.'),- created_at: zod.iso- .datetime({})- .describe('timestamp of when the channel was created'),- id: zod.uuid().describe('uuid of the channel'),- name: zod- .string()- .nullish()- .describe('string name of the channel'),- org_id: zod- .number()- .min(getItemsSoupResponseItemsItemDataChannelOrgIdMin)- .nullish()- .describe('id of the organization this channel belongs too'),- owner_id: zod- .string()- .describe('id of the user who created the channel'),- team_id: zod- .uuid()- .nullish()- .describe('id of the team this channel belongs to'),- updated_at: zod.iso- .datetime({})- .describe('timestamp of when the channel was last updated'),- }),+ channel: zod+ .object({+ channel_type: zod+ .enum(['public', 'private', 'direct_message', 'team'])+ .describe('Type of channel.'),+ created_at: zod.iso+ .datetime({})+ .describe('Creation timestamp.'),+ id: zod.uuid().describe('Channel id.'),+ name: zod+ .string()+ .nullish()+ .describe('Channel display name.'),+ org_id: zod+ .number()+ .min(getItemsSoupResponseItemsItemDataChannelOrgIdMin)+ .nullish()+ .describe('Organization id.'),+ owner_id: zod.string().describe('Channel owner.'),+ team_id: zod.uuid().nullish().describe('Team id.'),+ updated_at: zod.iso+ .datetime({})+ .describe('Update timestamp.'),+ })+ .describe('Channel metadata in soup payloads.'),participants: zod.array(zod.object({channel_id: zod.uuid(),@@ -7393,46 +7390,76 @@ export const getItemsSoupResponse = zod.object({),}).and(- zod.object({- latest_message: zod- .union([- zod.null(),- zod.object({- content: zod.string(),- created_at: zod.iso.datetime({}),- deleted_at: zod.iso.datetime({}).nullish(),- mentions: zod- .array(zod.string())+ zod+ .object({+ latest_message: zod+ .union([+ zod.null(),+ zod+ .object({+ content: zod.string().describe('Message content.'),+ created_at: zod.iso+ .datetime({})+ .describe('Creation timestamp.'),+ deleted_at: zod.iso+ .datetime({})+ .nullish()+ .describe('Deletion timestamp.'),+ mentions: zod+ .array(zod.string())+ .describe(+ 'Message mentions formatted as `{ENTITY_TYPE}:{ENTITY_ID}`.'+ ),+ message_id: zod.uuid().describe('Message id.'),+ sender_id: zod.string().describe('Sender id.'),+ thread_id: zod+ .uuid()+ .nullish()+ .describe('Thread parent id.'),+ updated_at: zod.iso+ .datetime({})+ .describe('Update timestamp.'),+ }).describe(- 'message mentions formatted as `{ENTITY_TYPE}:{ENTITY_ID}`'+ 'Lightweight channel message for soup payloads.'),- message_id: zod.uuid(),- sender_id: zod.string(),- thread_id: zod.uuid().nullish(),- updated_at: zod.iso.datetime({}),- }),- ])- .optional(),- latest_non_thread_message: zod- .union([- zod.null(),- zod.object({- content: zod.string(),- created_at: zod.iso.datetime({}),- deleted_at: zod.iso.datetime({}).nullish(),- mentions: zod- .array(zod.string())+ ])+ .optional(),+ latest_non_thread_message: zod+ .union([+ zod.null(),+ zod+ .object({+ content: zod.string().describe('Message content.'),+ created_at: zod.iso+ .datetime({})+ .describe('Creation timestamp.'),+ deleted_at: zod.iso+ .datetime({})+ .nullish()+ .describe('Deletion timestamp.'),+ mentions: zod+ .array(zod.string())+ .describe(+ 'Message mentions formatted as `{ENTITY_TYPE}:{ENTITY_ID}`.'+ ),+ message_id: zod.uuid().describe('Message id.'),+ sender_id: zod.string().describe('Sender id.'),+ thread_id: zod+ .uuid()+ .nullish()+ .describe('Thread parent id.'),+ updated_at: zod.iso+ .datetime({})+ .describe('Update timestamp.'),+ }).describe(- 'message mentions formatted as `{ENTITY_TYPE}:{ENTITY_ID}`'+ 'Lightweight channel message for soup payloads.'),- message_id: zod.uuid(),- sender_id: zod.string(),- thread_id: zod.uuid().nullish(),- updated_at: zod.iso.datetime({}),- }),- ])- .optional(),- })+ ])+ .optional(),+ })+ .describe('Latest-message bundle for soup payloads.')).and(zod.object({@@ -9266,34 +9293,31 @@ export const postItemsSoupResponse = zod.object({zod.object({data: zod.object({- channel: zod.object({- channel_type: zod- .enum(['public', 'private', 'direct_message', 'team'])- .describe('Type of channel.'),- created_at: zod.iso- .datetime({})- .describe('timestamp of when the channel was created'),- id: zod.uuid().describe('uuid of the channel'),- name: zod- .string()- .nullish()- .describe('string name of the channel'),- org_id: zod- .number()- .min(postItemsSoupResponseItemsItemDataChannelOrgIdMin)- .nullish()- .describe('id of the organization this channel belongs too'),- owner_id: zod- .string()- .describe('id of the user who created the channel'),- team_id: zod- .uuid()- .nullish()- .describe('id of the team this channel belongs to'),- updated_at: zod.iso- .datetime({})- .describe('timestamp of when the channel was last updated'),- }),+ channel: zod+ .object({+ channel_type: zod+ .enum(['public', 'private', 'direct_message', 'team'])+ .describe('Type of channel.'),+ created_at: zod.iso+ .datetime({})+ .describe('Creation timestamp.'),+ id: zod.uuid().describe('Channel id.'),+ name: zod+ .string()+ .nullish()+ .describe('Channel display name.'),+ org_id: zod+ .number()+ .min(postItemsSoupResponseItemsItemDataChannelOrgIdMin)+ .nullish()+ .describe('Organization id.'),+ owner_id: zod.string().describe('Channel owner.'),+ team_id: zod.uuid().nullish().describe('Team id.'),+ updated_at: zod.iso+ .datetime({})+ .describe('Update timestamp.'),+ })+ .describe('Channel metadata in soup payloads.'),participants: zod.array(zod.object({channel_id: zod.uuid(),@@ -9307,46 +9331,76 @@ export const postItemsSoupResponse = zod.object({),}).and(- zod.object({- latest_message: zod- .union([- zod.null(),- zod.object({- content: zod.string(),- created_at: zod.iso.datetime({}),- deleted_at: zod.iso.datetime({}).nullish(),- mentions: zod- .array(zod.string())+ zod+ .object({+ latest_message: zod+ .union([+ zod.null(),+ zod+ .object({+ content: zod.string().describe('Message content.'),+ created_at: zod.iso+ .datetime({})+ .describe('Creation timestamp.'),+ deleted_at: zod.iso+ .datetime({})+ .nullish()+ .describe('Deletion timestamp.'),+ mentions: zod+ .array(zod.string())+ .describe(+ 'Message mentions formatted as `{ENTITY_TYPE}:{ENTITY_ID}`.'+ ),+ message_id: zod.uuid().describe('Message id.'),+ sender_id: zod.string().describe('Sender id.'),+ thread_id: zod+ .uuid()+ .nullish()+ .describe('Thread parent id.'),+ updated_at: zod.iso+ .datetime({})+ .describe('Update timestamp.'),+ }).describe(- 'message mentions formatted as `{ENTITY_TYPE}:{ENTITY_ID}`'+ 'Lightweight channel message for soup payloads.'),- message_id: zod.uuid(),- sender_id: zod.string(),- thread_id: zod.uuid().nullish(),- updated_at: zod.iso.datetime({}),- }),- ])- .optional(),- latest_non_thread_message: zod- .union([- zod.null(),- zod.object({- content: zod.string(),- created_at: zod.iso.datetime({}),- deleted_at: zod.iso.datetime({}).nullish(),- mentions: zod- .array(zod.string())+ ])+ .optional(),+ latest_non_thread_message: zod+ .union([+ zod.null(),+ zod+ .object({+ content: zod.string().describe('Message content.'),+ created_at: zod.iso+ .datetime({})+ .describe('Creation timestamp.'),+ deleted_at: zod.iso+ .datetime({})+ .nullish()+ .describe('Deletion timestamp.'),+ mentions: zod+ .array(zod.string())+ .describe(+ 'Message mentions formatted as `{ENTITY_TYPE}:{ENTITY_ID}`.'+ ),+ message_id: zod.uuid().describe('Message id.'),+ sender_id: zod.string().describe('Sender id.'),+ thread_id: zod+ .uuid()+ .nullish()+ .describe('Thread parent id.'),+ updated_at: zod.iso+ .datetime({})+ .describe('Update timestamp.'),+ }).describe(- 'message mentions formatted as `{ENTITY_TYPE}:{ENTITY_ID}`'+ 'Lightweight channel message for soup payloads.'),- message_id: zod.uuid(),- sender_id: zod.string(),- thread_id: zod.uuid().nullish(),- updated_at: zod.iso.datetime({}),- }),- ])- .optional(),- })+ ])+ .optional(),+ })+ .describe('Latest-message bundle for soup payloads.')).and(zod.object({@@ -10740,34 +10794,31 @@ export const postItemsSoupAstResponse = zod.object({zod.object({data: zod.object({- channel: zod.object({- channel_type: zod- .enum(['public', 'private', 'direct_message', 'team'])- .describe('Type of channel.'),- created_at: zod.iso- .datetime({})- .describe('timestamp of when the channel was created'),- id: zod.uuid().describe('uuid of the channel'),- name: zod- .string()- .nullish()- .describe('string name of the channel'),- org_id: zod- .number()- .min(postItemsSoupAstResponseItemsItemDataChannelOrgIdMin)- .nullish()- .describe('id of the organization this channel belongs too'),- owner_id: zod- .string()- .describe('id of the user who created the channel'),- team_id: zod- .uuid()- .nullish()- .describe('id of the team this channel belongs to'),- updated_at: zod.iso- .datetime({})- .describe('timestamp of when the channel was last updated'),- }),+ channel: zod+ .object({+ channel_type: zod+ .enum(['public', 'private', 'direct_message', 'team'])+ .describe('Type of channel.'),+ created_at: zod.iso+ .datetime({})+ .describe('Creation timestamp.'),+ id: zod.uuid().describe('Channel id.'),+ name: zod+ .string()+ .nullish()+ .describe('Channel display name.'),+ org_id: zod+ .number()+ .min(postItemsSoupAstResponseItemsItemDataChannelOrgIdMin)+ .nullish()+ .describe('Organization id.'),+ owner_id: zod.string().describe('Channel owner.'),+ team_id: zod.uuid().nullish().describe('Team id.'),+ updated_at: zod.iso+ .datetime({})+ .describe('Update timestamp.'),+ })+ .describe('Channel metadata in soup payloads.'),participants: zod.array(zod.object({channel_id: zod.uuid(),@@ -10781,46 +10832,76 @@ export const postItemsSoupAstResponse = zod.object({),}).and(- zod.object({- latest_message: zod- .union([- zod.null(),- zod.object({- content: zod.string(),- created_at: zod.iso.datetime({}),- deleted_at: zod.iso.datetime({}).nullish(),- mentions: zod- .array(zod.string())+ zod+ .object({+ latest_message: zod+ .union([+ zod.null(),+ zod+ .object({+ content: zod.string().describe('Message content.'),+ created_at: zod.iso+ .datetime({})+ .describe('Creation timestamp.'),+ deleted_at: zod.iso+ .datetime({})+ .nullish()+ .describe('Deletion timestamp.'),+ mentions: zod+ .array(zod.string())+ .describe(+ 'Message mentions formatted as `{ENTITY_TYPE}:{ENTITY_ID}`.'+ ),+ message_id: zod.uuid().describe('Message id.'),+ sender_id: zod.string().describe('Sender id.'),+ thread_id: zod+ .uuid()+ .nullish()+ .describe('Thread parent id.'),+ updated_at: zod.iso+ .datetime({})+ .describe('Update timestamp.'),+ }).describe(- 'message mentions formatted as `{ENTITY_TYPE}:{ENTITY_ID}`'+ 'Lightweight channel message for soup payloads.'),- message_id: zod.uuid(),- sender_id: zod.string(),- thread_id: zod.uuid().nullish(),- updated_at: zod.iso.datetime({}),- }),- ])- .optional(),- latest_non_thread_message: zod- .union([- zod.null(),- zod.object({- content: zod.string(),- created_at: zod.iso.datetime({}),- deleted_at: zod.iso.datetime({}).nullish(),- mentions: zod- .array(zod.string())+ ])+ .optional(),+ latest_non_thread_message: zod+ .union([+ zod.null(),+ zod+ .object({+ content: zod.string().describe('Message content.'),+ created_at: zod.iso+ .datetime({})+ .describe('Creation timestamp.'),+ deleted_at: zod.iso+ .datetime({})+ .nullish()+ .describe('Deletion timestamp.'),+ mentions: zod+ .array(zod.string())+ .describe(+ 'Message mentions formatted as `{ENTITY_TYPE}:{ENTITY_ID}`.'+ ),+ message_id: zod.uuid().describe('Message id.'),+ sender_id: zod.string().describe('Sender id.'),+ thread_id: zod+ .uuid()+ .nullish()+ .describe('Thread parent id.'),+ updated_at: zod.iso+ .datetime({})+ .describe('Update timestamp.'),+ }).describe(- 'message mentions formatted as `{ENTITY_TYPE}:{ENTITY_ID}`'+ 'Lightweight channel message for soup payloads.'),- message_id: zod.uuid(),- sender_id: zod.string(),- thread_id: zod.uuid().nullish(),- updated_at: zod.iso.datetime({}),- }),- ])- .optional(),- })+ ])+ .optional(),+ })+ .describe('Latest-message bundle for soup payloads.')).and(zod.object({@@ -12500,42 +12581,38 @@ export const postItemsSoupAstGroupedResponse = zodzod.object({data: zod.object({- channel: zod.object({- channel_type: zod- .enum(['public', 'private', 'direct_message', 'team'])- .describe('Type of channel.'),- created_at: zod.iso- .datetime({})- .describe(- 'timestamp of when the channel was created'- ),- id: zod.uuid().describe('uuid of the channel'),- name: zod- .string()- .nullish()- .describe('string name of the channel'),- org_id: zod- .number()- .min(- postItemsSoupAstGroupedResponseItemsDataChannelOrgIdMin- )- .nullish()- .describe(- 'id of the organization this channel belongs too'- ),- owner_id: zod- .string()- .describe('id of the user who created the channel'),- team_id: zod- .uuid()- .nullish()- .describe('id of the team this channel belongs to'),- updated_at: zod.iso- .datetime({})- .describe(- 'timestamp of when the channel was last updated'- ),- }),+ channel: zod+ .object({+ channel_type: zod+ .enum([+ 'public',+ 'private',+ 'direct_message',+ 'team',+ ])+ .describe('Type of channel.'),+ created_at: zod.iso+ .datetime({})+ .describe('Creation timestamp.'),+ id: zod.uuid().describe('Channel id.'),+ name: zod+ .string()+ .nullish()+ .describe('Channel display name.'),+ org_id: zod+ .number()+ .min(+ postItemsSoupAstGroupedResponseItemsDataChannelOrgIdMin+ )+ .nullish()+ .describe('Organization id.'),+ owner_id: zod.string().describe('Channel owner.'),+ team_id: zod.uuid().nullish().describe('Team id.'),+ updated_at: zod.iso+ .datetime({})+ .describe('Update timestamp.'),+ })+ .describe('Channel metadata in soup payloads.'),participants: zod.array(zod.object({channel_id: zod.uuid(),@@ -12549,46 +12626,88 @@ export const postItemsSoupAstGroupedResponse = zod),}).and(- zod.object({- latest_message: zod- .union([- zod.null(),- zod.object({- content: zod.string(),- created_at: zod.iso.datetime({}),- deleted_at: zod.iso.datetime({}).nullish(),- mentions: zod- .array(zod.string())+ zod+ .object({+ latest_message: zod+ .union([+ zod.null(),+ zod+ .object({+ content: zod+ .string()+ .describe('Message content.'),+ created_at: zod.iso+ .datetime({})+ .describe('Creation timestamp.'),+ deleted_at: zod.iso+ .datetime({})+ .nullish()+ .describe('Deletion timestamp.'),+ mentions: zod+ .array(zod.string())+ .describe(+ 'Message mentions formatted as `{ENTITY_TYPE}:{ENTITY_ID}`.'+ ),+ message_id: zod+ .uuid()+ .describe('Message id.'),+ sender_id: zod+ .string()+ .describe('Sender id.'),+ thread_id: zod+ .uuid()+ .nullish()+ .describe('Thread parent id.'),+ updated_at: zod.iso+ .datetime({})+ .describe('Update timestamp.'),+ }).describe(- 'message mentions formatted as `{ENTITY_TYPE}:{ENTITY_ID}`'+ 'Lightweight channel message for soup payloads.'),- message_id: zod.uuid(),- sender_id: zod.string(),- thread_id: zod.uuid().nullish(),- updated_at: zod.iso.datetime({}),- }),- ])- .optional(),- latest_non_thread_message: zod- .union([- zod.null(),- zod.object({- content: zod.string(),- created_at: zod.iso.datetime({}),- deleted_at: zod.iso.datetime({}).nullish(),- mentions: zod- .array(zod.string())+ ])+ .optional(),+ latest_non_thread_message: zod+ .union([+ zod.null(),+ zod+ .object({+ content: zod+ .string()+ .describe('Message content.'),+ created_at: zod.iso+ .datetime({})+ .describe('Creation timestamp.'),+ deleted_at: zod.iso+ .datetime({})+ .nullish()+ .describe('Deletion timestamp.'),+ mentions: zod+ .array(zod.string())+ .describe(+ 'Message mentions formatted as `{ENTITY_TYPE}:{ENTITY_ID}`.'+ ),+ message_id: zod+ .uuid()+ .describe('Message id.'),+ sender_id: zod+ .string()+ .describe('Sender id.'),+ thread_id: zod+ .uuid()+ .nullish()+ .describe('Thread parent id.'),+ updated_at: zod.iso+ .datetime({})+ .describe('Update timestamp.'),+ }).describe(- 'message mentions formatted as `{ENTITY_TYPE}:{ENTITY_ID}`'+ 'Lightweight channel message for soup payloads.'),- message_id: zod.uuid(),- sender_id: zod.string(),- thread_id: zod.uuid().nullish(),- updated_at: zod.iso.datetime({}),- }),- ])- .optional(),- })+ ])+ .optional(),+ })+ .describe('Latest-message bundle for soup payloads.')).and(zod.object({@@ -13974,42 +14093,38 @@ export const postItemsSoupAstGroupedResponse = zodzod.object({data: zod.object({- channel: zod.object({- channel_type: zod- .enum(['public', 'private', 'direct_message', 'team'])- .describe('Type of channel.'),- created_at: zod.iso- .datetime({})- .describe(- 'timestamp of when the channel was created'- ),- id: zod.uuid().describe('uuid of the channel'),- name: zod- .string()- .nullish()- .describe('string name of the channel'),- org_id: zod- .number()- .min(- postItemsSoupAstGroupedResponseItemsDataChannelOrgIdMinOne- )- .nullish()- .describe(- 'id of the organization this channel belongs too'- ),- owner_id: zod- .string()- .describe('id of the user who created the channel'),- team_id: zod- .uuid()- .nullish()- .describe('id of the team this channel belongs to'),- updated_at: zod.iso- .datetime({})- .describe(- 'timestamp of when the channel was last updated'- ),- }),+ channel: zod+ .object({+ channel_type: zod+ .enum([+ 'public',+ 'private',+ 'direct_message',+ 'team',+ ])+ .describe('Type of channel.'),+ created_at: zod.iso+ .datetime({})+ .describe('Creation timestamp.'),+ id: zod.uuid().describe('Channel id.'),+ name: zod+ .string()+ .nullish()+ .describe('Channel display name.'),+ org_id: zod+ .number()+ .min(+ postItemsSoupAstGroupedResponseItemsDataChannelOrgIdMinOne+ )+ .nullish()+ .describe('Organization id.'),+ owner_id: zod.string().describe('Channel owner.'),+ team_id: zod.uuid().nullish().describe('Team id.'),+ updated_at: zod.iso+ .datetime({})+ .describe('Update timestamp.'),+ })+ .describe('Channel metadata in soup payloads.'),participants: zod.array(zod.object({channel_id: zod.uuid(),@@ -14023,46 +14138,88 @@ export const postItemsSoupAstGroupedResponse = zod),}).and(- zod.object({- latest_message: zod- .union([- zod.null(),- zod.object({- content: zod.string(),- created_at: zod.iso.datetime({}),- deleted_at: zod.iso.datetime({}).nullish(),- mentions: zod- .array(zod.string())+ zod+ .object({+ latest_message: zod+ .union([+ zod.null(),+ zod+ .object({+ content: zod+ .string()+ .describe('Message content.'),+ created_at: zod.iso+ .datetime({})+ .describe('Creation timestamp.'),+ deleted_at: zod.iso+ .datetime({})+ .nullish()+ .describe('Deletion timestamp.'),+ mentions: zod+ .array(zod.string())+ .describe(+ 'Message mentions formatted as `{ENTITY_TYPE}:{ENTITY_ID}`.'+ ),+ message_id: zod+ .uuid()+ .describe('Message id.'),+ sender_id: zod+ .string()+ .describe('Sender id.'),+ thread_id: zod+ .uuid()+ .nullish()+ .describe('Thread parent id.'),+ updated_at: zod.iso+ .datetime({})+ .describe('Update timestamp.'),+ }).describe(- 'message mentions formatted as `{ENTITY_TYPE}:{ENTITY_ID}`'+ 'Lightweight channel message for soup payloads.'),- message_id: zod.uuid(),- sender_id: zod.string(),- thread_id: zod.uuid().nullish(),- updated_at: zod.iso.datetime({}),- }),- ])- .optional(),- latest_non_thread_message: zod- .union([- zod.null(),- zod.object({- content: zod.string(),- created_at: zod.iso.datetime({}),- deleted_at: zod.iso.datetime({}).nullish(),- mentions: zod- .array(zod.string())+ ])+ .optional(),+ latest_non_thread_message: zod+ .union([+ zod.null(),+ zod+ .object({+ content: zod+ .string()+ .describe('Message content.'),+ created_at: zod.iso+ .datetime({})+ .describe('Creation timestamp.'),+ deleted_at: zod.iso+ .datetime({})+ .nullish()+ .describe('Deletion timestamp.'),+ mentions: zod+ .array(zod.string())+ .describe(+ 'Message mentions formatted as `{ENTITY_TYPE}:{ENTITY_ID}`.'+ ),+ message_id: zod+ .uuid()+ .describe('Message id.'),+ sender_id: zod+ .string()+ .describe('Sender id.'),+ thread_id: zod+ .uuid()+ .nullish()+ .describe('Thread parent id.'),+ updated_at: zod.iso+ .datetime({})+ .describe('Update timestamp.'),+ }).describe(- 'message mentions formatted as `{ENTITY_TYPE}:{ENTITY_ID}`'+ 'Lightweight channel message for soup payloads.'),- message_id: zod.uuid(),- sender_id: zod.string(),- thread_id: zod.uuid().nullish(),- updated_at: zod.iso.datetime({}),- }),- ])- .optional(),- })+ ])+ .optional(),+ })+ .describe('Latest-message bundle for soup payloads.')).and(zod.object({diff --git a/js/app/packages/service-clients/service-storage/openapi.json b/js/app/packages/service-clients/service-storage/openapi.jsonindex 2e8a809274..fc12b392e6 100644--- a/js/app/packages/service-clients/service-storage/openapi.json+++ b/js/app/packages/service-clients/service-storage/openapi.json@@ -10794,6 +10794,7 @@},"Channel": {"type": "object",+ "description": "Channel metadata in soup payloads.","required": ["id","channel_type",@@ -10804,41 +10805,41 @@"properties": {"channel_type": {"$ref": "#/components/schemas/ChannelType",- "description": "type of the channel"+ "description": "Channel type."},"created_at": {"type": "string","format": "date-time",- "description": "timestamp of when the channel was created"+ "description": "Creation timestamp."},"id": {"type": "string","format": "uuid",- "description": "uuid of the channel"+ "description": "Channel id."},"name": {"type": ["string", "null"],- "description": "string name of the channel"+ "description": "Channel display name."},"org_id": {"type": ["integer", "null"],"format": "int32",- "description": "id of the organization this channel belongs too",+ "description": "Organization id.","minimum": 0},"owner_id": {"type": "string",- "description": "id of the user who created the channel"+ "description": "Channel owner."},"team_id": {"type": ["string", "null"],"format": "uuid",- "description": "id of the team this channel belongs to"+ "description": "Team id."},"updated_at": {"type": "string","format": "date-time",- "description": "timestamp of when the channel was last updated"+ "description": "Update timestamp."}}},@@ -10902,6 +10903,7 @@},"ChannelMessage": {"type": "object",+ "description": "Lightweight channel message for soup payloads.","required": ["message_id","sender_id",@@ -10912,37 +10914,44 @@],"properties": {"content": {- "type": "string"+ "type": "string",+ "description": "Message content."},"created_at": {"type": "string",- "format": "date-time"+ "format": "date-time",+ "description": "Creation timestamp."},"deleted_at": {"type": ["string", "null"],- "format": "date-time"+ "format": "date-time",+ "description": "Deletion timestamp."},"mentions": {"type": "array","items": {"type": "string"},- "description": "message mentions formatted as `{ENTITY_TYPE}:{ENTITY_ID}`"+ "description": "Message mentions formatted as `{ENTITY_TYPE}:{ENTITY_ID}`."},"message_id": {"type": "string",- "format": "uuid"+ "format": "uuid",+ "description": "Message id."},"sender_id": {- "type": "string"+ "type": "string",+ "description": "Sender id."},"thread_id": {"type": ["string", "null"],- "format": "uuid"+ "format": "uuid",+ "description": "Thread parent id."},"updated_at": {"type": "string",- "format": "date-time"+ "format": "date-time",+ "description": "Update timestamp."}}},@@ -15188,6 +15197,7 @@},"LatestMessage": {"type": "object",+ "description": "Latest-message bundle for soup payloads.","properties": {"latest_message": {"oneOf": [@@ -15195,7 +15205,8 @@"type": "null"},{- "$ref": "#/components/schemas/ChannelMessage"+ "$ref": "#/components/schemas/ChannelMessage",+ "description": "Latest message including thread replies."}]},@@ -15205,7 +15216,8 @@"type": "null"},{- "$ref": "#/components/schemas/ChannelMessage"+ "$ref": "#/components/schemas/ChannelMessage",+ "description": "Latest top-level non-thread message."}]}diff --git a/rust/cloud-storage/Cargo.lock b/rust/cloud-storage/Cargo.lockindex ef9eeeb4b6..186c563755 100644--- a/rust/cloud-storage/Cargo.lock+++ b/rust/cloud-storage/Cargo.lock@@ -2385,6 +2385,7 @@ version = "0.1.0"dependencies = ["anyhow","cached",+ "channels","chrono","doppleganger","futures",@@ -7723,6 +7724,7 @@ version = "0.1.0"dependencies = ["anyhow","call",+ "channels","chrono","crm","document_sub_type",@@ -10825,6 +10827,7 @@ version = "0.1.0"dependencies = ["anyhow","aws-sdk-s3",+ "channels","chrono","clap","comms_db_client",diff --git a/rust/cloud-storage/authentication_service/src/api/webhooks/user/delete_user_webhook.rs b/rust/cloud-storage/authentication_service/src/api/webhooks/user/delete_user_webhook.rsindex f9ac62dfc9..f689eefecc 100644--- a/rust/cloud-storage/authentication_service/src/api/webhooks/user/delete_user_webhook.rs+++ b/rust/cloud-storage/authentication_service/src/api/webhooks/user/delete_user_webhook.rs@@ -284,7 +284,7 @@ async fn remove_user_from_org_channels(remove_participant(db,RemoveParticipantOptions {- channel_id: &channel.id.0,+ channel_id: &channel.id,user_id,},)diff --git a/rust/cloud-storage/channels/src/domain/models.rs b/rust/cloud-storage/channels/src/domain/models.rsindex 45a8f6a9e0..eb0fa14327 100644--- a/rust/cloud-storage/channels/src/domain/models.rs+++ b/rust/cloud-storage/channels/src/domain/models.rs@@ -6,6 +6,7 @@ use models_pagination::{CreatedAt, CursorVal, Identify, SortOn};#[cfg(feature = "list")]use models_pagination::{Query, SimpleSortMethod};use serde::{Deserialize, Serialize, Serializer};+use std::collections::HashMap;use uuid::Uuid;pub use bot_id::BotId;@@ -250,7 +251,7 @@ impl Identify for ChannelMessage {}/// Lightweight channel message used when rendering a channel as an AI attachment.-#[derive(Debug, Clone)]+#[derive(Debug, Clone, Serialize, Deserialize)]pub struct RecentChannelMessage {/// Message id.pub message_id: Uuid,@@ -568,6 +569,132 @@ pub enum ChannelType {Team,}+impl std::fmt::Display for ChannelType {+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {+ match self {+ ChannelType::Public => f.write_str("public"),+ ChannelType::Private => f.write_str("private"),+ ChannelType::DirectMessage => f.write_str("direct_message"),+ ChannelType::Team => f.write_str("team"),+ }+ }+}++/// Request to add a user to all organization channels.+#[derive(Debug, Serialize, Deserialize)]+#[cfg_attr(feature = "inbound", derive(utoipa::ToSchema))]+pub struct AddUserToOrgChannelsRequest {+ /// User to add.+ pub user_id: String,+ /// Organization id.+ pub org_id: i64,+}++/// Request to remove a user from all organization channels.+#[derive(Debug, Serialize, Deserialize)]+#[cfg_attr(feature = "inbound", derive(utoipa::ToSchema))]+pub struct RemoveUserFromOrgChannelsRequest {+ /// User to remove.+ pub user_id: String,+ /// Organization id.+ pub org_id: i64,+}++/// Request to check user membership in channels.+#[derive(Debug, Serialize, Deserialize)]+pub struct CheckChannelsForUserRequest {+ /// User id to check.+ pub user_id: String,+ /// Channel ids to check.+ pub channel_ids: Vec<Uuid>,+}++/// User activity data for a channel.+#[derive(Debug, Serialize, Deserialize)]+pub struct UserActivityForChannel {+ /// User id for the activity.+ pub user_id: String,+ /// Activity update timestamp.+ pub updated_at: chrono::NaiveDateTime,+}++/// Information about a channel used in search responses.+#[derive(Debug, Clone, Serialize, Deserialize, Default)]+pub struct ChannelHistoryInfo {+ /// Channel id.+ pub item_id: Uuid,+ /// Channel creation timestamp.+ pub created_at: DateTime<Utc>,+ /// Channel update timestamp.+ pub updated_at: DateTime<Utc>,+ /// Last viewed timestamp for requesting user.+ pub viewed_at: Option<DateTime<Utc>>,+ /// Last interaction timestamp for requesting user.+ pub interacted_at: Option<DateTime<Utc>>,+ /// Channel owner user id.+ pub user_id: String,+ /// Channel type string.+ pub channel_type: String,+}++/// Request for channel history data.+#[derive(Debug, Serialize, Deserialize)]+pub struct GetChannelsHistoryRequest {+ /// Requesting user id.+ pub user_id: String,+ /// Channel ids to fetch.+ pub channel_ids: Vec<Uuid>,+}++/// Response for channel history data.+#[derive(Debug, Serialize, Deserialize)]+pub struct GetChannelsHistoryResponse {+ /// History data keyed by channel id.+ pub channels_history: HashMap<Uuid, ChannelHistoryInfo>,+}++/// Request to create a welcome message.+#[derive(Debug, Serialize, Deserialize)]+pub struct CreateWelcomeMessageRequest {+ /// User id the welcome message is from/for.+ pub welcome_user_id: MacroUserIdStr<'static>,+ /// User id to send the welcome message to.+ pub to_user_id: MacroUserIdStr<'static>,+}++/// Channel message response used by search indexing.+#[derive(Debug, Serialize, Deserialize)]+pub struct GetChannelMessageResponse {+ /// Channel id.+ pub channel_id: Uuid,+ /// Channel name.+ pub name: Option<String>,+ /// Channel type.+ pub channel_type: ChannelType,+ /// Organization id.+ pub org_id: Option<i64>,+ /// Message data.+ pub channel_message: RecentChannelMessage,+}++/// Request to fetch channel metadata.+#[derive(Debug, Serialize, Deserialize)]+pub struct ChannelMetadataRequest {+ /// Channel id.+ pub channel_id: Uuid,+}++/// Request to fetch channel attachment text.+#[derive(Debug, Serialize, Deserialize)]+pub struct ChannelAttachmentTextRequest {+ /// Channel id.+ pub channel_id: Uuid,+ /// Optional lower bound.+ pub since: Option<chrono::DateTime<chrono::Utc>>,+ /// Optional row limit.+ pub limit: Option<i64>,+}+/// A user's activity (view/interaction) within a channel.#[derive(Debug, Clone, Serialize, Deserialize)]pub struct Activity {diff --git a/rust/cloud-storage/comms_db_client/Cargo.toml b/rust/cloud-storage/comms_db_client/Cargo.tomlindex 482178301d..5140e8c41a 100644--- a/rust/cloud-storage/comms_db_client/Cargo.toml+++ b/rust/cloud-storage/comms_db_client/Cargo.toml@@ -7,6 +7,7 @@ version = "0.1.0"[dependencies]anyhow = { workspace = true }cached = { workspace = true }+channels = { path = "../channels", default-features = false, features = ["outbound"] }chrono = { workspace = true }doppleganger = { workspace = true }futures = { workspace = true }diff --git a/rust/cloud-storage/comms_db_client/src/activity/get_activity.rs b/rust/cloud-storage/comms_db_client/src/activity/get_activity.rsindex 9679001ff1..c9295df82e 100644--- a/rust/cloud-storage/comms_db_client/src/activity/get_activity.rs+++ b/rust/cloud-storage/comms_db_client/src/activity/get_activity.rs@@ -1,7 +1,7 @@use crate::model::Activity;use anyhow::{Context, Result};+use channels::domain::models::{ChannelHistoryInfo, ChannelType, UserActivityForChannel};use chrono::{DateTime, Utc};-use model::comms::{ChannelHistoryInfo, ChannelType, UserActivityForChannel};use sqlx::{Pool, Postgres};use std::collections::HashMap;use uuid::Uuid;diff --git a/rust/cloud-storage/comms_db_client/src/channels/create_channel.rs b/rust/cloud-storage/comms_db_client/src/channels/create_channel.rsindex db64ddc578..0c614b3c4d 100644--- a/rust/cloud-storage/comms_db_client/src/channels/create_channel.rs+++ b/rust/cloud-storage/comms_db_client/src/channels/create_channel.rs@@ -1,7 +1,6 @@use crate::activity;use anyhow::{Context, Result};-#[allow(unused_imports)]-use model::comms::{ChannelType, ParticipantRole};+use channels::domain::models::{ChannelType, ParticipantRole};use sqlx::{Pool, Postgres};use uuid::Uuid;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.rsindex 838ea1ae91..5a5560f720 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,5 +1,5 @@use cached::proc_macro::cached;-use model::comms::Channel;+use channels::domain::models::ChannelListItem;use sqlx::{Pool, Postgres};use uuid::Uuid;@@ -64,7 +64,7 @@ pub async fn get_user_channel_ids(pub async fn get_org_channels(_db: &Pool<Postgres>,_org_id: &i64,-) -> Result<Vec<Channel>, sqlx::Error> {+) -> Result<Vec<ChannelListItem>, sqlx::Error> {Ok(Vec::new())}diff --git a/rust/cloud-storage/comms_db_client/src/channels/seed_channel.rs b/rust/cloud-storage/comms_db_client/src/channels/seed_channel.rsindex abd75eef17..f63ef7875c 100644--- a/rust/cloud-storage/comms_db_client/src/channels/seed_channel.rs+++ b/rust/cloud-storage/comms_db_client/src/channels/seed_channel.rs@@ -1,7 +1,6 @@use crate::activity;use anyhow::{Context, Result};-#[allow(unused_imports)]-use model::comms::{ChannelType, ParticipantRole};+use channels::domain::models::{ChannelType, ParticipantRole};use sqlx::{Pool, Postgres};use uuid::Uuid;diff --git a/rust/cloud-storage/comms_db_client/src/messages/get_channel_message.rs b/rust/cloud-storage/comms_db_client/src/messages/get_channel_message.rsindex e551c431e1..6dbc557c54 100644--- a/rust/cloud-storage/comms_db_client/src/messages/get_channel_message.rs+++ b/rust/cloud-storage/comms_db_client/src/messages/get_channel_message.rs@@ -1,5 +1,5 @@use crate::model::SimpleMention;-use model::comms::{ChannelMessage, ChannelType, GetChannelMessageResponse};+use channels::domain::models::{ChannelType, GetChannelMessageResponse, RecentChannelMessage};use uuid::Uuid;#[derive(Debug, serde::Serialize, serde::Deserialize)]@@ -81,7 +81,7 @@ pub async fn get_channel_message_by_id(name: channel_message_info.name,channel_type: channel_message_info.channel_type,org_id: channel_message_info.org_id,- channel_message: ChannelMessage {+ channel_message: RecentChannelMessage {message_id: channel_message_info.message_id,thread_id: channel_message_info.thread_id,sender_id: channel_message_info.sender_id,diff --git a/rust/cloud-storage/comms_db_client/src/model/mod.rs b/rust/cloud-storage/comms_db_client/src/model/mod.rsindex 5a107e4924..61c0e5222a 100644--- a/rust/cloud-storage/comms_db_client/src/model/mod.rs+++ b/rust/cloud-storage/comms_db_client/src/model/mod.rs@@ -1,5 +1,5 @@+use channels::domain::models::ChannelType;use macro_user_id::user_id::MacroUserIdStr;-use model::comms::ChannelType;use serde::{Deserialize, Serialize};use std::fmt;use utoipa::ToSchema;diff --git a/rust/cloud-storage/comms_db_client/src/participants/add_participant.rs b/rust/cloud-storage/comms_db_client/src/participants/add_participant.rsindex b901b75c79..993c44e46d 100644--- a/rust/cloud-storage/comms_db_client/src/participants/add_participant.rs+++ b/rust/cloud-storage/comms_db_client/src/participants/add_participant.rs@@ -1,8 +1,7 @@use anyhow::{Context, Result};+use channels::domain::models::ParticipantRole;use uuid::Uuid;-use model::comms::ParticipantRole;-pub struct AddParticipantOptions<'a> {pub channel_id: &'a Uuid,pub user_id: &'a str,diff --git a/rust/cloud-storage/comms_db_client/src/participants/get_participants.rs b/rust/cloud-storage/comms_db_client/src/participants/get_participants.rsindex e4330d1c34..2519633dd9 100644--- a/rust/cloud-storage/comms_db_client/src/participants/get_participants.rs+++ b/rust/cloud-storage/comms_db_client/src/participants/get_participants.rs@@ -1,15 +1,12 @@use anyhow::{Context, Result};-use doppleganger::Doppleganger;-use doppleganger::Mirror;+use channels::domain::models::{ChannelParticipant, Sender};use macro_user_id::cowlike::CowLike;use macro_user_id::user_id::MacroUserIdStr;-use model::comms::{ChannelId, ChannelParticipant};use sqlx::Transaction;use sqlx::{Pool, Postgres};use uuid::Uuid;-#[derive(sqlx::Type, Doppleganger, Debug)]-#[dg(forward = model::comms::ParticipantRole)]+#[derive(sqlx::Type, Debug)]#[sqlx(rename_all = "lowercase")]pub enum DbParticipantRole {Admin,@@ -17,6 +14,23 @@ pub enum DbParticipantRole {Owner,}+impl From<DbParticipantRole> for channels::domain::models::ParticipantRole {+ fn from(role: DbParticipantRole) -> Self {+ match role {+ DbParticipantRole::Admin => Self::Admin,+ DbParticipantRole::Member => Self::Member,+ DbParticipantRole::Owner => Self::Owner,+ }+ }+}++// XXX: This is a shim until we correctly implement https://macro.com/app/task/019ed710-f261-7059-b890-5ade6e11f4cd+fn validate_participant_user_id(user_id: &str) -> Result<(), sqlx::Error> {+ Sender::parse_storage_str(user_id)+ .map(|_| ())+ .map_err(|err| sqlx::Error::Decode(Box::new(err)))+}+#[tracing::instrument(skip(tsx))]pub async fn get_participants_tsx<'t>(tsx: &mut Transaction<'t, Postgres>,@@ -37,12 +51,11 @@ pub async fn get_participants_tsx<'t>(channel_id).try_map(|row| {+ validate_participant_user_id(&row.user_id)?;Ok(ChannelParticipant {- channel_id: ChannelId(row.channel_id),- user_id: macro_user_id::user_id::MacroUserIdStr::parse_from_str(&row.user_id)- .map_err(|e| sqlx::Error::Decode(Box::new(e)))?- .into_owned(),- role: DbParticipantRole::mirror(row.role),+ channel_id: row.channel_id,+ user_id: row.user_id,+ role: row.role.into(),joined_at: row.joined_at,left_at: row.left_at,})@@ -73,12 +86,11 @@ pub async fn get_participants(channel_id).try_map(|row| {+ validate_participant_user_id(&row.user_id)?;Ok(ChannelParticipant {- channel_id: ChannelId(row.channel_id),- user_id: macro_user_id::user_id::MacroUserIdStr::parse_from_str(&row.user_id)- .map_err(|e| sqlx::Error::Decode(Box::new(e)))?- .into_owned(),- role: DbParticipantRole::mirror(row.role),+ channel_id: row.channel_id,+ user_id: row.user_id,+ role: row.role.into(),joined_at: row.joined_at,left_at: row.left_at,})diff --git a/rust/cloud-storage/model/src/chat/mod.rs b/rust/cloud-storage/model/src/chat/mod.rsindex 2e1ded3e95..218b90f41e 100644--- a/rust/cloud-storage/model/src/chat/mod.rs+++ b/rust/cloud-storage/model/src/chat/mod.rs@@ -8,7 +8,6 @@ use serde::{Deserialize, Serialize};use strum::Display;use utoipa::ToSchema;-use crate::comms::ChannelType;use crate::document::FileType;#[derive(sqlx::FromRow, Serialize, Deserialize, Eq, PartialEq, Debug, Clone, ToSchema)]@@ -74,6 +73,15 @@ pub struct ChatAttachment {pub message_id: Option<String>,}+#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, ToSchema)]+#[serde(rename_all = "snake_case")]+pub enum ChannelType {+ Public,+ Private,+ DirectMessage,+ Team,+}+#[derive(Serialize, Deserialize, Eq, PartialEq, Debug, Clone, ToSchema)]#[serde(tag = "type", rename_all = "snake_case")]pub enum AttachmentMetadata {diff --git a/rust/cloud-storage/model/src/comms/mod.rs b/rust/cloud-storage/model/src/comms/mod.rsdeleted file mode 100644index 4eb93b728b..0000000000--- a/rust/cloud-storage/model/src/comms/mod.rs+++ /dev/null@@ -1,231 +0,0 @@-use chrono::{DateTime, Utc};-use doppleganger::Primitive;-use macro_user_id::user_id::MacroUserIdStr;-use serde::{Deserialize, Serialize};-use sqlx::Type;-use std::collections::HashMap;-use strum::Display;-use utoipa::ToSchema;-use uuid::Uuid;--/// Ugly place to store the models that are used by service client.-/// it's ugly to promot someone else moving it as I am lazy -- Hutch.--#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]-#[serde(transparent)]-pub struct OrganizationId(pub u32);--impl Primitive for OrganizationId {}--#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, Hash)]-#[serde(transparent)]-pub struct ChannelId(pub Uuid);--impl Primitive for ChannelId {}--#[derive(Debug, Serialize, Deserialize, ToSchema)]-pub struct AddUserToOrgChannelsRequest {- pub user_id: String,- pub org_id: i64,-}--#[derive(Debug, Serialize, Deserialize, ToSchema)]-pub struct RemoveUserFromOrgChannelsRequest {- pub user_id: String,- pub org_id: i64,-}--#[derive(Debug, Serialize, Deserialize, ToSchema, PartialEq, Eq)]-#[serde(rename_all = "snake_case")]-pub enum GetOrCreateAction {- Get,- Create,-}--#[derive(Debug, Serialize, Deserialize)]-pub struct CheckChannelsForUserRequest {- pub user_id: String,- pub channel_ids: Vec<Uuid>,-}--#[derive(Debug, Serialize, Deserialize)]-pub struct UserActivityForChannel {- /// The user id of the activity- pub user_id: String,- /// The updated_at time of the activity- /// This is used to compare against channel_notification_email_sent updated_at from- /// notification db to determine if the user should be notified via email.- pub updated_at: chrono::NaiveDateTime,-}--#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Type, ToSchema, Default)]-#[sqlx(type_name = "comms_participant_role", rename_all = "lowercase")]-#[serde(rename_all = "snake_case")]-pub enum ParticipantRole {- Owner,- Admin,- #[default]- Member,-}--#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]-pub struct ChannelParticipant {- /// id of the channel- #[schema(value_type = Uuid)]- pub channel_id: ChannelId,- /// id of the user- #[schema(value_type = String)]- pub user_id: MacroUserIdStr<'static>,- /// type of the participant- pub role: ParticipantRole,- /// timestamp of when the user joined the channel- pub joined_at: chrono::DateTime<chrono::Utc>,- /// timestamp of when the user left the channel- pub left_at: Option<chrono::DateTime<chrono::Utc>>,-}--#[derive(- Debug,- Clone,- Copy,- PartialEq,- Eq,- Display,- ToSchema,- Serialize,- Deserialize,- sqlx::Type,- schemars::JsonSchema,-)]-#[strum(serialize_all = "snake_case")]-#[serde(rename_all = "snake_case")]-#[sqlx(type_name = "comms_channel_type", rename_all = "snake_case")]-pub enum ChannelType {- Public,- Private,- DirectMessage,- Team,-}--#[derive(Debug, Clone, Serialize, Deserialize, ToSchema, PartialEq, Eq)]-pub struct Channel {- /// uuid of the channel- #[schema(value_type = Uuid)]- pub id: ChannelId,- /// string name of the channel- pub name: Option<String>,- /// type of the channel- pub channel_type: ChannelType,- /// id of the organization this channel belongs too- #[schema(value_type = Option<u32>)]- pub org_id: Option<OrganizationId>,- /// id of the team this channel belongs to- #[serde(default)]- pub team_id: Option<Uuid>,- /// timestamp of when the channel was created- pub created_at: chrono::DateTime<chrono::Utc>,- /// timestamp of when the channel was last updated- pub updated_at: chrono::DateTime<chrono::Utc>,- /// id of the user who created the channel- #[schema(value_type = String)]- pub owner_id: MacroUserIdStr<'static>,-}--#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]-pub struct ChannelWithParticipants {- #[serde(flatten)]- pub channel: Channel,- pub participants: Vec<ChannelParticipant>,-}--#[derive(Debug, Clone, Default, ToSchema, Serialize, Deserialize)]-pub struct LatestMessage {- pub latest_message: Option<ChannelMessage>,- pub latest_non_thread_message: Option<ChannelMessage>,-}--/// information about a channel used in search responses-#[derive(Debug, Clone, Serialize, Deserialize, Default)]-pub struct ChannelHistoryInfo {- pub item_id: Uuid,- pub created_at: DateTime<Utc>,- pub updated_at: DateTime<Utc>,- pub viewed_at: Option<DateTime<Utc>>,- pub interacted_at: Option<DateTime<Utc>>,- /// The id of the user who created the channel- pub user_id: String,- /// The string value of the channel type- pub channel_type: String,-}--#[derive(Debug, Serialize, Deserialize)]-pub struct GetChannelsHistoryRequest {- pub user_id: String,- pub channel_ids: Vec<Uuid>,-}--#[derive(Debug, Serialize, Deserialize)]-pub struct GetChannelsHistoryResponse {- pub channels_history: HashMap<Uuid, ChannelHistoryInfo>,-}--#[derive(Debug, Serialize, Deserialize)]-pub struct CreateWelcomeMessageRequest {- /// The id of the user to create the welcome message to- pub welcome_user_id: MacroUserIdStr<'static>,- /// The id of the user to send the welcome message to- pub to_user_id: MacroUserIdStr<'static>,-}--#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]-pub struct ChannelMessage {- pub message_id: Uuid,- pub thread_id: Option<Uuid>,- pub sender_id: String,- pub content: String,- pub created_at: chrono::DateTime<chrono::Utc>,- pub updated_at: chrono::DateTime<chrono::Utc>,- pub deleted_at: Option<chrono::DateTime<chrono::Utc>>,- /// message mentions formatted as `{ENTITY_TYPE}:{ENTITY_ID}`- pub mentions: Vec<String>,-}--#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]-pub struct Message {- pub id: Uuid,- pub channel_id: Uuid,- pub thread_id: Option<Uuid>,- #[schema(value_type = String)]- pub sender_id: MacroUserIdStr<'static>,- pub content: String,- pub created_at: chrono::DateTime<chrono::Utc>,- pub updated_at: chrono::DateTime<chrono::Utc>,- pub edited_at: Option<chrono::DateTime<chrono::Utc>>,- pub deleted_at: Option<chrono::DateTime<chrono::Utc>>,-}--#[derive(Debug, Serialize, Deserialize)]-pub struct GetChannelMessageResponse {- pub channel_id: Uuid,- pub name: Option<String>,- pub channel_type: ChannelType,- pub org_id: Option<i64>,- pub channel_message: ChannelMessage,-}--#[derive(Debug, Serialize, Deserialize, ToSchema)]-pub struct GetMessageWithContextResponse {- pub messages: Vec<Message>,-}--#[derive(Debug, Serialize, Deserialize)]-pub struct ChannelMetadataRequest {- pub channel_id: Uuid,-}--#[derive(Debug, Serialize, Deserialize)]-pub struct ChannelAttachmentTextRequest {- pub channel_id: Uuid,- pub since: Option<chrono::DateTime<chrono::Utc>>,- pub limit: Option<i64>,-}diff --git a/rust/cloud-storage/model/src/lib.rs b/rust/cloud-storage/model/src/lib.rsindex d9cbd36627..7e9c405208 100644--- a/rust/cloud-storage/model/src/lib.rs+++ b/rust/cloud-storage/model/src/lib.rs@@ -4,7 +4,6 @@ pub mod annotations;pub mod authentication;pub mod chat;pub mod citations;-pub mod comms;pub mod convert;pub mod document;pub mod document_storage_service_internal;diff --git a/rust/cloud-storage/models_soup/Cargo.toml b/rust/cloud-storage/models_soup/Cargo.tomlindex f8c29733a4..b56fd5e7e8 100644--- a/rust/cloud-storage/models_soup/Cargo.toml+++ b/rust/cloud-storage/models_soup/Cargo.toml@@ -11,6 +11,7 @@ schema = ["dep:utoipa", "item_filters/schema"][dependencies]anyhow = { workspace = true }call = { path = "../call", default-features = false }+channels = { path = "../channels", default-features = false, features = ["list"] }chrono = { workspace = true }crm = { path = "../crm", default-features = false }document_sub_type = { path = "../document_sub_type" }diff --git a/rust/cloud-storage/models_soup/src/comms.rs b/rust/cloud-storage/models_soup/src/comms.rsindex 5fc3cf2941..a046c7a966 100644--- a/rust/cloud-storage/models_soup/src/comms.rs+++ b/rust/cloud-storage/models_soup/src/comms.rs@@ -1,9 +1,105 @@-use model::comms;+use macro_user_id::{cowlike::CowLike, user_id::MacroUserIdStr};use serde::{Deserialize, Serialize};+use uuid::Uuid;-pub use comms::{- Channel, ChannelId, ChannelMessage, ChannelType, LatestMessage, OrganizationId, ParticipantRole,-};+/// Organization id for soup channel payloads.+#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]+#[serde(transparent)]+#[cfg_attr(feature = "schema", derive(utoipa::ToSchema))]+pub struct OrganizationId(pub u32);++/// Channel id for soup channel payloads.+#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, Hash)]+#[serde(transparent)]+#[cfg_attr(feature = "schema", derive(utoipa::ToSchema))]+pub struct ChannelId(pub Uuid);++/// Channel type for soup channel payloads.+#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]+#[serde(rename_all = "snake_case")]+#[cfg_attr(feature = "schema", derive(utoipa::ToSchema))]+pub enum ChannelType {+ /// Public channel.+ Public,+ /// Private group channel.+ Private,+ /// One-to-one direct message channel.+ DirectMessage,+ /// Team channel.+ Team,+}++/// Role of a channel participant.+#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]+#[serde(rename_all = "snake_case")]+#[cfg_attr(feature = "schema", derive(utoipa::ToSchema))]+pub enum ParticipantRole {+ /// Channel owner.+ Owner,+ /// Channel admin.+ Admin,+ /// Regular member.+ #[default]+ Member,+}++/// Channel metadata in soup payloads.+#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]+#[cfg_attr(feature = "schema", derive(utoipa::ToSchema))]+pub struct Channel {+ /// Channel id.+ #[cfg_attr(feature = "schema", schema(value_type = Uuid))]+ pub id: ChannelId,+ /// Channel display name.+ pub name: Option<String>,+ /// Channel type.+ pub channel_type: ChannelType,+ /// Organization id.+ #[cfg_attr(feature = "schema", schema(value_type = Option<u32>))]+ pub org_id: Option<OrganizationId>,+ /// Team id.+ #[serde(default)]+ pub team_id: Option<Uuid>,+ /// Creation timestamp.+ pub created_at: chrono::DateTime<chrono::Utc>,+ /// Update timestamp.+ pub updated_at: chrono::DateTime<chrono::Utc>,+ /// Channel owner.+ #[cfg_attr(feature = "schema", schema(value_type = String))]+ pub owner_id: MacroUserIdStr<'static>,+}++/// Lightweight channel message for soup payloads.+#[derive(Debug, Clone, Serialize, Deserialize)]+#[cfg_attr(feature = "schema", derive(utoipa::ToSchema))]+pub struct ChannelMessage {+ /// Message id.+ pub message_id: Uuid,+ /// Thread parent id.+ pub thread_id: Option<Uuid>,+ /// Sender id.+ pub sender_id: String,+ /// Message content.+ pub content: String,+ /// Creation timestamp.+ pub created_at: chrono::DateTime<chrono::Utc>,+ /// Update timestamp.+ pub updated_at: chrono::DateTime<chrono::Utc>,+ /// Deletion timestamp.+ pub deleted_at: Option<chrono::DateTime<chrono::Utc>>,+ /// Message mentions formatted as `{ENTITY_TYPE}:{ENTITY_ID}`.+ pub mentions: Vec<String>,+}++/// Latest-message bundle for soup payloads.+#[derive(Debug, Clone, Default, Serialize, Deserialize)]+#[cfg_attr(feature = "schema", derive(utoipa::ToSchema))]+pub struct LatestMessage {+ /// Latest message including thread replies.+ pub latest_message: Option<ChannelMessage>,+ /// Latest top-level non-thread message.+ pub latest_non_thread_message: Option<ChannelMessage>,+}#[derive(Debug, Serialize, Deserialize)]#[cfg_attr(feature = "schema", derive(utoipa::ToSchema))]@@ -26,7 +122,7 @@ pub struct ChannelWithParticipants {#[derive(Debug, Clone, Serialize, Deserialize)]#[cfg_attr(feature = "schema", derive(utoipa::ToSchema))]pub struct ChannelParticipant {- #[cfg_attr(feature = "schema", schema(value_type = uuid::Uuid))]+ #[cfg_attr(feature = "schema", schema(value_type = Uuid))]pub channel_id: ChannelId,#[cfg_attr(feature = "schema", schema(value_type = String))]pub user_id: macro_user_id::user_id::MacroUserIdStr<'static>,@@ -34,3 +130,106 @@ pub struct ChannelParticipant {pub joined_at: chrono::DateTime<chrono::Utc>,pub left_at: Option<chrono::DateTime<chrono::Utc>>,}++fn channel_type_from_channels(channel_type: channels::domain::models::ChannelType) -> ChannelType {+ match channel_type {+ channels::domain::models::ChannelType::Public => ChannelType::Public,+ channels::domain::models::ChannelType::Private => ChannelType::Private,+ channels::domain::models::ChannelType::DirectMessage => ChannelType::DirectMessage,+ channels::domain::models::ChannelType::Team => ChannelType::Team,+ }+}++fn participant_role_from_channels(+ role: channels::domain::models::ParticipantRole,+) -> ParticipantRole {+ match role {+ channels::domain::models::ParticipantRole::Owner => ParticipantRole::Owner,+ channels::domain::models::ParticipantRole::Admin => ParticipantRole::Admin,+ channels::domain::models::ParticipantRole::Member => ParticipantRole::Member,+ }+}++fn channel_message_from_channels(+ message: channels::domain::models::RecentChannelMessage,+) -> ChannelMessage {+ ChannelMessage {+ message_id: message.message_id,+ thread_id: message.thread_id,+ sender_id: message.sender_id,+ content: message.content,+ created_at: message.created_at,+ updated_at: message.updated_at,+ deleted_at: message.deleted_at,+ mentions: message.mentions,+ }+}++fn channel_from_channels(channel: channels::domain::models::ChannelListItem) -> Channel {+ Channel {+ id: ChannelId(channel.id),+ name: channel.name,+ channel_type: channel_type_from_channels(channel.channel_type),+ org_id: channel+ .org_id+ .and_then(|org_id| u32::try_from(org_id).ok())+ .map(OrganizationId),+ team_id: channel.team_id,+ created_at: channel.created_at,+ updated_at: channel.updated_at,+ owner_id: channel.owner_id,+ }+}++fn latest_message_from_channels(+ latest_message: channels::domain::models::LatestMessage,+) -> LatestMessage {+ LatestMessage {+ latest_message: latest_message+ .latest_message+ .map(channel_message_from_channels),+ latest_non_thread_message: latest_message+ .latest_non_thread_message+ .map(channel_message_from_channels),+ }+}++impl TryFrom<channels::domain::models::ChannelParticipant> for ChannelParticipant {+ type Error = macro_user_id::error::ParseErr;++ fn try_from(+ participant: channels::domain::models::ChannelParticipant,+ ) -> Result<Self, Self::Error> {+ Ok(Self {+ channel_id: ChannelId(participant.channel_id),+ user_id: MacroUserIdStr::parse_from_str(&participant.user_id)?.into_owned(),+ role: participant_role_from_channels(participant.role),+ joined_at: participant.joined_at,+ left_at: participant.left_at,+ })+ }+}++impl From<channels::domain::models::ChannelWithParticipants> for ChannelWithParticipants {+ fn from(channel: channels::domain::models::ChannelWithParticipants) -> Self {+ Self {+ channel: channel_from_channels(channel.channel),+ participants: channel+ .participants+ .into_iter()+ .filter_map(|participant| participant.try_into().ok())+ .collect(),+ }+ }+}++impl From<channels::domain::models::ChannelWithLatest> for SoupChannel {+ fn from(channel: channels::domain::models::ChannelWithLatest) -> Self {+ Self {+ channel: channel.channel.into(),+ latest_message: latest_message_from_channels(channel.latest_message),+ viewed_at: channel.viewed_at,+ interacted_at: channel.interacted_at,+ }+ }+}diff --git a/rust/cloud-storage/search_service/src/api/search/channel.rs b/rust/cloud-storage/search_service/src/api/search/channel.rsindex a785f93a0c..3995b6485b 100644--- a/rust/cloud-storage/search_service/src/api/search/channel.rs+++ b/rust/cloud-storage/search_service/src/api/search/channel.rs@@ -12,8 +12,8 @@ use axum::{response::Json,routing::post,};+use channels::domain::models::ChannelHistoryInfo;use macro_user_id::user_id::MacroUserId;-use model::comms::ChannelHistoryInfo;use model::user::UserContext;use models_search::MatchType;use models_search::channel::{diff --git a/rust/cloud-storage/seed_cli/Cargo.toml b/rust/cloud-storage/seed_cli/Cargo.tomlindex 040c5fc956..e864074ef6 100644--- a/rust/cloud-storage/seed_cli/Cargo.toml+++ b/rust/cloud-storage/seed_cli/Cargo.toml@@ -7,6 +7,7 @@ version = "0.1.0"[dependencies]anyhow = { workspace = true }aws-sdk-s3 = { workspace = true }+channels = { path = "../channels", default-features = false, features = ["outbound"] }chrono = { workspace = true }clap = { workspace = true }comms_db_client = { path = "../comms_db_client" }diff --git a/rust/cloud-storage/seed_cli/src/entity/channel/mod.rs b/rust/cloud-storage/seed_cli/src/entity/channel/mod.rsindex 3de6f60320..85773072ef 100644--- a/rust/cloud-storage/seed_cli/src/entity/channel/mod.rs+++ b/rust/cloud-storage/seed_cli/src/entity/channel/mod.rs@@ -6,10 +6,10 @@ mod test;use std::path::Path;use anyhow::Context;+use channels::domain::models::ChannelType;use clap::{Args, Subcommand, ValueEnum};use comms_db_client::channels::create_channel::CreateChannelOptions;use comms_db_client::channels::seed_channel::SeedChannelOptions;-use model::comms::ChannelType;use serde::Deserialize;use uuid::Uuid;diff --git a/rust/cloud-storage/soup/src/domain/service.rs b/rust/cloud-storage/soup/src/domain/service.rsindex 92e4caf815..f107fe0d77 100644--- a/rust/cloud-storage/soup/src/domain/service.rs+++ b/rust/cloud-storage/soup/src/domain/service.rs@@ -7,10 +7,7 @@ use crate::domain::{ports::{SoupOutput, SoupRepo, SoupService},};use call::domain::{models::GetCallRecordsRequest, ports::CallRecordQueryService};-use channels::domain::{- models::{ChannelType, GetChannelsRequest, ParticipantRole, RecentChannelMessage},- ports::ChannelListService,-};+use channels::domain::{models::GetChannelsRequest, ports::ChannelListService};use cowlike::CowLike;use crm::domain::service::CrmService;use doppleganger::Mirror;@@ -51,89 +48,6 @@ use uuid::Uuid;#[cfg(test)]mod tests;-fn channel_type_to_soup(channel_type: ChannelType) -> models_soup::comms::ChannelType {- match channel_type {- ChannelType::Public => models_soup::comms::ChannelType::Public,- ChannelType::Private => models_soup::comms::ChannelType::Private,- ChannelType::DirectMessage => models_soup::comms::ChannelType::DirectMessage,- ChannelType::Team => models_soup::comms::ChannelType::Team,- }-}--fn participant_role_to_soup(role: ParticipantRole) -> models_soup::comms::ParticipantRole {- match role {- ParticipantRole::Owner => models_soup::comms::ParticipantRole::Owner,- ParticipantRole::Admin => models_soup::comms::ParticipantRole::Admin,- ParticipantRole::Member => models_soup::comms::ParticipantRole::Member,- }-}--fn recent_channel_message_to_soup(- message: RecentChannelMessage,-) -> models_soup::comms::ChannelMessage {- models_soup::comms::ChannelMessage {- message_id: message.message_id,- thread_id: message.thread_id,- sender_id: message.sender_id,- content: message.content,- created_at: message.created_at,- updated_at: message.updated_at,- deleted_at: message.deleted_at,- mentions: message.mentions,- }-}--fn channel_to_soup_channel(- channel: channels::domain::models::ChannelWithLatest,-) -> Option<SoupChannel> {- let channel_item = channel.channel.channel;- Some(SoupChannel {- channel: models_soup::comms::ChannelWithParticipants {- channel: models_soup::comms::Channel {- id: models_soup::comms::ChannelId(channel_item.id),- name: channel_item.name,- channel_type: channel_type_to_soup(channel_item.channel_type),- org_id: channel_item- .org_id- .and_then(|org_id| u32::try_from(org_id).ok())- .map(models_soup::comms::OrganizationId),- team_id: channel_item.team_id,- created_at: channel_item.created_at,- updated_at: channel_item.updated_at,- owner_id: channel_item.owner_id,- },- participants: channel- .channel- .participants- .into_iter()- .filter_map(|participant| {- Some(models_soup::comms::ChannelParticipant {- channel_id: models_soup::comms::ChannelId(participant.channel_id),- user_id: MacroUserIdStr::parse_from_str(&participant.user_id)- .ok()?- .into_owned(),- role: participant_role_to_soup(participant.role),- joined_at: participant.joined_at,- left_at: participant.left_at,- })- })- .collect(),- },- latest_message: models_soup::comms::LatestMessage {- latest_message: channel- .latest_message- .latest_message- .map(recent_channel_message_to_soup),- latest_non_thread_message: channel- .latest_message- .latest_non_thread_message- .map(recent_channel_message_to_soup),- },- viewed_at: channel.viewed_at,- interacted_at: channel.interacted_at,- })-}-fn foreign_entity_to_soup_item(entity: ForeignEntity) -> SoupItem {SoupItem::ForeignEntity(SoupForeignEntity {id: entity.id,@@ -473,13 +387,13 @@ where.await.map_err(|_| SoupErr::CommsErr).map(|r| {- r.into_iter().filter_map(|mut c| {+ r.into_iter().map(|mut c| {let frecency_score = c.frecency_score.take();- let soup_channel = channel_to_soup_channel(c)?;- Some(FrecencySoupItem {+ let soup_channel = SoupChannel::from(c);+ FrecencySoupItem {item: SoupItem::Channel(soup_channel),frecency_score,- })+ }})})?,))