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.

Update soup channel thread payload shape (#4231)

Sean Aye8dc6cc5b0b5d
diff --git a/js/app/packages/queries/soup/normalized-cache/operations.ts b/js/app/packages/queries/soup/normalized-cache/operations.ts
index 1900700d82..631d6f4b18 100644
--- a/js/app/packages/queries/soup/normalized-cache/operations.ts
+++ b/js/app/packages/queries/soup/normalized-cache/operations.ts
@@ -150,7 +150,7 @@ export function getSoupItemId(item: SoupApiItem): string {
case 'call':
return item.data.callId;
case 'channelThread':
- return item.data.root_message.message_id;
+ return item.data.id;
default:
return item.data.id;
}
diff --git a/js/app/packages/queries/soup/normalized-cache/types.ts b/js/app/packages/queries/soup/normalized-cache/types.ts
index 566f46ff9b..b573f5d9e5 100644
--- a/js/app/packages/queries/soup/normalized-cache/types.ts
+++ b/js/app/packages/queries/soup/normalized-cache/types.ts
@@ -13,7 +13,6 @@ type SoupItemData<T extends SoupEntityTag> = Extract<
// Channel's inner Channel object (for partial nested updates like { channel: { id, name } })
type ChannelInner = SoupItemData<'channel'>['channel'];
-type ChannelThreadRootMessage = SoupItemData<'channelThread'>['root_message'];
// Partial data: require the entity ID, all else optional.
// Channel is special — ID lives at data.channel.id.
@@ -23,12 +22,7 @@ type SoupPartialData<T extends SoupEntityTag> = T extends 'channel'
>
: T extends 'call'
? Partial<SoupItemData<'call'>> & { callId: string }
- : T extends 'channelThread'
- ? {
- root_message: Partial<ChannelThreadRootMessage> &
- Pick<ChannelThreadRootMessage, 'message_id'>;
- } & Partial<Omit<SoupItemData<'channelThread'>, 'root_message'>>
- : Partial<SoupItemData<T>> & { id: string };
+ : Partial<SoupItemData<T>> & { id: string };
// A partial soup entity for optimistic updates.
export type SoupEntityPartial<T extends SoupEntityTag = SoupEntityTag> = {
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 cc75670d2c..1c71c329ca 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
@@ -846,6 +846,8 @@ export * from './soupChannelAllOf';
export * from './soupChannelAllOfInteractedAt';
export * from './soupChannelAllOfViewedAt';
export * from './soupChannelThread';
+export * from './soupChannelThreadDeletedAt';
+export * from './soupChannelThreadEditedAt';
export * from './soupChat';
export * from './soupChatDeletedAt';
export * from './soupChatProjectId';
@@ -854,6 +856,7 @@ export * from './soupContact';
export * from './soupContactEmailAddress';
export * from './soupContactName';
export * from './soupContactSfsPhotoUrl';
+export * from './soupCountedReaction';
export * from './soupCrmCompany';
export * from './soupCrmCompanyDescription';
export * from './soupCrmCompanyName';
@@ -909,7 +912,14 @@ export * from './soupItemOneOfThreeTag';
export * from './soupLabel';
export * from './soupLabelListVisibility';
export * from './soupLabelType';
+export * from './soupMessageAttachment';
+export * from './soupMessageAttachmentHeight';
+export * from './soupMessageAttachmentWidth';
export * from './soupMessageListVisibility';
+export * from './soupMessageSender';
+export * from './soupMessageSenderAvatarUrl';
+export * from './soupMessageSenderName';
+export * from './soupMessageSenderType';
export * from './soupPage';
export * from './soupPageNextCursor';
export * from './soupProject';
@@ -918,6 +928,10 @@ export * from './soupProjectParentId';
export * from './soupProjectViewedAt';
export * from './soupProperty';
export * from './soupPropertyValue';
+export * from './soupThreadInfo';
+export * from './soupThreadInfoLatestReplyAt';
+export * from './soupThreadReply';
+export * from './soupThreadReplyEditedAt';
export * from './successResponse';
export * from './syncServiceVersionID';
export * from './taskFilters';
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/soupChannelThread.ts b/js/app/packages/service-clients/service-storage/generated/schemas/soupChannelThread.ts
index ced30d8599..b6ebf8e680 100644
--- a/js/app/packages/service-clients/service-storage/generated/schemas/soupChannelThread.ts
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/soupChannelThread.ts
@@ -4,19 +4,43 @@
* document_storage_service
* OpenAPI spec version: 0.1.0
*/
-import type { ChannelMessage } from './channelMessage';
+
+import type { SoupChannelThreadDeletedAt } from './soupChannelThreadDeletedAt';
+import type { SoupChannelThreadEditedAt } from './soupChannelThreadEditedAt';
+import type { SoupCountedReaction } from './soupCountedReaction';
+import type { SoupMessageAttachment } from './soupMessageAttachment';
+import type { SoupMessageSender } from './soupMessageSender';
+import type { SoupThreadInfo } from './soupThreadInfo';
/**
* A top-level channel message thread for soup payloads.
-This reuses the existing lightweight [`ChannelMessage`] shape used by
-[`SoupChannel`] latest-message data.
+This mirrors the public channel-message API shape so soup consumers can
+render a thread root the same way they render a channel timeline message.
*/
export interface SoupChannelThread {
- /** Channel that owns the thread. */
+ /** Attachments on this message. */
+ attachments: SoupMessageAttachment[];
+ /** Channel id. */
channel_id: string;
- /** Thread replies, using the same lightweight channel message shape. */
- messages: ChannelMessage[];
- /** Top-level message that acts as the thread parent. */
- root_message: ChannelMessage;
+ /** Message content. */
+ content: string;
+ /** Creation timestamp. */
+ created_at: string;
+ /** Deletion timestamp. */
+ deleted_at?: SoupChannelThreadDeletedAt;
+ /** Edit timestamp. */
+ edited_at?: SoupChannelThreadEditedAt;
+ /** Message id. */
+ id: string;
+ /** Reactions on this message. */
+ reactions: SoupCountedReaction[];
+ /** Structured sender identity. */
+ sender: SoupMessageSender;
+ /** Sender id. */
+ sender_id: string;
+ /** Thread metadata and preview replies. */
+ thread: SoupThreadInfo;
+ /** Update timestamp. */
+ updated_at: string;
}
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/soupChannelThreadDeletedAt.ts b/js/app/packages/service-clients/service-storage/generated/schemas/soupChannelThreadDeletedAt.ts
new file mode 100644
index 0000000000..6d0af8cc30
--- /dev/null
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/soupChannelThreadDeletedAt.ts
@@ -0,0 +1,11 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * Deletion timestamp.
+ */
+export type SoupChannelThreadDeletedAt = string | null;
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/soupChannelThreadEditedAt.ts b/js/app/packages/service-clients/service-storage/generated/schemas/soupChannelThreadEditedAt.ts
new file mode 100644
index 0000000000..dd05131775
--- /dev/null
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/soupChannelThreadEditedAt.ts
@@ -0,0 +1,11 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * Edit timestamp.
+ */
+export type SoupChannelThreadEditedAt = string | null;
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/soupCountedReaction.ts b/js/app/packages/service-clients/service-storage/generated/schemas/soupCountedReaction.ts
new file mode 100644
index 0000000000..7ba58c0cec
--- /dev/null
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/soupCountedReaction.ts
@@ -0,0 +1,16 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * A reaction with emoji and user list.
+ */
+export interface SoupCountedReaction {
+ /** Emoji string. */
+ emoji: string;
+ /** User ids who added this reaction. */
+ users: string[];
+}
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/soupMessageAttachment.ts b/js/app/packages/service-clients/service-storage/generated/schemas/soupMessageAttachment.ts
new file mode 100644
index 0000000000..b00f832964
--- /dev/null
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/soupMessageAttachment.ts
@@ -0,0 +1,26 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+import type { SoupMessageAttachmentHeight } from './soupMessageAttachmentHeight';
+import type { SoupMessageAttachmentWidth } from './soupMessageAttachmentWidth';
+
+/**
+ * An attachment on a message.
+ */
+export interface SoupMessageAttachment {
+ /** Creation timestamp. */
+ created_at: string;
+ /** Entity id. */
+ entity_id: string;
+ /** Type of entity. */
+ entity_type: string;
+ /** Height for images. */
+ height?: SoupMessageAttachmentHeight;
+ /** Attachment id. */
+ id: string;
+ /** Width for images. */
+ width?: SoupMessageAttachmentWidth;
+}
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/soupMessageAttachmentHeight.ts b/js/app/packages/service-clients/service-storage/generated/schemas/soupMessageAttachmentHeight.ts
new file mode 100644
index 0000000000..5483ed6eb6
--- /dev/null
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/soupMessageAttachmentHeight.ts
@@ -0,0 +1,11 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * Height for images.
+ */
+export type SoupMessageAttachmentHeight = number | null;
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/soupMessageAttachmentWidth.ts b/js/app/packages/service-clients/service-storage/generated/schemas/soupMessageAttachmentWidth.ts
new file mode 100644
index 0000000000..2fcea689c3
--- /dev/null
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/soupMessageAttachmentWidth.ts
@@ -0,0 +1,11 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * Width for images.
+ */
+export type SoupMessageAttachmentWidth = number | null;
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/soupMessageSender.ts b/js/app/packages/service-clients/service-storage/generated/schemas/soupMessageSender.ts
new file mode 100644
index 0000000000..173ffd91ac
--- /dev/null
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/soupMessageSender.ts
@@ -0,0 +1,23 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+import type { SoupMessageSenderAvatarUrl } from './soupMessageSenderAvatarUrl';
+import type { SoupMessageSenderName } from './soupMessageSenderName';
+import type { SoupMessageSenderType } from './soupMessageSenderType';
+
+/**
+ * Public sender identity for soup channel messages.
+ */
+export interface SoupMessageSender {
+ /** Avatar URL for bot senders. */
+ avatar_url?: SoupMessageSenderAvatarUrl;
+ /** Sender id without the storage namespace prefix. */
+ id: string;
+ /** Display name for bot senders. */
+ name?: SoupMessageSenderName;
+ /** Sender type. */
+ type: SoupMessageSenderType;
+}
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/soupMessageSenderAvatarUrl.ts b/js/app/packages/service-clients/service-storage/generated/schemas/soupMessageSenderAvatarUrl.ts
new file mode 100644
index 0000000000..eb16b28571
--- /dev/null
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/soupMessageSenderAvatarUrl.ts
@@ -0,0 +1,11 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * Avatar URL for bot senders.
+ */
+export type SoupMessageSenderAvatarUrl = string | null;
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/soupMessageSenderName.ts b/js/app/packages/service-clients/service-storage/generated/schemas/soupMessageSenderName.ts
new file mode 100644
index 0000000000..2e151e6b93
--- /dev/null
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/soupMessageSenderName.ts
@@ -0,0 +1,11 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * Display name for bot senders.
+ */
+export type SoupMessageSenderName = string | null;
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/soupMessageSenderType.ts b/js/app/packages/service-clients/service-storage/generated/schemas/soupMessageSenderType.ts
new file mode 100644
index 0000000000..b062e96747
--- /dev/null
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/soupMessageSenderType.ts
@@ -0,0 +1,18 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * Public sender type for soup channel messages.
+ */
+export type SoupMessageSenderType =
+ (typeof SoupMessageSenderType)[keyof typeof SoupMessageSenderType];
+
+// eslint-disable-next-line @typescript-eslint/no-redeclare
+export const SoupMessageSenderType = {
+ user: 'user',
+ bot: 'bot',
+} as const;
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/soupThreadInfo.ts b/js/app/packages/service-clients/service-storage/generated/schemas/soupThreadInfo.ts
new file mode 100644
index 0000000000..ee123bb370
--- /dev/null
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/soupThreadInfo.ts
@@ -0,0 +1,20 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+import type { SoupThreadInfoLatestReplyAt } from './soupThreadInfoLatestReplyAt';
+import type { SoupThreadReply } from './soupThreadReply';
+
+/**
+ * Thread metadata and preview replies for soup channel messages.
+ */
+export interface SoupThreadInfo {
+ /** Timestamp of the latest reply. */
+ latest_reply_at?: SoupThreadInfoLatestReplyAt;
+ /** Preview replies. */
+ preview: SoupThreadReply[];
+ /** Total reply count. */
+ reply_count: number;
+}
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/soupThreadInfoLatestReplyAt.ts b/js/app/packages/service-clients/service-storage/generated/schemas/soupThreadInfoLatestReplyAt.ts
new file mode 100644
index 0000000000..01da3e7f9b
--- /dev/null
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/soupThreadInfoLatestReplyAt.ts
@@ -0,0 +1,11 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * Timestamp of the latest reply.
+ */
+export type SoupThreadInfoLatestReplyAt = string | null;
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/soupThreadReply.ts b/js/app/packages/service-clients/service-storage/generated/schemas/soupThreadReply.ts
new file mode 100644
index 0000000000..318f8b511a
--- /dev/null
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/soupThreadReply.ts
@@ -0,0 +1,35 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+import type { SoupCountedReaction } from './soupCountedReaction';
+import type { SoupMessageAttachment } from './soupMessageAttachment';
+import type { SoupMessageSender } from './soupMessageSender';
+import type { SoupThreadReplyEditedAt } from './soupThreadReplyEditedAt';
+
+/**
+ * A thread reply shown in preview.
+ */
+export interface SoupThreadReply {
+ /** Attachments on this reply. */
+ attachments: SoupMessageAttachment[];
+ /** Reply content. */
+ content: string;
+ /** Creation timestamp. */
+ created_at: string;
+ /** Edit timestamp. */
+ edited_at?: SoupThreadReplyEditedAt;
+ /** Reply id. */
+ id: string;
+ /** Reactions on this reply. */
+ reactions: SoupCountedReaction[];
+ /** Structured sender identity. */
+ sender: SoupMessageSender;
+ /** Sender id. */
+ sender_id: string;
+ /** Update timestamp. */
+ updated_at: string;
+}
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/soupThreadReplyEditedAt.ts b/js/app/packages/service-clients/service-storage/generated/schemas/soupThreadReplyEditedAt.ts
new file mode 100644
index 0000000000..8e95f3ea86
--- /dev/null
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/soupThreadReplyEditedAt.ts
@@ -0,0 +1,11 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * Edit timestamp.
+ */
+export type SoupThreadReplyEditedAt = string | null;
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 445a00202f..376ae1f7ea 100644
--- a/js/app/packages/service-clients/service-storage/generated/zod.ts
+++ b/js/app/packages/service-clients/service-storage/generated/zod.ts
@@ -7671,72 +7671,185 @@ export const getItemsSoupResponse = zod
.object({
data: zod
.object({
- channel_id: zod
- .uuid()
- .describe('Channel that owns the thread.'),
- messages: zod
+ attachments: zod
.array(
zod
.object({
- content: zod.string().describe('Message content.'),
created_at: zod.iso
.datetime({})
.describe('Creation timestamp.'),
- deleted_at: zod.iso
- .datetime({})
+ entity_id: zod.string().describe('Entity id.'),
+ entity_type: zod.string().describe('Type of entity.'),
+ height: zod
+ .number()
.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()
+ .describe('Height for images.'),
+ id: zod.uuid().describe('Attachment id.'),
+ width: zod
+ .number()
.nullish()
- .describe('Thread parent id.'),
- updated_at: zod.iso
- .datetime({})
- .describe('Update timestamp.'),
+ .describe('Width for images.'),
})
- .describe(
- 'Lightweight channel message for soup payloads.'
- )
+ .describe('An attachment on a message.')
)
- .describe(
- 'Thread replies, using the same lightweight channel message shape.'
- ),
- root_message: zod
+ .describe('Attachments on this message.'),
+ channel_id: zod.uuid().describe('Channel id.'),
+ content: zod.string().describe('Message content.'),
+ created_at: zod.iso
+ .datetime({})
+ .describe('Creation timestamp.'),
+ deleted_at: zod.iso
+ .datetime({})
+ .nullish()
+ .describe('Deletion timestamp.'),
+ edited_at: zod.iso
+ .datetime({})
+ .nullish()
+ .describe('Edit timestamp.'),
+ id: zod.uuid().describe('Message id.'),
+ reactions: zod
+ .array(
+ zod
+ .object({
+ emoji: zod.string().describe('Emoji string.'),
+ users: zod
+ .array(zod.string())
+ .describe('User ids who added this reaction.'),
+ })
+ .describe('A reaction with emoji and user list.')
+ )
+ .describe('Reactions on this message.'),
+ sender: zod
.object({
- content: zod.string().describe('Message content.'),
- created_at: zod.iso
- .datetime({})
- .describe('Creation timestamp.'),
- deleted_at: zod.iso
- .datetime({})
+ avatar_url: zod
+ .string()
.nullish()
- .describe('Deletion timestamp.'),
- mentions: zod
- .array(zod.string())
+ .describe('Avatar URL for bot senders.'),
+ id: zod
+ .string()
.describe(
- 'Message mentions formatted as `{ENTITY_TYPE}:{ENTITY_ID}`.'
+ 'Sender id without the storage namespace prefix.'
),
- message_id: zod.uuid().describe('Message id.'),
- sender_id: zod.string().describe('Sender id.'),
- thread_id: zod
- .uuid()
+ name: zod
+ .string()
.nullish()
- .describe('Thread parent id.'),
- updated_at: zod.iso
+ .describe('Display name for bot senders.'),
+ type: zod
+ .enum(['user', 'bot'])
+ .describe(
+ 'Public sender type for soup channel messages.'
+ ),
+ })
+ .describe(
+ 'Public sender identity for soup channel messages.'
+ ),
+ sender_id: zod.string().describe('Sender id.'),
+ thread: zod
+ .object({
+ latest_reply_at: zod.iso
.datetime({})
- .describe('Update timestamp.'),
+ .nullish()
+ .describe('Timestamp of the latest reply.'),
+ preview: zod
+ .array(
+ zod
+ .object({
+ attachments: zod
+ .array(
+ zod
+ .object({
+ created_at: zod.iso
+ .datetime({})
+ .describe('Creation timestamp.'),
+ entity_id: zod
+ .string()
+ .describe('Entity id.'),
+ entity_type: zod
+ .string()
+ .describe('Type of entity.'),
+ height: zod
+ .number()
+ .nullish()
+ .describe('Height for images.'),
+ id: zod.uuid().describe('Attachment id.'),
+ width: zod
+ .number()
+ .nullish()
+ .describe('Width for images.'),
+ })
+ .describe('An attachment on a message.')
+ )
+ .describe('Attachments on this reply.'),
+ content: zod.string().describe('Reply content.'),
+ created_at: zod.iso
+ .datetime({})
+ .describe('Creation timestamp.'),
+ edited_at: zod.iso
+ .datetime({})
+ .nullish()
+ .describe('Edit timestamp.'),
+ id: zod.uuid().describe('Reply id.'),
+ reactions: zod
+ .array(
+ zod
+ .object({
+ emoji: zod
+ .string()
+ .describe('Emoji string.'),
+ users: zod
+ .array(zod.string())
+ .describe(
+ 'User ids who added this reaction.'
+ ),
+ })
+ .describe(
+ 'A reaction with emoji and user list.'
+ )
+ )
+ .describe('Reactions on this reply.'),
+ sender: zod
+ .object({
+ avatar_url: zod
+ .string()
+ .nullish()
+ .describe('Avatar URL for bot senders.'),
+ id: zod
+ .string()
+ .describe(
+ 'Sender id without the storage namespace prefix.'
+ ),
+ name: zod
+ .string()
+ .nullish()
+ .describe('Display name for bot senders.'),
+ type: zod
+ .enum(['user', 'bot'])
+ .describe(
+ 'Public sender type for soup channel messages.'
+ ),
+ })
+ .describe(
+ 'Public sender identity for soup channel messages.'
+ ),
+ sender_id: zod.string().describe('Sender id.'),
+ updated_at: zod.iso
+ .datetime({})
+ .describe('Update timestamp.'),
+ })
+ .describe('A thread reply shown in preview.')
+ )
+ .describe('Preview replies.'),
+ reply_count: zod.number().describe('Total reply count.'),
})
- .describe('Lightweight channel message for soup payloads.'),
+ .describe(
+ 'Thread metadata and preview replies for soup channel messages.'
+ ),
+ updated_at: zod.iso
+ .datetime({})
+ .describe('Update timestamp.'),
})
.describe(
- 'A top-level channel message thread for soup payloads.\n\nThis reuses the existing lightweight [`ChannelMessage`] shape used by\n[`SoupChannel`] latest-message data.'
+ 'A top-level channel message thread for soup payloads.\n\nThis mirrors the public channel-message API shape so soup consumers can\nrender a thread root the same way they render a channel timeline message.'
),
tag: zod.enum(['channelThread']),
})
@@ -9935,72 +10048,185 @@ export const postItemsSoupResponse = zod
.object({
data: zod
.object({
- channel_id: zod
- .uuid()
- .describe('Channel that owns the thread.'),
- messages: zod
+ attachments: zod
.array(
zod
.object({
- content: zod.string().describe('Message content.'),
created_at: zod.iso
.datetime({})
.describe('Creation timestamp.'),
- deleted_at: zod.iso
- .datetime({})
+ entity_id: zod.string().describe('Entity id.'),
+ entity_type: zod.string().describe('Type of entity.'),
+ height: zod
+ .number()
.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()
+ .describe('Height for images.'),
+ id: zod.uuid().describe('Attachment id.'),
+ width: zod
+ .number()
.nullish()
- .describe('Thread parent id.'),
- updated_at: zod.iso
- .datetime({})
- .describe('Update timestamp.'),
+ .describe('Width for images.'),
})
- .describe(
- 'Lightweight channel message for soup payloads.'
- )
+ .describe('An attachment on a message.')
)
- .describe(
- 'Thread replies, using the same lightweight channel message shape.'
- ),
- root_message: zod
+ .describe('Attachments on this message.'),
+ channel_id: zod.uuid().describe('Channel id.'),
+ content: zod.string().describe('Message content.'),
+ created_at: zod.iso
+ .datetime({})
+ .describe('Creation timestamp.'),
+ deleted_at: zod.iso
+ .datetime({})
+ .nullish()
+ .describe('Deletion timestamp.'),
+ edited_at: zod.iso
+ .datetime({})
+ .nullish()
+ .describe('Edit timestamp.'),
+ id: zod.uuid().describe('Message id.'),
+ reactions: zod
+ .array(
+ zod
+ .object({
+ emoji: zod.string().describe('Emoji string.'),
+ users: zod
+ .array(zod.string())
+ .describe('User ids who added this reaction.'),
+ })
+ .describe('A reaction with emoji and user list.')
+ )
+ .describe('Reactions on this message.'),
+ sender: zod
.object({
- content: zod.string().describe('Message content.'),
- created_at: zod.iso
- .datetime({})
- .describe('Creation timestamp.'),
- deleted_at: zod.iso
- .datetime({})
+ avatar_url: zod
+ .string()
.nullish()
- .describe('Deletion timestamp.'),
- mentions: zod
- .array(zod.string())
+ .describe('Avatar URL for bot senders.'),
+ id: zod
+ .string()
.describe(
- 'Message mentions formatted as `{ENTITY_TYPE}:{ENTITY_ID}`.'
+ 'Sender id without the storage namespace prefix.'
),
- message_id: zod.uuid().describe('Message id.'),
- sender_id: zod.string().describe('Sender id.'),
- thread_id: zod
- .uuid()
+ name: zod
+ .string()
.nullish()
- .describe('Thread parent id.'),
- updated_at: zod.iso
+ .describe('Display name for bot senders.'),
+ type: zod
+ .enum(['user', 'bot'])
+ .describe(
+ 'Public sender type for soup channel messages.'
+ ),
+ })
+ .describe(
+ 'Public sender identity for soup channel messages.'
+ ),
+ sender_id: zod.string().describe('Sender id.'),
+ thread: zod
+ .object({
+ latest_reply_at: zod.iso
.datetime({})
- .describe('Update timestamp.'),
+ .nullish()
+ .describe('Timestamp of the latest reply.'),
+ preview: zod
+ .array(
+ zod
+ .object({
+ attachments: zod
+ .array(
+ zod
+ .object({
+ created_at: zod.iso
+ .datetime({})
+ .describe('Creation timestamp.'),
+ entity_id: zod
+ .string()
+ .describe('Entity id.'),
+ entity_type: zod
+ .string()
+ .describe('Type of entity.'),
+ height: zod
+ .number()
+ .nullish()
+ .describe('Height for images.'),
+ id: zod.uuid().describe('Attachment id.'),
+ width: zod
+ .number()
+ .nullish()
+ .describe('Width for images.'),
+ })
+ .describe('An attachment on a message.')
+ )
+ .describe('Attachments on this reply.'),
+ content: zod.string().describe('Reply content.'),
+ created_at: zod.iso
+ .datetime({})
+ .describe('Creation timestamp.'),
+ edited_at: zod.iso
+ .datetime({})
+ .nullish()
+ .describe('Edit timestamp.'),
+ id: zod.uuid().describe('Reply id.'),
+ reactions: zod
+ .array(
+ zod
+ .object({
+ emoji: zod
+ .string()
+ .describe('Emoji string.'),
+ users: zod
+ .array(zod.string())
+ .describe(
+ 'User ids who added this reaction.'
+ ),
+ })
+ .describe(
+ 'A reaction with emoji and user list.'
+ )
+ )
+ .describe('Reactions on this reply.'),
+ sender: zod
+ .object({
+ avatar_url: zod
+ .string()
+ .nullish()
+ .describe('Avatar URL for bot senders.'),
+ id: zod
+ .string()
+ .describe(
+ 'Sender id without the storage namespace prefix.'
+ ),
+ name: zod
+ .string()
+ .nullish()
+ .describe('Display name for bot senders.'),
+ type: zod
+ .enum(['user', 'bot'])
+ .describe(
+ 'Public sender type for soup channel messages.'
+ ),
+ })
+ .describe(
+ 'Public sender identity for soup channel messages.'
+ ),
+ sender_id: zod.string().describe('Sender id.'),
+ updated_at: zod.iso
+ .datetime({})
+ .describe('Update timestamp.'),
+ })
+ .describe('A thread reply shown in preview.')
+ )
+ .describe('Preview replies.'),
+ reply_count: zod.number().describe('Total reply count.'),
})
- .describe('Lightweight channel message for soup payloads.'),
+ .describe(
+ 'Thread metadata and preview replies for soup channel messages.'
+ ),
+ updated_at: zod.iso
+ .datetime({})
+ .describe('Update timestamp.'),
})
.describe(
- 'A top-level channel message thread for soup payloads.\n\nThis reuses the existing lightweight [`ChannelMessage`] shape used by\n[`SoupChannel`] latest-message data.'
+ 'A top-level channel message thread for soup payloads.\n\nThis mirrors the public channel-message API shape so soup consumers can\nrender a thread root the same way they render a channel timeline message.'
),
tag: zod.enum(['channelThread']),
})
@@ -11743,72 +11969,185 @@ export const postItemsSoupAstResponse = zod
.object({
data: zod
.object({
- channel_id: zod
- .uuid()
- .describe('Channel that owns the thread.'),
- messages: zod
+ attachments: zod
.array(
zod
.object({
- content: zod.string().describe('Message content.'),
created_at: zod.iso
.datetime({})
.describe('Creation timestamp.'),
- deleted_at: zod.iso
- .datetime({})
+ entity_id: zod.string().describe('Entity id.'),
+ entity_type: zod.string().describe('Type of entity.'),
+ height: zod
+ .number()
.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()
+ .describe('Height for images.'),
+ id: zod.uuid().describe('Attachment id.'),
+ width: zod
+ .number()
.nullish()
- .describe('Thread parent id.'),
- updated_at: zod.iso
- .datetime({})
- .describe('Update timestamp.'),
+ .describe('Width for images.'),
})
- .describe(
- 'Lightweight channel message for soup payloads.'
- )
+ .describe('An attachment on a message.')
)
- .describe(
- 'Thread replies, using the same lightweight channel message shape.'
- ),
- root_message: zod
+ .describe('Attachments on this message.'),
+ channel_id: zod.uuid().describe('Channel id.'),
+ content: zod.string().describe('Message content.'),
+ created_at: zod.iso
+ .datetime({})
+ .describe('Creation timestamp.'),
+ deleted_at: zod.iso
+ .datetime({})
+ .nullish()
+ .describe('Deletion timestamp.'),
+ edited_at: zod.iso
+ .datetime({})
+ .nullish()
+ .describe('Edit timestamp.'),
+ id: zod.uuid().describe('Message id.'),
+ reactions: zod
+ .array(
+ zod
+ .object({
+ emoji: zod.string().describe('Emoji string.'),
+ users: zod
+ .array(zod.string())
+ .describe('User ids who added this reaction.'),
+ })
+ .describe('A reaction with emoji and user list.')
+ )
+ .describe('Reactions on this message.'),
+ sender: zod
.object({
- content: zod.string().describe('Message content.'),
- created_at: zod.iso
- .datetime({})
- .describe('Creation timestamp.'),
- deleted_at: zod.iso
- .datetime({})
+ avatar_url: zod
+ .string()
.nullish()
- .describe('Deletion timestamp.'),
- mentions: zod
- .array(zod.string())
+ .describe('Avatar URL for bot senders.'),
+ id: zod
+ .string()
.describe(
- 'Message mentions formatted as `{ENTITY_TYPE}:{ENTITY_ID}`.'
+ 'Sender id without the storage namespace prefix.'
),
- message_id: zod.uuid().describe('Message id.'),
- sender_id: zod.string().describe('Sender id.'),
- thread_id: zod
- .uuid()
+ name: zod
+ .string()
.nullish()
- .describe('Thread parent id.'),
- updated_at: zod.iso
+ .describe('Display name for bot senders.'),
+ type: zod
+ .enum(['user', 'bot'])
+ .describe(
+ 'Public sender type for soup channel messages.'
+ ),
+ })
+ .describe(
+ 'Public sender identity for soup channel messages.'
+ ),
+ sender_id: zod.string().describe('Sender id.'),
+ thread: zod
+ .object({
+ latest_reply_at: zod.iso
.datetime({})
- .describe('Update timestamp.'),
+ .nullish()
+ .describe('Timestamp of the latest reply.'),
+ preview: zod
+ .array(
+ zod
+ .object({
+ attachments: zod
+ .array(
+ zod
+ .object({
+ created_at: zod.iso
+ .datetime({})
+ .describe('Creation timestamp.'),
+ entity_id: zod
+ .string()
+ .describe('Entity id.'),
+ entity_type: zod
+ .string()
+ .describe('Type of entity.'),
+ height: zod
+ .number()
+ .nullish()
+ .describe('Height for images.'),
+ id: zod.uuid().describe('Attachment id.'),
+ width: zod
+ .number()
+ .nullish()
+ .describe('Width for images.'),
+ })
+ .describe('An attachment on a message.')
+ )
+ .describe('Attachments on this reply.'),
+ content: zod.string().describe('Reply content.'),
+ created_at: zod.iso
+ .datetime({})
+ .describe('Creation timestamp.'),
+ edited_at: zod.iso
+ .datetime({})
+ .nullish()
+ .describe('Edit timestamp.'),
+ id: zod.uuid().describe('Reply id.'),
+ reactions: zod
+ .array(
+ zod
+ .object({
+ emoji: zod
+ .string()
+ .describe('Emoji string.'),
+ users: zod
+ .array(zod.string())
+ .describe(
+ 'User ids who added this reaction.'
+ ),
+ })
+ .describe(
+ 'A reaction with emoji and user list.'
+ )
+ )
+ .describe('Reactions on this reply.'),
+ sender: zod
+ .object({
+ avatar_url: zod
+ .string()
+ .nullish()
+ .describe('Avatar URL for bot senders.'),
+ id: zod
+ .string()
+ .describe(
+ 'Sender id without the storage namespace prefix.'
+ ),
+ name: zod
+ .string()
+ .nullish()
+ .describe('Display name for bot senders.'),
+ type: zod
+ .enum(['user', 'bot'])
+ .describe(
+ 'Public sender type for soup channel messages.'
+ ),
+ })
+ .describe(
+ 'Public sender identity for soup channel messages.'
+ ),
+ sender_id: zod.string().describe('Sender id.'),
+ updated_at: zod.iso
+ .datetime({})
+ .describe('Update timestamp.'),
+ })
+ .describe('A thread reply shown in preview.')
+ )
+ .describe('Preview replies.'),
+ reply_count: zod.number().describe('Total reply count.'),
})
- .describe('Lightweight channel message for soup payloads.'),
+ .describe(
+ 'Thread metadata and preview replies for soup channel messages.'
+ ),
+ updated_at: zod.iso
+ .datetime({})
+ .describe('Update timestamp.'),
})
.describe(
- 'A top-level channel message thread for soup payloads.\n\nThis reuses the existing lightweight [`ChannelMessage`] shape used by\n[`SoupChannel`] latest-message data.'
+ 'A top-level channel message thread for soup payloads.\n\nThis mirrors the public channel-message API shape so soup consumers can\nrender a thread root the same way they render a channel timeline message.'
),
tag: zod.enum(['channelThread']),
})
@@ -13859,76 +14198,203 @@ export const postItemsSoupAstGroupedResponse = zod
.object({
data: zod
.object({
- channel_id: zod
- .uuid()
- .describe('Channel that owns the thread.'),
- messages: zod
+ attachments: zod
.array(
zod
.object({
- content: zod
- .string()
- .describe('Message content.'),
created_at: zod.iso
.datetime({})
.describe('Creation timestamp.'),
- deleted_at: zod.iso
- .datetime({})
+ entity_id: zod.string().describe('Entity id.'),
+ entity_type: zod
+ .string()
+ .describe('Type of entity.'),
+ height: zod
+ .number()
.nullish()
- .describe('Deletion timestamp.'),
- mentions: zod
+ .describe('Height for images.'),
+ id: zod.uuid().describe('Attachment id.'),
+ width: zod
+ .number()
+ .nullish()
+ .describe('Width for images.'),
+ })
+ .describe('An attachment on a message.')
+ )
+ .describe('Attachments on this message.'),
+ channel_id: zod.uuid().describe('Channel id.'),
+ content: zod.string().describe('Message content.'),
+ created_at: zod.iso
+ .datetime({})
+ .describe('Creation timestamp.'),
+ deleted_at: zod.iso
+ .datetime({})
+ .nullish()
+ .describe('Deletion timestamp.'),
+ edited_at: zod.iso
+ .datetime({})
+ .nullish()
+ .describe('Edit timestamp.'),
+ id: zod.uuid().describe('Message id.'),
+ reactions: zod
+ .array(
+ zod
+ .object({
+ emoji: zod.string().describe('Emoji string.'),
+ users: zod
.array(zod.string())
.describe(
- 'Message mentions formatted as `{ENTITY_TYPE}:{ENTITY_ID}`.'
+ 'User ids who added this reaction.'
),
- 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(
- 'Lightweight channel message for soup payloads.'
- )
+ .describe('A reaction with emoji and user list.')
)
- .describe(
- 'Thread replies, using the same lightweight channel message shape.'
- ),
- root_message: zod
+ .describe('Reactions on this message.'),
+ sender: zod
.object({
- content: zod.string().describe('Message content.'),
- created_at: zod.iso
- .datetime({})
- .describe('Creation timestamp.'),
- deleted_at: zod.iso
- .datetime({})
+ avatar_url: zod
+ .string()
.nullish()
- .describe('Deletion timestamp.'),
- mentions: zod
- .array(zod.string())
+ .describe('Avatar URL for bot senders.'),
+ id: zod
+ .string()
.describe(
- 'Message mentions formatted as `{ENTITY_TYPE}:{ENTITY_ID}`.'
+ 'Sender id without the storage namespace prefix.'
),
- message_id: zod.uuid().describe('Message id.'),
- sender_id: zod.string().describe('Sender id.'),
- thread_id: zod
- .uuid()
+ name: zod
+ .string()
.nullish()
- .describe('Thread parent id.'),
- updated_at: zod.iso
+ .describe('Display name for bot senders.'),
+ type: zod
+ .enum(['user', 'bot'])
+ .describe(
+ 'Public sender type for soup channel messages.'
+ ),
+ })
+ .describe(
+ 'Public sender identity for soup channel messages.'
+ ),
+ sender_id: zod.string().describe('Sender id.'),
+ thread: zod
+ .object({
+ latest_reply_at: zod.iso
.datetime({})
- .describe('Update timestamp.'),
+ .nullish()
+ .describe('Timestamp of the latest reply.'),
+ preview: zod
+ .array(
+ zod
+ .object({
+ attachments: zod
+ .array(
+ zod
+ .object({
+ created_at: zod.iso
+ .datetime({})
+ .describe('Creation timestamp.'),
+ entity_id: zod
+ .string()
+ .describe('Entity id.'),
+ entity_type: zod
+ .string()
+ .describe('Type of entity.'),
+ height: zod
+ .number()
+ .nullish()
+ .describe('Height for images.'),
+ id: zod
+ .uuid()
+ .describe('Attachment id.'),
+ width: zod
+ .number()
+ .nullish()
+ .describe('Width for images.'),
+ })
+ .describe(
+ 'An attachment on a message.'
+ )
+ )
+ .describe('Attachments on this reply.'),
+ content: zod
+ .string()
+ .describe('Reply content.'),
+ created_at: zod.iso
+ .datetime({})
+ .describe('Creation timestamp.'),
+ edited_at: zod.iso
+ .datetime({})
+ .nullish()
+ .describe('Edit timestamp.'),
+ id: zod.uuid().describe('Reply id.'),
+ reactions: zod
+ .array(
+ zod
+ .object({
+ emoji: zod
+ .string()
+ .describe('Emoji string.'),
+ users: zod
+ .array(zod.string())
+ .describe(
+ 'User ids who added this reaction.'
+ ),
+ })
+ .describe(
+ 'A reaction with emoji and user list.'
+ )
+ )
+ .describe('Reactions on this reply.'),
+ sender: zod
+ .object({
+ avatar_url: zod
+ .string()
+ .nullish()
+ .describe(
+ 'Avatar URL for bot senders.'
+ ),
+ id: zod
+ .string()
+ .describe(
+ 'Sender id without the storage namespace prefix.'
+ ),
+ name: zod
+ .string()
+ .nullish()
+ .describe(
+ 'Display name for bot senders.'
+ ),
+ type: zod
+ .enum(['user', 'bot'])
+ .describe(
+ 'Public sender type for soup channel messages.'
+ ),
+ })
+ .describe(
+ 'Public sender identity for soup channel messages.'
+ ),
+ sender_id: zod
+ .string()
+ .describe('Sender id.'),
+ updated_at: zod.iso
+ .datetime({})
+ .describe('Update timestamp.'),
+ })
+ .describe('A thread reply shown in preview.')
+ )
+ .describe('Preview replies.'),
+ reply_count: zod
+ .number()
+ .describe('Total reply count.'),
})
.describe(
- 'Lightweight channel message for soup payloads.'
+ 'Thread metadata and preview replies for soup channel messages.'
),
+ updated_at: zod.iso
+ .datetime({})
+ .describe('Update timestamp.'),
})
.describe(
- 'A top-level channel message thread for soup payloads.\n\nThis reuses the existing lightweight [`ChannelMessage`] shape used by\n[`SoupChannel`] latest-message data.'
+ 'A top-level channel message thread for soup payloads.\n\nThis mirrors the public channel-message API shape so soup consumers can\nrender a thread root the same way they render a channel timeline message.'
),
tag: zod.enum(['channelThread']),
})
@@ -15663,76 +16129,203 @@ export const postItemsSoupAstGroupedResponse = zod
.object({
data: zod
.object({
- channel_id: zod
- .uuid()
- .describe('Channel that owns the thread.'),
- messages: zod
+ attachments: zod
.array(
zod
.object({
- content: zod
- .string()
- .describe('Message content.'),
created_at: zod.iso
.datetime({})
.describe('Creation timestamp.'),
- deleted_at: zod.iso
- .datetime({})
+ entity_id: zod.string().describe('Entity id.'),
+ entity_type: zod
+ .string()
+ .describe('Type of entity.'),
+ height: zod
+ .number()
+ .nullish()
+ .describe('Height for images.'),
+ id: zod.uuid().describe('Attachment id.'),
+ width: zod
+ .number()
.nullish()
- .describe('Deletion timestamp.'),
- mentions: zod
+ .describe('Width for images.'),
+ })
+ .describe('An attachment on a message.')
+ )
+ .describe('Attachments on this message.'),
+ channel_id: zod.uuid().describe('Channel id.'),
+ content: zod.string().describe('Message content.'),
+ created_at: zod.iso
+ .datetime({})
+ .describe('Creation timestamp.'),
+ deleted_at: zod.iso
+ .datetime({})
+ .nullish()
+ .describe('Deletion timestamp.'),
+ edited_at: zod.iso
+ .datetime({})
+ .nullish()
+ .describe('Edit timestamp.'),
+ id: zod.uuid().describe('Message id.'),
+ reactions: zod
+ .array(
+ zod
+ .object({
+ emoji: zod.string().describe('Emoji string.'),
+ users: zod
.array(zod.string())
.describe(
- 'Message mentions formatted as `{ENTITY_TYPE}:{ENTITY_ID}`.'
+ 'User ids who added this reaction.'
),
- 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(
- 'Lightweight channel message for soup payloads.'
- )
+ .describe('A reaction with emoji and user list.')
)
- .describe(
- 'Thread replies, using the same lightweight channel message shape.'
- ),
- root_message: zod
+ .describe('Reactions on this message.'),
+ sender: zod
.object({
- content: zod.string().describe('Message content.'),
- created_at: zod.iso
- .datetime({})
- .describe('Creation timestamp.'),
- deleted_at: zod.iso
- .datetime({})
+ avatar_url: zod
+ .string()
.nullish()
- .describe('Deletion timestamp.'),
- mentions: zod
- .array(zod.string())
+ .describe('Avatar URL for bot senders.'),
+ id: zod
+ .string()
.describe(
- 'Message mentions formatted as `{ENTITY_TYPE}:{ENTITY_ID}`.'
+ 'Sender id without the storage namespace prefix.'
),
- message_id: zod.uuid().describe('Message id.'),
- sender_id: zod.string().describe('Sender id.'),
- thread_id: zod
- .uuid()
+ name: zod
+ .string()
.nullish()
- .describe('Thread parent id.'),
- updated_at: zod.iso
+ .describe('Display name for bot senders.'),
+ type: zod
+ .enum(['user', 'bot'])
+ .describe(
+ 'Public sender type for soup channel messages.'
+ ),
+ })
+ .describe(
+ 'Public sender identity for soup channel messages.'
+ ),
+ sender_id: zod.string().describe('Sender id.'),
+ thread: zod
+ .object({
+ latest_reply_at: zod.iso
.datetime({})
- .describe('Update timestamp.'),
+ .nullish()
+ .describe('Timestamp of the latest reply.'),
+ preview: zod
+ .array(
+ zod
+ .object({
+ attachments: zod
+ .array(
+ zod
+ .object({
+ created_at: zod.iso
+ .datetime({})
+ .describe('Creation timestamp.'),
+ entity_id: zod
+ .string()
+ .describe('Entity id.'),
+ entity_type: zod
+ .string()
+ .describe('Type of entity.'),
+ height: zod
+ .number()
+ .nullish()
+ .describe('Height for images.'),
+ id: zod
+ .uuid()
+ .describe('Attachment id.'),
+ width: zod
+ .number()
+ .nullish()
+ .describe('Width for images.'),
+ })
+ .describe(
+ 'An attachment on a message.'
+ )
+ )
+ .describe('Attachments on this reply.'),
+ content: zod
+ .string()
+ .describe('Reply content.'),
+ created_at: zod.iso
+ .datetime({})
+ .describe('Creation timestamp.'),
+ edited_at: zod.iso
+ .datetime({})
+ .nullish()
+ .describe('Edit timestamp.'),
+ id: zod.uuid().describe('Reply id.'),
+ reactions: zod
+ .array(
+ zod
+ .object({
+ emoji: zod
+ .string()
+ .describe('Emoji string.'),
+ users: zod
+ .array(zod.string())
+ .describe(
+ 'User ids who added this reaction.'
+ ),
+ })
+ .describe(
+ 'A reaction with emoji and user list.'
+ )
+ )
+ .describe('Reactions on this reply.'),
+ sender: zod
+ .object({
+ avatar_url: zod
+ .string()
+ .nullish()
+ .describe(
+ 'Avatar URL for bot senders.'
+ ),
+ id: zod
+ .string()
+ .describe(
+ 'Sender id without the storage namespace prefix.'
+ ),
+ name: zod
+ .string()
+ .nullish()
+ .describe(
+ 'Display name for bot senders.'
+ ),
+ type: zod
+ .enum(['user', 'bot'])
+ .describe(
+ 'Public sender type for soup channel messages.'
+ ),
+ })
+ .describe(
+ 'Public sender identity for soup channel messages.'
+ ),
+ sender_id: zod
+ .string()
+ .describe('Sender id.'),
+ updated_at: zod.iso
+ .datetime({})
+ .describe('Update timestamp.'),
+ })
+ .describe('A thread reply shown in preview.')
+ )
+ .describe('Preview replies.'),
+ reply_count: zod
+ .number()
+ .describe('Total reply count.'),
})
.describe(
- 'Lightweight channel message for soup payloads.'
+ 'Thread metadata and preview replies for soup channel messages.'
),
+ updated_at: zod.iso
+ .datetime({})
+ .describe('Update timestamp.'),
})
.describe(
- 'A top-level channel message thread for soup payloads.\n\nThis reuses the existing lightweight [`ChannelMessage`] shape used by\n[`SoupChannel`] latest-message data.'
+ 'A top-level channel message thread for soup payloads.\n\nThis mirrors the public channel-message API shape so soup consumers can\nrender a thread root the same way they render a channel timeline message.'
),
tag: zod.enum(['channelThread']),
})
diff --git a/js/app/packages/service-clients/service-storage/openapi.json b/js/app/packages/service-clients/service-storage/openapi.json
index 3b07e84e9d..ca8dccd423 100644
--- a/js/app/packages/service-clients/service-storage/openapi.json
+++ b/js/app/packages/service-clients/service-storage/openapi.json
@@ -17402,24 +17402,79 @@
},
"SoupChannelThread": {
"type": "object",
- "description": "A top-level channel message thread for soup payloads.\n\nThis reuses the existing lightweight [`ChannelMessage`] shape used by\n[`SoupChannel`] latest-message data.",
- "required": ["channel_id", "root_message", "messages"],
+ "description": "A top-level channel message thread for soup payloads.\n\nThis mirrors the public channel-message API shape so soup consumers can\nrender a thread root the same way they render a channel timeline message.",
+ "required": [
+ "id",
+ "channel_id",
+ "sender_id",
+ "sender",
+ "content",
+ "created_at",
+ "updated_at",
+ "thread",
+ "reactions",
+ "attachments"
+ ],
"properties": {
+ "attachments": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/SoupMessageAttachment"
+ },
+ "description": "Attachments on this message."
+ },
"channel_id": {
"type": "string",
"format": "uuid",
- "description": "Channel that owns the thread."
+ "description": "Channel id."
},
- "messages": {
+ "content": {
+ "type": "string",
+ "description": "Message content."
+ },
+ "created_at": {
+ "type": "string",
+ "format": "date-time",
+ "description": "Creation timestamp."
+ },
+ "deleted_at": {
+ "type": ["string", "null"],
+ "format": "date-time",
+ "description": "Deletion timestamp."
+ },
+ "edited_at": {
+ "type": ["string", "null"],
+ "format": "date-time",
+ "description": "Edit timestamp."
+ },
+ "id": {
+ "type": "string",
+ "format": "uuid",
+ "description": "Message id."
+ },
+ "reactions": {
"type": "array",
"items": {
- "$ref": "#/components/schemas/ChannelMessage"
+ "$ref": "#/components/schemas/SoupCountedReaction"
},
- "description": "Thread replies, using the same lightweight channel message shape."
+ "description": "Reactions on this message."
+ },
+ "sender": {
+ "$ref": "#/components/schemas/SoupMessageSender",
+ "description": "Structured sender identity."
+ },
+ "sender_id": {
+ "type": "string",
+ "description": "Sender id."
},
- "root_message": {
- "$ref": "#/components/schemas/ChannelMessage",
- "description": "Top-level message that acts as the thread parent."
+ "thread": {
+ "$ref": "#/components/schemas/SoupThreadInfo",
+ "description": "Thread metadata and preview replies."
+ },
+ "updated_at": {
+ "type": "string",
+ "format": "date-time",
+ "description": "Update timestamp."
}
}
},
@@ -17516,6 +17571,24 @@
}
}
},
+ "SoupCountedReaction": {
+ "type": "object",
+ "description": "A reaction with emoji and user list.",
+ "required": ["emoji", "users"],
+ "properties": {
+ "emoji": {
+ "type": "string",
+ "description": "Emoji string."
+ },
+ "users": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "description": "User ids who added this reaction."
+ }
+ }
+ },
"SoupCrmCompany": {
"type": "object",
"description": "A CRM company as displayed in Soup. Carries the core company\nfields plus display metadata resolved from `crm_domain_directory`\nagainst the primary (earliest-created) domain.",
@@ -18120,11 +18193,74 @@
"description": "Whether an email label is provider-created or user-created.",
"enum": ["system", "user"]
},
+ "SoupMessageAttachment": {
+ "type": "object",
+ "description": "An attachment on a message.",
+ "required": ["id", "entity_type", "entity_id", "created_at"],
+ "properties": {
+ "created_at": {
+ "type": "string",
+ "format": "date-time",
+ "description": "Creation timestamp."
+ },
+ "entity_id": {
+ "type": "string",
+ "description": "Entity id."
+ },
+ "entity_type": {
+ "type": "string",
+ "description": "Type of entity."
+ },
+ "height": {
+ "type": ["integer", "null"],
+ "format": "int32",
+ "description": "Height for images."
+ },
+ "id": {
+ "type": "string",
+ "format": "uuid",
+ "description": "Attachment id."
+ },
+ "width": {
+ "type": ["integer", "null"],
+ "format": "int32",
+ "description": "Width for images."
+ }
+ }
+ },
"SoupMessageListVisibility": {
"type": "string",
"description": "Gmail-style message list visibility for a label.",
"enum": ["show", "hide"]
},
+ "SoupMessageSender": {
+ "type": "object",
+ "description": "Public sender identity for soup channel messages.",
+ "required": ["type", "id"],
+ "properties": {
+ "avatar_url": {
+ "type": ["string", "null"],
+ "description": "Avatar URL for bot senders."
+ },
+ "id": {
+ "type": "string",
+ "description": "Sender id without the storage namespace prefix."
+ },
+ "name": {
+ "type": ["string", "null"],
+ "description": "Display name for bot senders."
+ },
+ "type": {
+ "$ref": "#/components/schemas/SoupMessageSenderType",
+ "description": "Sender type."
+ }
+ }
+ },
+ "SoupMessageSenderType": {
+ "type": "string",
+ "description": "Public sender type for soup channel messages.",
+ "enum": ["user", "bot"]
+ },
"SoupPage": {
"type": "object",
"description": "Response page for non-grouped soup endpoints.",
@@ -18222,6 +18358,92 @@
}
}
},
+ "SoupThreadInfo": {
+ "type": "object",
+ "description": "Thread metadata and preview replies for soup channel messages.",
+ "required": ["reply_count", "preview"],
+ "properties": {
+ "latest_reply_at": {
+ "type": ["string", "null"],
+ "format": "date-time",
+ "description": "Timestamp of the latest reply."
+ },
+ "preview": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/SoupThreadReply"
+ },
+ "description": "Preview replies."
+ },
+ "reply_count": {
+ "type": "integer",
+ "format": "int64",
+ "description": "Total reply count."
+ }
+ }
+ },
+ "SoupThreadReply": {
+ "type": "object",
+ "description": "A thread reply shown in preview.",
+ "required": [
+ "id",
+ "sender_id",
+ "sender",
+ "content",
+ "created_at",
+ "updated_at",
+ "reactions",
+ "attachments"
+ ],
+ "properties": {
+ "attachments": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/SoupMessageAttachment"
+ },
+ "description": "Attachments on this reply."
+ },
+ "content": {
+ "type": "string",
+ "description": "Reply content."
+ },
+ "created_at": {
+ "type": "string",
+ "format": "date-time",
+ "description": "Creation timestamp."
+ },
+ "edited_at": {
+ "type": ["string", "null"],
+ "format": "date-time",
+ "description": "Edit timestamp."
+ },
+ "id": {
+ "type": "string",
+ "format": "uuid",
+ "description": "Reply id."
+ },
+ "reactions": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/SoupCountedReaction"
+ },
+ "description": "Reactions on this reply."
+ },
+ "sender": {
+ "$ref": "#/components/schemas/SoupMessageSender",
+ "description": "Structured sender identity."
+ },
+ "sender_id": {
+ "type": "string",
+ "description": "Sender id."
+ },
+ "updated_at": {
+ "type": "string",
+ "format": "date-time",
+ "description": "Update timestamp."
+ }
+ }
+ },
"SuccessResponse": {
"type": "object",
"required": ["error", "data"],
diff --git a/rust/cloud-storage/channels/src/domain/list_service.rs b/rust/cloud-storage/channels/src/domain/list_service.rs
index da5df22504..9dc014995b 100644
--- a/rust/cloud-storage/channels/src/domain/list_service.rs
+++ b/rust/cloud-storage/channels/src/domain/list_service.rs
@@ -9,7 +9,7 @@ use uuid::Uuid;
use crate::domain::{
models::{
- Activity, ChannelThreadReplyRows, ChannelType, ChannelWithLatest, GetChannelsRequest,
+ Activity, ChannelMessage, ChannelType, ChannelWithLatest, GetChannelsRequest,
GetThreadReplyRowsRequest, NameLookup, UserName, fallback_user_name,
},
ports::{ChannelListRepo, ChannelListService, ChannelListUserRepo},
@@ -150,11 +150,11 @@ where
self.channels.get_channel_list_activities(user)
}
- fn get_thread_reply_rows(
+ fn get_thread_messages(
&self,
req: GetThreadReplyRowsRequest,
- ) -> impl Future<Output = Result<Vec<ChannelThreadReplyRows>, rootcause::Report>> + Send {
- self.channels.get_thread_reply_rows(req.into_params())
+ ) -> impl Future<Output = Result<Vec<ChannelMessage>, rootcause::Report>> + Send {
+ self.channels.get_thread_messages(req.into_params())
}
fn get_names(
diff --git a/rust/cloud-storage/channels/src/domain/models.rs b/rust/cloud-storage/channels/src/domain/models.rs
index fb537fb2b4..fe644dfe7e 100644
--- a/rust/cloud-storage/channels/src/domain/models.rs
+++ b/rust/cloud-storage/channels/src/domain/models.rs
@@ -217,7 +217,7 @@ pub enum MessagePageDirection {
}
/// A top-level message with thread info, reactions, and attachments.
-#[derive(Debug)]
+#[derive(Debug, Clone)]
pub struct ChannelMessage {
/// Message id.
pub id: Uuid,
@@ -284,7 +284,7 @@ impl SortOn<CreatedAt> for ChannelMessage {
}
/// Thread metadata + preview replies for a top-level message.
-#[derive(Debug)]
+#[derive(Debug, Clone)]
pub struct ThreadInfo {
/// Total number of replies in the thread.
pub reply_count: i64,
@@ -1246,16 +1246,6 @@ impl GetThreadReplyRowsParams {
}
}
-/// A top-level channel message plus all reply rows for Soup thread rendering.
-#[cfg(feature = "list")]
-#[derive(Debug, Clone)]
-pub struct ChannelThreadReplyRows {
- /// Top-level parent message for the thread.
- pub parent: TopLevelMessageRow,
- /// Non-deleted replies in oldest-first order.
- pub replies: Vec<ThreadReplyRow>,
-}
-
#[cfg(feature = "list")]
impl GetChannelsParams {
/// Requesting user id.
diff --git a/rust/cloud-storage/channels/src/domain/ports.rs b/rust/cloud-storage/channels/src/domain/ports.rs
index 5215934c91..41432159c6 100644
--- a/rust/cloud-storage/channels/src/domain/ports.rs
+++ b/rust/cloud-storage/channels/src/domain/ports.rs
@@ -15,7 +15,7 @@ use crate::domain::models::{
};
#[cfg(feature = "list")]
use crate::domain::models::{
- ChannelThreadReplyRows, ChannelWithLatest, ChannelWithParticipants, GetChannelsParams,
+ ChannelMessage, ChannelWithLatest, ChannelWithParticipants, GetChannelsParams,
GetChannelsRequest, GetThreadReplyRowsParams, GetThreadReplyRowsRequest, LatestMessage,
UserName,
};
@@ -50,11 +50,11 @@ pub trait ChannelListRepo: Send + Sync + 'static {
user_id: MacroUserIdStr<'_>,
) -> impl Future<Output = Result<Vec<Activity>, rootcause::Report>> + Send;
- /// Fetch top-level channel message rows and their reply rows for Soup thread rendering.
- fn get_thread_reply_rows(
+ /// Fetch top-level channel messages for Soup thread rendering.
+ fn get_thread_messages(
&self,
req: GetThreadReplyRowsParams,
- ) -> impl Future<Output = Result<Vec<ChannelThreadReplyRows>, rootcause::Report>> + Send;
+ ) -> impl Future<Output = Result<Vec<ChannelMessage>, rootcause::Report>> + Send;
}
/// Repository for user display names needed by channel list rendering.
@@ -82,11 +82,11 @@ pub trait ChannelListService: Send + Sync + 'static {
user: MacroUserIdStr<'_>,
) -> impl Future<Output = Result<Vec<Activity>, rootcause::Report>> + Send;
- /// Fetch top-level channel message rows and their reply rows for Soup thread rendering.
- fn get_thread_reply_rows(
+ /// Fetch top-level channel messages for Soup thread rendering.
+ fn get_thread_messages(
&self,
req: GetThreadReplyRowsRequest,
- ) -> impl Future<Output = Result<Vec<ChannelThreadReplyRows>, rootcause::Report>> + Send;
+ ) -> impl Future<Output = Result<Vec<ChannelMessage>, rootcause::Report>> + Send;
/// Fetch names for user ids.
fn get_names(
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 ea62a195da..84be1b5055 100644
--- a/rust/cloud-storage/channels/src/outbound/pg_channels_repo.rs
+++ b/rust/cloud-storage/channels/src/outbound/pg_channels_repo.rs
@@ -9,14 +9,14 @@ use crate::domain::{
models::{
Activity, ActivityType, AttachmentChannelReference, AttachmentEntityReference,
AttachmentGenericReference, BotId, BotSenderProfile, ChannelAttachment,
- ChannelAttachmentType, ChannelContextMessage, ChannelInfo, ChannelListItem,
+ ChannelAttachmentType, ChannelContextMessage, ChannelInfo, ChannelListItem, ChannelMessage,
ChannelMessageFilters, ChannelMessageKind, ChannelMetadata, ChannelParticipant,
- ChannelPreviewRow, ChannelThreadReplyRows, ChannelType, ChannelWithParticipants,
- CountedReaction, CreateChannelRequest, CreateEntityMentionOptions, EntityMention,
- GetChannelsParams, GetThreadReplyRowsParams, LatestMessage, MessageAttachment,
- MessagePageDirection, MutatedAttachment, MutatedMessage, NameLookup, NewChannelAttachment,
- ParticipantRole, PatchChannelRequest, RecentChannelMessage, ResolvedChannelMessage, Sender,
- SimpleMention, ThreadData, ThreadReplyRow, TopLevelMessageRow, UserName,
+ ChannelPreviewRow, ChannelType, ChannelWithParticipants, CountedReaction,
+ CreateChannelRequest, CreateEntityMentionOptions, EntityMention, GetChannelsParams,
+ GetThreadReplyRowsParams, LatestMessage, MessageAttachment, MessagePageDirection,
+ MutatedAttachment, MutatedMessage, NameLookup, NewChannelAttachment, ParticipantRole,
+ PatchChannelRequest, RecentChannelMessage, ResolvedChannelMessage, Sender, SimpleMention,
+ ThreadData, ThreadInfo, ThreadReply, ThreadReplyRow, TopLevelMessageRow, UserName,
fallback_user_name,
},
ports::{ChannelRepo, TopLevelMessagesQueryResult},
@@ -53,6 +53,15 @@ impl PgChannelsRepo {
}
}
+#[cfg(feature = "list")]
+fn bot_profile_for_sender(
+ profiles: &HashMap<BotId, BotSenderProfile>,
+ sender_id: &str,
+) -> Option<BotSenderProfile> {
+ let bot_id = BotId::parse_storage_str(sender_id).ok()?;
+ profiles.get(&bot_id).cloned()
+}
+
/// Intermediate row for the top-level messages query.
#[derive(Debug, sqlx::FromRow)]
struct TopLevelRow {
@@ -1235,10 +1244,10 @@ impl ChannelListRepo for PgChannelsRepo {
.await?)
}
- async fn get_thread_reply_rows(
+ async fn get_thread_messages(
&self,
params: GetThreadReplyRowsParams,
- ) -> Result<Vec<ChannelThreadReplyRows>, rootcause::Report> {
+ ) -> Result<Vec<ChannelMessage>, rootcause::Report> {
let parents: Vec<TopLevelMessageRow> = build_channel_thread_rows_query(&params)
.build()
.try_map(|row: PgRow| {
@@ -1261,54 +1270,87 @@ impl ChannelListRepo for PgChannelsRepo {
return Ok(Vec::new());
}
- // QueryBuilder keeps this batch fetch independent from SQLx's offline macro cache;
- // all parent ids are still passed as a single bind parameter.
- let mut reply_query = QueryBuilder::new(
- r#"
- SELECT
- id,
- thread_id,
- sender_id,
- content,
- created_at,
- updated_at,
- edited_at::timestamptz AS edited_at
- FROM comms_messages
- WHERE thread_id = ANY("#,
- );
- reply_query.push_bind(parent_ids.clone());
- reply_query.push(
- r#")
- AND deleted_at IS NULL
- ORDER BY thread_id ASC, created_at ASC, id ASC
- "#,
- );
- let reply_rows = reply_query
- .build_query_as::<ThreadReplyOnlyRow>()
- .fetch_all(&self.pool)
- .await?;
+ let thread_data = self
+ .get_thread_data(&parent_ids, 3)
+ .await
+ .map_err(|error| rootcause::report!(error))?;
- let mut replies_by_parent: HashMap<Uuid, Vec<ThreadReplyRow>> = HashMap::new();
- for row in reply_rows {
- replies_by_parent
- .entry(row.thread_id)
- .or_default()
- .push(ThreadReplyRow {
- id: row.id,
- thread_id: row.thread_id,
- sender_id: row.sender_id,
- content: row.content,
- created_at: row.created_at,
- updated_at: row.updated_at,
- edited_at: row.edited_at,
- });
+ let mut all_ids = parent_ids.clone();
+ let mut sender_ids: Vec<&str> = parents
+ .iter()
+ .map(|parent| parent.sender_id.as_str())
+ .collect();
+ for data in thread_data.values() {
+ for reply in &data.preview_replies {
+ all_ids.push(reply.id);
+ sender_ids.push(reply.sender_id.as_str());
+ }
}
+ let bot_ids: Vec<BotId> = sender_ids
+ .into_iter()
+ .filter_map(|sender_id| BotId::parse_storage_str(sender_id).ok())
+ .collect::<HashSet<_>>()
+ .into_iter()
+ .collect();
+
+ let (reactions, attachments, bot_profiles) = tokio::join!(
+ self.get_reactions_batch(&all_ids),
+ self.get_attachments_batch(&all_ids),
+ self.get_bot_profiles(&bot_ids),
+ );
+
+ let reactions = reactions.map_err(|error| rootcause::report!(error))?;
+ let attachments = attachments.map_err(|error| rootcause::report!(error))?;
+ let bot_profiles = bot_profiles.map_err(|error| rootcause::report!(error))?;
+
Ok(parents
.into_iter()
.map(|parent| {
- let replies = replies_by_parent.remove(&parent.id).unwrap_or_default();
- ChannelThreadReplyRows { parent, replies }
+ let data = thread_data.get(&parent.id);
+ let preview = data
+ .map(|data| {
+ data.preview_replies
+ .iter()
+ .map(|reply| ThreadReply {
+ id: reply.id,
+ sender_id: reply.sender_id.clone(),
+ bot_profile: bot_profile_for_sender(
+ &bot_profiles,
+ &reply.sender_id,
+ ),
+ content: reply.content.clone(),
+ created_at: reply.created_at,
+ updated_at: reply.updated_at,
+ edited_at: reply.edited_at,
+ reactions: reactions.get(&reply.id).cloned().unwrap_or_default(),
+ attachments: attachments
+ .get(&reply.id)
+ .cloned()
+ .unwrap_or_default(),
+ })
+ .collect()
+ })
+ .unwrap_or_default();
+
+ ChannelMessage {
+ id: parent.id,
+ channel_id: parent.channel_id,
+ sender_id: parent.sender_id.clone(),
+ bot_profile: bot_profile_for_sender(&bot_profiles, &parent.sender_id),
+ content: parent.content,
+ created_at: parent.created_at,
+ updated_at: parent.updated_at,
+ edited_at: parent.edited_at,
+ deleted_at: parent.deleted_at,
+ thread: ThreadInfo {
+ reply_count: data.map_or(0, |data| data.reply_count),
+ latest_reply_at: data.and_then(|data| data.latest_reply_at),
+ preview,
+ },
+ reactions: reactions.get(&parent.id).cloned().unwrap_or_default(),
+ attachments: attachments.get(&parent.id).cloned().unwrap_or_default(),
+ }
})
.collect())
}
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 63aebc876e..9c92ade9e3 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
@@ -35,8 +35,7 @@ const MSG31: Uuid = Uuid::from_u128(0x00000000_0000_0000_0000_000000000031);
const REPLY1: Uuid = Uuid::from_u128(0x00000000_0000_0000_0000_00000000b001);
const REPLY2: Uuid = Uuid::from_u128(0x00000000_0000_0000_0000_00000000b002);
const REPLY3: Uuid = Uuid::from_u128(0x00000000_0000_0000_0000_00000000b003);
-const REPLY4: Uuid = Uuid::from_u128(0x00000000_0000_0000_0000_00000000b004);
-const REPLY5: Uuid = Uuid::from_u128(0x00000000_0000_0000_0000_00000000b005);
+const REPLY4: Uuid = Uuid::from_u128(0x00000000_0000_0000_0000_00000000b005);
const DELETED_MSG_ATTACHMENT: Uuid = Uuid::from_u128(0x00000000_0000_0000_0000_00000000a004);
const USER_A: &str = "macro|[email protected]";
const USER_B: &str = "macro|[email protected]";
@@ -245,25 +244,27 @@ async fn channel_thread_rows_are_visible_to_channel_members(
) -> anyhow::Result<()> {
let repo = repo(pool);
let rows = repo
- .get_thread_reply_rows(
+ .get_thread_messages(
thread_rows_request(USER_A, None, SimpleSortMethod::UpdatedAt, 50).into_params(),
)
.await
.map_err(report_err)?;
- let parent_ids = rows.iter().map(|row| row.parent.id).collect::<Vec<_>>();
+ let parent_ids = rows.iter().map(|row| row.id).collect::<Vec<_>>();
assert_eq!(parent_ids, vec![MSG3, MSG1, MSG31]);
let msg1 = rows
.iter()
- .find(|row| row.parent.id == MSG1)
+ .find(|row| row.id == MSG1)
.expect("msg1 thread should be returned");
+ assert_eq!(msg1.thread.reply_count, 4);
let reply_ids = msg1
- .replies
+ .thread
+ .preview
.iter()
.map(|reply| reply.id)
.collect::<Vec<_>>();
- assert_eq!(reply_ids, vec![REPLY1, REPLY2, REPLY3, REPLY4]);
+ assert_eq!(reply_ids, vec![REPLY1, REPLY2, REPLY3]);
Ok(())
}
@@ -276,7 +277,7 @@ async fn channel_thread_rows_are_scoped_to_active_channel_members(
) -> anyhow::Result<()> {
let repo = repo(pool);
let rows = repo
- .get_thread_reply_rows(
+ .get_thread_messages(
thread_rows_request(NON_MEMBER, None, SimpleSortMethod::UpdatedAt, 50).into_params(),
)
.await
@@ -293,7 +294,7 @@ async fn channel_thread_rows_are_scoped_to_active_channel_members(
async fn channel_thread_rows_filter_by_thread_id(pool: Pool<Postgres>) -> anyhow::Result<()> {
let repo = repo(pool);
let rows = repo
- .get_thread_reply_rows(
+ .get_thread_messages(
thread_rows_request(
USER_A,
thread_filter(ChannelThreadLiteral::ThreadId(MSG1)),
@@ -306,13 +307,15 @@ async fn channel_thread_rows_filter_by_thread_id(pool: Pool<Postgres>) -> anyhow
.map_err(report_err)?;
assert_eq!(rows.len(), 1);
- assert_eq!(rows[0].parent.id, MSG1);
+ assert_eq!(rows[0].id, MSG1);
+ assert_eq!(rows[0].thread.reply_count, 4);
let reply_ids = rows[0]
- .replies
+ .thread
+ .preview
.iter()
.map(|reply| reply.id)
.collect::<Vec<_>>();
- assert_eq!(reply_ids, vec![REPLY1, REPLY2, REPLY3, REPLY4]);
+ assert_eq!(reply_ids, vec![REPLY1, REPLY2, REPLY3]);
Ok(())
}
@@ -323,7 +326,7 @@ async fn channel_thread_rows_filter_by_thread_id(pool: Pool<Postgres>) -> anyhow
async fn channel_thread_rows_filter_by_channel_id(pool: Pool<Postgres>) -> anyhow::Result<()> {
let repo = repo(pool);
let rows = repo
- .get_thread_reply_rows(
+ .get_thread_messages(
thread_rows_request(
USER_A,
thread_filter(ChannelThreadLiteral::ChannelId(CH2)),
@@ -346,7 +349,7 @@ async fn channel_thread_rows_filter_by_channel_id(pool: Pool<Postgres>) -> anyho
async fn channel_thread_rows_filter_by_root_sender(pool: Pool<Postgres>) -> anyhow::Result<()> {
let repo = repo(pool);
let rows = repo
- .get_thread_reply_rows(
+ .get_thread_messages(
thread_rows_request(
USER_A,
thread_filter(ChannelThreadLiteral::RootSender(macro_user_id(USER_A))),
@@ -358,7 +361,7 @@ async fn channel_thread_rows_filter_by_root_sender(pool: Pool<Postgres>) -> anyh
.await
.map_err(report_err)?;
- let parent_ids = rows.iter().map(|row| row.parent.id).collect::<Vec<_>>();
+ let parent_ids = rows.iter().map(|row| row.id).collect::<Vec<_>>();
assert_eq!(parent_ids, vec![MSG3, MSG1, MSG31]);
Ok(())
}
@@ -376,7 +379,7 @@ async fn channel_thread_rows_filter_by_notification_done_secondary_entity(
insert_channel_thread_notification(&pool, USER_B, CH1, MSG3, true, false).await?;
let rows = repo(pool)
- .get_thread_reply_rows(
+ .get_thread_messages(
thread_rows_request(
USER_A,
thread_filter(ChannelThreadLiteral::NotificationDone(true)),
@@ -388,7 +391,7 @@ async fn channel_thread_rows_filter_by_notification_done_secondary_entity(
.await
.map_err(report_err)?;
- let parent_ids = rows.iter().map(|row| row.parent.id).collect::<Vec<_>>();
+ let parent_ids = rows.iter().map(|row| row.id).collect::<Vec<_>>();
assert_eq!(parent_ids, vec![MSG1]);
Ok(())
}
@@ -405,7 +408,7 @@ async fn channel_thread_rows_filter_by_notification_seen_secondary_entity(
insert_channel_thread_notification(&pool, USER_A, CH1, MSG31, false, false).await?;
let rows = repo(pool)
- .get_thread_reply_rows(
+ .get_thread_messages(
thread_rows_request(
USER_A,
thread_filter(ChannelThreadLiteral::NotificationSeen(true)),
@@ -417,7 +420,7 @@ async fn channel_thread_rows_filter_by_notification_seen_secondary_entity(
.await
.map_err(report_err)?;
- let parent_ids = rows.iter().map(|row| row.parent.id).collect::<Vec<_>>();
+ let parent_ids = rows.iter().map(|row| row.id).collect::<Vec<_>>();
assert_eq!(parent_ids, vec![MSG1]);
Ok(())
}
@@ -429,25 +432,25 @@ async fn channel_thread_rows_filter_by_notification_seen_secondary_entity(
async fn channel_thread_rows_apply_cursor(pool: Pool<Postgres>) -> anyhow::Result<()> {
let repo = repo(pool);
let first_page = repo
- .get_thread_reply_rows(
+ .get_thread_messages(
thread_rows_request(USER_A, None, SimpleSortMethod::UpdatedAt, 1).into_params(),
)
.await
.map_err(report_err)?;
assert_eq!(first_page.len(), 1);
- assert_eq!(first_page[0].parent.id, MSG3);
+ assert_eq!(first_page[0].id, MSG3);
let second_page = repo
- .get_thread_reply_rows(
+ .get_thread_messages(
GetThreadReplyRowsRequest {
macro_id: macro_user_id(USER_A),
limit: Some(50),
query: Query::Cursor(Cursor {
- id: first_page[0].parent.id,
+ id: first_page[0].id,
limit: 50,
val: CursorVal {
sort_type: SimpleSortMethod::UpdatedAt,
- last_val: first_page[0].parent.updated_at,
+ last_val: first_page[0].updated_at,
},
filter: None,
}),
@@ -457,10 +460,7 @@ async fn channel_thread_rows_apply_cursor(pool: Pool<Postgres>) -> anyhow::Resul
.await
.map_err(report_err)?;
- let parent_ids = second_page
- .iter()
- .map(|row| row.parent.id)
- .collect::<Vec<_>>();
+ let parent_ids = second_page.iter().map(|row| row.id).collect::<Vec<_>>();
assert_eq!(parent_ids, vec![MSG1, MSG31]);
Ok(())
}
@@ -827,7 +827,7 @@ async fn thread_replies_excludes_deleted_rows(pool: Pool<Postgres>) -> anyhow::R
let active_replies = repo.get_thread_replies(MSG2).await?;
assert_eq!(active_replies.len(), 1);
- assert_eq!(active_replies[0].id, REPLY5);
+ assert_eq!(active_replies[0].id, REPLY4);
assert_eq!(active_replies[0].content, "reply to deleted");
Ok(())
}
@@ -1062,7 +1062,7 @@ async fn resolve_top_level_parent_follows_reply_to_deleted_parent(
) -> anyhow::Result<()> {
let repo = repo(pool);
// REPLY5 (b005) is a reply to MSG2 (which is soft-deleted but has active reply)
- let row = repo.resolve_top_level_parent(CH1, REPLY5).await?;
+ let row = repo.resolve_top_level_parent(CH1, REPLY4).await?;
let row = row.expect("reply to deleted parent should still resolve");
assert_eq!(row.id, MSG2);
@@ -1351,7 +1351,7 @@ async fn notification_seen_filter_matches_top_level_messages_and_thread_replies(
) -> anyhow::Result<()> {
insert_channel_message_notification(&pool, USER_A, CH1, MSG3, false, true).await?;
insert_channel_message_notification(&pool, USER_A, CH1, REPLY1, false, true).await?;
- insert_channel_message_notification(&pool, USER_A, CH1, REPLY5, false, true).await?;
+ insert_channel_message_notification(&pool, USER_A, CH1, REPLY4, false, true).await?;
let filters = ChannelMessageFilters {
notification_filters: NotificationFilters {
diff --git a/rust/cloud-storage/models_soup/src/comms.rs b/rust/cloud-storage/models_soup/src/comms.rs
index 32acff76b9..5cd1546be3 100644
--- a/rust/cloud-storage/models_soup/src/comms.rs
+++ b/rust/cloud-storage/models_soup/src/comms.rs
@@ -119,29 +119,136 @@ pub struct SoupChannel {
/// A top-level channel message thread for soup payloads.
///
-/// This reuses the existing lightweight [`ChannelMessage`] shape used by
-/// [`SoupChannel`] latest-message data.
+/// This mirrors the public channel-message API shape so soup consumers can
+/// render a thread root the same way they render a channel timeline message.
#[derive(Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schema", derive(utoipa::ToSchema))]
pub struct SoupChannelThread {
- /// Channel that owns the thread.
- #[cfg_attr(feature = "schema", schema(value_type = Uuid))]
- pub channel_id: ChannelId,
- /// Top-level message that acts as the thread parent.
- pub root_message: ChannelMessage,
- /// Thread replies, using the same lightweight channel message shape.
- pub messages: Vec<ChannelMessage>,
+ /// Message id.
+ pub id: Uuid,
+ /// Channel id.
+ pub channel_id: Uuid,
+ /// Sender id.
+ pub sender_id: String,
+ /// Structured sender identity.
+ pub sender: SoupMessageSender,
+ /// Message content.
+ pub content: String,
+ /// Creation timestamp.
+ pub created_at: chrono::DateTime<chrono::Utc>,
+ /// Update timestamp.
+ pub updated_at: chrono::DateTime<chrono::Utc>,
+ /// Edit timestamp.
+ pub edited_at: Option<chrono::DateTime<chrono::Utc>>,
+ /// Deletion timestamp.
+ pub deleted_at: Option<chrono::DateTime<chrono::Utc>>,
+ /// Thread metadata and preview replies.
+ pub thread: SoupThreadInfo,
+ /// Reactions on this message.
+ pub reactions: Vec<SoupCountedReaction>,
+ /// Attachments on this message.
+ pub attachments: Vec<SoupMessageAttachment>,
+}
+
+/// Public sender identity for soup channel messages.
+#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
+#[cfg_attr(feature = "schema", derive(utoipa::ToSchema))]
+pub struct SoupMessageSender {
+ /// Sender type.
+ #[serde(rename = "type")]
+ pub sender_type: SoupMessageSenderType,
+ /// Sender id without the storage namespace prefix.
+ pub id: String,
+ /// Display name for bot senders.
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub name: Option<String>,
+ /// Avatar URL for bot senders.
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub avatar_url: Option<String>,
+}
+
+/// Public sender type for soup channel messages.
+#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
+#[serde(rename_all = "snake_case")]
+#[cfg_attr(feature = "schema", derive(utoipa::ToSchema))]
+pub enum SoupMessageSenderType {
+ /// Macro user sender.
+ User,
+ /// Bot sender.
+ Bot,
+}
+
+/// Thread metadata and preview replies for soup channel messages.
+#[derive(Debug, Clone, Serialize, Deserialize)]
+#[cfg_attr(feature = "schema", derive(utoipa::ToSchema))]
+pub struct SoupThreadInfo {
+ /// Total reply count.
+ pub reply_count: i64,
+ /// Timestamp of the latest reply.
+ pub latest_reply_at: Option<chrono::DateTime<chrono::Utc>>,
+ /// Preview replies.
+ pub preview: Vec<SoupThreadReply>,
+}
+
+/// A thread reply shown in preview.
+#[derive(Debug, Clone, Serialize, Deserialize)]
+#[cfg_attr(feature = "schema", derive(utoipa::ToSchema))]
+pub struct SoupThreadReply {
+ /// Reply id.
+ pub id: Uuid,
+ /// Sender id.
+ pub sender_id: String,
+ /// Structured sender identity.
+ pub sender: SoupMessageSender,
+ /// Reply content.
+ pub content: String,
+ /// Creation timestamp.
+ pub created_at: chrono::DateTime<chrono::Utc>,
+ /// Update timestamp.
+ pub updated_at: chrono::DateTime<chrono::Utc>,
+ /// Edit timestamp.
+ pub edited_at: Option<chrono::DateTime<chrono::Utc>>,
+ /// Reactions on this reply.
+ pub reactions: Vec<SoupCountedReaction>,
+ /// Attachments on this reply.
+ pub attachments: Vec<SoupMessageAttachment>,
+}
+
+/// A reaction with emoji and user list.
+#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
+#[cfg_attr(feature = "schema", derive(utoipa::ToSchema))]
+pub struct SoupCountedReaction {
+ /// Emoji string.
+ pub emoji: String,
+ /// User ids who added this reaction.
+ pub users: Vec<String>,
+}
+
+/// An attachment on a message.
+#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
+#[cfg_attr(feature = "schema", derive(utoipa::ToSchema))]
+pub struct SoupMessageAttachment {
+ /// Attachment id.
+ pub id: Uuid,
+ /// Type of entity.
+ pub entity_type: String,
+ /// Entity id.
+ pub entity_id: String,
+ /// Width for images.
+ pub width: Option<i32>,
+ /// Height for images.
+ pub height: Option<i32>,
+ /// Creation timestamp.
+ pub created_at: chrono::DateTime<chrono::Utc>,
}
impl SoupChannelThread {
- /// Latest update timestamp across the parent message and replies.
- pub fn updated_at(&self) -> chrono::DateTime<chrono::Utc> {
- self.messages
- .iter()
- .map(|message| message.updated_at)
- .max()
- .unwrap_or(self.root_message.updated_at)
- .max(self.root_message.updated_at)
+ /// Latest update timestamp across the parent message and thread metadata.
+ pub fn effective_updated_at(&self) -> chrono::DateTime<chrono::Utc> {
+ self.thread
+ .latest_reply_at
+ .unwrap_or(self.updated_at)
+ .max(self.updated_at)
}
}
@@ -351,71 +458,109 @@ impl SoupChannel {
}
}
-impl SoupChannelThread {
- /// Converts a channels-domain channel message with preview replies into a Soup thread.
- pub fn new_from_channel_message(message: channels::domain::models::ChannelMessage) -> Self {
- let channels::domain::models::ChannelMessage {
- id,
- channel_id,
- sender_id,
- content,
- created_at,
- updated_at,
- deleted_at,
- thread,
- ..
- } = message;
- let messages = thread
- .preview
- .into_iter()
- .map(|reply| ChannelMessage::new_from_thread_reply(id, reply))
- .collect();
-
- Self {
- channel_id: ChannelId(channel_id),
- root_message: ChannelMessage {
- message_id: id,
- thread_id: None,
- sender_id,
- content,
- created_at,
- updated_at,
- deleted_at,
- mentions: Vec::new(),
+impl SoupMessageSender {
+ fn from_storage_string(sender_id: &str) -> Self {
+ match channels::domain::models::Sender::parse_storage_str(sender_id) {
+ Ok(channels::domain::models::Sender::Bot(bot_id)) => Self {
+ sender_type: SoupMessageSenderType::Bot,
+ id: bot_id.as_uuid().to_string(),
+ name: None,
+ avatar_url: None,
+ },
+ Ok(channels::domain::models::Sender::User(user_id)) => Self {
+ sender_type: SoupMessageSenderType::User,
+ id: user_id.to_string(),
+ name: None,
+ avatar_url: None,
+ },
+ Err(_) => Self {
+ sender_type: SoupMessageSenderType::User,
+ id: sender_id.to_string(),
+ name: None,
+ avatar_url: None,
},
- messages,
}
}
- /// Converts a channels-domain channel message and replies into a Soup thread.
- pub fn new_from_channel_message_and_replies(
- message: channels::domain::models::ChannelMessage,
- replies: Vec<channels::domain::models::ThreadReply>,
+ fn from_message_sender(
+ sender_id: &str,
+ bot_profile: Option<channels::domain::models::BotSenderProfile>,
) -> Self {
- let parent_id = message.id;
+ let mut sender = Self::from_storage_string(sender_id);
+ if matches!(sender.sender_type, SoupMessageSenderType::Bot)
+ && let Some(profile) = bot_profile
+ {
+ sender.name = Some(profile.name);
+ sender.avatar_url = profile.avatar_url;
+ }
+ sender
+ }
+}
+
+impl From<channels::domain::models::CountedReaction> for SoupCountedReaction {
+ fn from(reaction: channels::domain::models::CountedReaction) -> Self {
Self {
- channel_id: ChannelId(message.channel_id),
- root_message: ChannelMessage::new_from_channel_message(message),
- messages: replies
- .into_iter()
- .map(|reply| ChannelMessage::new_from_thread_reply(parent_id, reply))
- .collect(),
+ emoji: reaction.emoji,
+ users: reaction.users,
}
}
+}
- /// Converts raw channels-domain parent/reply rows into a Soup thread.
- pub fn new_from_thread_reply_rows(
- rows: channels::domain::models::ChannelThreadReplyRows,
- ) -> Self {
- let channel_id = rows.parent.channel_id;
+impl From<channels::domain::models::MessageAttachment> for SoupMessageAttachment {
+ fn from(attachment: channels::domain::models::MessageAttachment) -> Self {
Self {
- channel_id: ChannelId(channel_id),
- root_message: ChannelMessage::new_from_top_level_message_row(rows.parent),
- messages: rows
- .replies
- .into_iter()
- .map(ChannelMessage::new_from_thread_reply_row)
- .collect(),
+ id: attachment.id,
+ entity_type: attachment.entity_type,
+ entity_id: attachment.entity_id,
+ width: attachment.width,
+ height: attachment.height,
+ created_at: attachment.created_at,
+ }
+ }
+}
+
+impl From<channels::domain::models::ThreadReply> for SoupThreadReply {
+ fn from(reply: channels::domain::models::ThreadReply) -> Self {
+ Self {
+ id: reply.id,
+ sender: SoupMessageSender::from_message_sender(&reply.sender_id, reply.bot_profile),
+ sender_id: reply.sender_id,
+ content: reply.content,
+ created_at: reply.created_at,
+ updated_at: reply.updated_at,
+ edited_at: reply.edited_at,
+ reactions: reply.reactions.into_iter().map(Into::into).collect(),
+ attachments: reply.attachments.into_iter().map(Into::into).collect(),
+ }
+ }
+}
+
+impl From<channels::domain::models::ThreadInfo> for SoupThreadInfo {
+ fn from(thread: channels::domain::models::ThreadInfo) -> Self {
+ Self {
+ reply_count: thread.reply_count,
+ latest_reply_at: thread.latest_reply_at,
+ preview: thread.preview.into_iter().map(Into::into).collect(),
+ }
+ }
+}
+
+impl SoupChannelThread {
+ /// Converts a channels-domain channel message into a Soup thread root.
+ pub fn new_from_channel_message(message: channels::domain::models::ChannelMessage) -> Self {
+ Self {
+ id: message.id,
+ channel_id: message.channel_id,
+ sender: SoupMessageSender::from_message_sender(&message.sender_id, message.bot_profile),
+ sender_id: message.sender_id,
+ content: message.content,
+ created_at: message.created_at,
+ updated_at: message.updated_at,
+ edited_at: message.edited_at,
+ deleted_at: message.deleted_at,
+ thread: SoupThreadInfo::from(message.thread),
+ reactions: message.reactions.into_iter().map(Into::into).collect(),
+ attachments: message.attachments.into_iter().map(Into::into).collect(),
}
}
}
diff --git a/rust/cloud-storage/models_soup/src/item.rs b/rust/cloud-storage/models_soup/src/item.rs
index c6c7c7b571..57de2f1088 100644
--- a/rust/cloud-storage/models_soup/src/item.rs
+++ b/rust/cloud-storage/models_soup/src/item.rs
@@ -59,8 +59,9 @@ impl SoupItem {
SoupItem::Channel(channel) => {
EntityType::Channel.with_entity_string(channel.channel.channel.id.0.to_string())
}
- SoupItem::ChannelThread(thread) => EntityType::ChannelMessage
- .with_entity_string(thread.root_message.message_id.to_string()),
+ SoupItem::ChannelThread(thread) => {
+ EntityType::ChannelMessage.with_entity_string(thread.id.to_string())
+ }
SoupItem::Call(record) => {
EntityType::Call.with_entity_string(record.call_id.to_string())
}
@@ -81,7 +82,7 @@ impl SoupItem {
SoupItem::Project(soup_project) => soup_project.updated_at,
SoupItem::EmailThread(soup_thread) => soup_thread.thread.updated_at,
SoupItem::Channel(soup_channel) => soup_channel.channel.channel.updated_at,
- SoupItem::ChannelThread(thread) => thread.updated_at(),
+ SoupItem::ChannelThread(thread) => thread.effective_updated_at(),
SoupItem::Call(record) => record.ended_at.unwrap_or(record.started_at),
SoupItem::CrmCompany(company) => company.updated_at,
SoupItem::ForeignEntity(foreign_entity) => foreign_entity.updated_at,
@@ -142,10 +143,8 @@ impl SoupItem {
(SoupItem::Channel(soup_channel), SimpleSortMethod::ViewedUpdated) => soup_channel
.viewed_at
.unwrap_or(soup_channel.channel.channel.updated_at),
- (SoupItem::ChannelThread(thread), SimpleSortMethod::CreatedAt) => {
- thread.root_message.created_at
- }
- (SoupItem::ChannelThread(thread), _) => thread.updated_at(),
+ (SoupItem::ChannelThread(thread), SimpleSortMethod::CreatedAt) => thread.created_at,
+ (SoupItem::ChannelThread(thread), _) => thread.effective_updated_at(),
(SoupItem::Call(record), SimpleSortMethod::CreatedAt) => record.started_at,
(SoupItem::Call(record), _) => record.ended_at.unwrap_or(record.started_at),
(SoupItem::CrmCompany(company), SimpleSortMethod::CreatedAt) => company.created_at,
@@ -174,7 +173,7 @@ impl Identify for SoupItem {
SoupItem::Project(soup_project) => soup_project.id,
SoupItem::EmailThread(thread) => thread.thread.id,
SoupItem::Channel(soup_channel) => soup_channel.channel.channel.id.0,
- SoupItem::ChannelThread(thread) => thread.root_message.message_id,
+ SoupItem::ChannelThread(thread) => thread.id,
SoupItem::Call(record) => record.call_id,
SoupItem::CrmCompany(company) => company.id,
SoupItem::ForeignEntity(foreign_entity) => foreign_entity.id,
diff --git a/rust/cloud-storage/soup/src/domain/service.rs b/rust/cloud-storage/soup/src/domain/service.rs
index c4b6ea46bb..006b3f1481 100644
--- a/rust/cloud-storage/soup/src/domain/service.rs
+++ b/rust/cloud-storage/soup/src/domain/service.rs
@@ -414,13 +414,13 @@ where
Ok(Either::Right(
self.comms_service
- .get_thread_reply_rows(req)
+ .get_thread_messages(req)
.await
.map_err(|_| SoupErr::CommsErr)?
.into_iter()
- .map(|rows| FrecencySoupItem {
- item: SoupItem::ChannelThread(SoupChannelThread::new_from_thread_reply_rows(
- rows,
+ .map(|message| FrecencySoupItem {
+ item: SoupItem::ChannelThread(SoupChannelThread::new_from_channel_message(
+ message,
)),
frecency_score: None,
}),
diff --git a/rust/cloud-storage/soup/src/domain/service/tests.rs b/rust/cloud-storage/soup/src/domain/service/tests.rs
index 71898444e4..8f4cf83734 100644
--- a/rust/cloud-storage/soup/src/domain/service/tests.rs
+++ b/rust/cloud-storage/soup/src/domain/service/tests.rs
@@ -2,8 +2,7 @@ use crate::domain::models::FrecencySoupItem;
use crate::domain::ports::MockSoupRepo;
use channels::domain::{
models::{
- ChannelThreadReplyRows, GetChannelsRequest, GetThreadReplyRowsRequest, ThreadReplyRow,
- TopLevelMessageRow,
+ ChannelMessage, GetChannelsRequest, GetThreadReplyRowsRequest, ThreadInfo, ThreadReply,
},
ports::ChannelListService,
};
@@ -74,10 +73,10 @@ impl ChannelListService for NoopCommsService {
Ok(Vec::new())
}
- async fn get_thread_reply_rows(
+ async fn get_thread_messages(
&self,
_req: GetThreadReplyRowsRequest,
- ) -> Result<Vec<ChannelThreadReplyRows>, Report> {
+ ) -> Result<Vec<ChannelMessage>, Report> {
Ok(Vec::new())
}
@@ -91,14 +90,14 @@ impl ChannelListService for NoopCommsService {
#[derive(Clone)]
struct RecordingCommsService {
- rows: Vec<ChannelThreadReplyRows>,
+ rows: Vec<ChannelMessage>,
channel_calls: Arc<Mutex<u32>>,
channel_filters: Arc<Mutex<Vec<String>>>,
thread_filters: Arc<Mutex<Vec<String>>>,
}
impl RecordingCommsService {
- fn new(rows: Vec<ChannelThreadReplyRows>) -> Self {
+ fn new(rows: Vec<ChannelMessage>) -> Self {
Self {
rows,
channel_calls: Arc::new(Mutex::new(0)),
@@ -140,10 +139,10 @@ impl ChannelListService for RecordingCommsService {
Ok(Vec::new())
}
- async fn get_thread_reply_rows(
+ async fn get_thread_messages(
&self,
req: GetThreadReplyRowsRequest,
- ) -> Result<Vec<ChannelThreadReplyRows>, Report> {
+ ) -> Result<Vec<ChannelMessage>, Report> {
self.thread_filters
.lock()
.unwrap()
@@ -491,32 +490,39 @@ fn foreign_entity_for_source(
}
}
-fn channel_thread_rows(
+fn channel_thread_message(
channel_id: Uuid,
thread_id: Uuid,
reply_id: Uuid,
updated_at: DateTime<Utc>,
-) -> ChannelThreadReplyRows {
- ChannelThreadReplyRows {
- parent: TopLevelMessageRow {
- id: thread_id,
- channel_id,
- sender_id: "macro|[email protected]".to_string(),
- content: "thread parent".to_string(),
- created_at: DateTime::default(),
- updated_at,
- edited_at: None,
- deleted_at: None,
+) -> ChannelMessage {
+ ChannelMessage {
+ id: thread_id,
+ channel_id,
+ sender_id: "macro|[email protected]".to_string(),
+ bot_profile: None,
+ content: "thread parent".to_string(),
+ created_at: DateTime::default(),
+ updated_at,
+ edited_at: None,
+ deleted_at: None,
+ thread: ThreadInfo {
+ reply_count: 1,
+ latest_reply_at: Some(DateTime::default() + Days::new(1)),
+ preview: vec![ThreadReply {
+ id: reply_id,
+ sender_id: "macro|[email protected]".to_string(),
+ bot_profile: None,
+ content: "thread reply".to_string(),
+ created_at: DateTime::default() + Days::new(1),
+ updated_at: DateTime::default() + Days::new(1),
+ edited_at: None,
+ reactions: Vec::new(),
+ attachments: Vec::new(),
+ }],
},
- replies: vec![ThreadReplyRow {
- id: reply_id,
- thread_id,
- sender_id: "macro|[email protected]".to_string(),
- content: "thread reply".to_string(),
- created_at: DateTime::default() + Days::new(1),
- updated_at: DateTime::default() + Days::new(1),
- edited_at: None,
- }],
+ reactions: Vec::new(),
+ attachments: Vec::new(),
}
}
@@ -526,7 +532,7 @@ async fn simple_soup_includes_channel_threads() {
let channel_id = Uuid::from_u128(0xaaaa);
let thread_id = Uuid::from_u128(0xbbbb);
let reply_id = Uuid::from_u128(0xcccc);
- let comms_service = RecordingCommsService::new(vec![channel_thread_rows(
+ let comms_service = RecordingCommsService::new(vec![channel_thread_message(
channel_id,
thread_id,
reply_id,
@@ -572,10 +578,11 @@ async fn simple_soup_includes_channel_threads() {
assert_matches!(
&page.items[0].item,
SoupItem::ChannelThread(thread) => {
- assert_eq!(thread.channel_id.0, channel_id);
- assert_eq!(thread.root_message.message_id, thread_id);
- assert_eq!(thread.messages.len(), 1);
- assert_eq!(thread.messages[0].message_id, reply_id);
+ assert_eq!(thread.channel_id, channel_id);
+ assert_eq!(thread.id, thread_id);
+ assert_eq!(thread.thread.reply_count, 1);
+ assert_eq!(thread.thread.preview.len(), 1);
+ assert_eq!(thread.thread.preview[0].id, reply_id);
}
);
}
diff --git a/rust/cloud-storage/soup/src/inbound/toolset/list_entities.rs b/rust/cloud-storage/soup/src/inbound/toolset/list_entities.rs
index b38eba8e7d..0f0ced928c 100644
--- a/rust/cloud-storage/soup/src/inbound/toolset/list_entities.rs
+++ b/rust/cloud-storage/soup/src/inbound/toolset/list_entities.rs
@@ -198,8 +198,8 @@ impl From<SoupItem> for EntityItem {
name: channel.channel.channel.name.clone(),
},
SoupItem::ChannelThread(thread) => EntityItem::ChannelThread {
- id: thread.root_message.message_id,
- channel_id: thread.channel_id.0,
+ id: thread.id,
+ channel_id: thread.channel_id,
},
SoupItem::Call(record) => EntityItem::Call {
id: record.call_id,