Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

feat(channels): return attachment width/height (#2123)

teo76c552f681d0
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/apiMessageAttachment.ts b/js/app/packages/service-clients/service-storage/generated/schemas/apiMessageAttachment.ts
index 3525415dd8..ade106edc9 100644
--- a/js/app/packages/service-clients/service-storage/generated/schemas/apiMessageAttachment.ts
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/apiMessageAttachment.ts
@@ -4,6 +4,8 @@
* document_storage_service
* OpenAPI spec version: 0.1.0
*/
+import type { ApiMessageAttachmentHeight } from './apiMessageAttachmentHeight';
+import type { ApiMessageAttachmentWidth } from './apiMessageAttachmentWidth';
/**
* An attachment on a message.
@@ -15,6 +17,10 @@ export interface ApiMessageAttachment {
entity_id: string;
/** Type of entity. */
entity_type: string;
+ /** Height (for images). */
+ height?: ApiMessageAttachmentHeight;
/** Attachment id. */
id: string;
+ /** Width (for images). */
+ width?: ApiMessageAttachmentWidth;
}
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/apiMessageAttachmentHeight.ts b/js/app/packages/service-clients/service-storage/generated/schemas/apiMessageAttachmentHeight.ts
new file mode 100644
index 0000000000..310e6c0636
--- /dev/null
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/apiMessageAttachmentHeight.ts
@@ -0,0 +1,11 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * Height (for images).
+ */
+export type ApiMessageAttachmentHeight = number | null;
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/apiMessageAttachmentWidth.ts b/js/app/packages/service-clients/service-storage/generated/schemas/apiMessageAttachmentWidth.ts
new file mode 100644
index 0000000000..453f104ae1
--- /dev/null
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/apiMessageAttachmentWidth.ts
@@ -0,0 +1,11 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * Width (for images).
+ */
+export type ApiMessageAttachmentWidth = number | null;
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 43284f607d..d52a41c00c 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
@@ -53,6 +53,8 @@ export * from './apiChannelMessagesPagePreviousCursor';
export * from './apiChannelParticipant';
export * from './apiCountedReaction';
export * from './apiMessageAttachment';
+export * from './apiMessageAttachmentHeight';
+export * from './apiMessageAttachmentWidth';
export * from './apiParticipantRole';
export * from './apiThreadInfo';
export * from './apiThreadInfoLatestReplyAt';
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 8013cf52f9..3c25f0c1f3 100644
--- a/js/app/packages/service-clients/service-storage/generated/zod.ts
+++ b/js/app/packages/service-clients/service-storage/generated/zod.ts
@@ -905,7 +905,15 @@ export const getChannelMessagesResponse = zod
.describe('When the attachment was created.'),
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.string().uuid().describe('Attachment id.'),
+ width: zod
+ .number()
+ .nullish()
+ .describe('Width (for images).'),
})
.describe('An attachment on a message.')
)
@@ -963,10 +971,18 @@ export const getChannelMessagesResponse = zod
entity_type: zod
.string()
.describe('Type of entity.'),
+ height: zod
+ .number()
+ .nullish()
+ .describe('Height (for images).'),
id: zod
.string()
.uuid()
.describe('Attachment id.'),
+ width: zod
+ .number()
+ .nullish()
+ .describe('Width (for images).'),
})
.describe('An attachment on a message.')
)
@@ -1052,7 +1068,9 @@ export const getThreadRepliesResponseItem = zod
.describe('When the attachment was created.'),
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.string().uuid().describe('Attachment id.'),
+ width: zod.number().nullish().describe('Width (for images).'),
})
.describe('An attachment on a message.')
)
diff --git a/js/app/packages/service-clients/service-storage/openapi.json b/js/app/packages/service-clients/service-storage/openapi.json
index 1df2fe71b9..b349af0d6d 100644
--- a/js/app/packages/service-clients/service-storage/openapi.json
+++ b/js/app/packages/service-clients/service-storage/openapi.json
@@ -5228,10 +5228,20 @@
"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)."
}
}
},
diff --git a/rust/cloud-storage/channels/.sqlx/query-4760be157b671303b9a00690179b7fa85258f1fb5b0f73de16eaef3a683fcdf9.json b/rust/cloud-storage/channels/.sqlx/query-b0d3b6f03c4160e443a3fe91c870187c3178efdf6853a22ee319c0163b1f6013.json
similarity index 67%
rename from rust/cloud-storage/channels/.sqlx/query-4760be157b671303b9a00690179b7fa85258f1fb5b0f73de16eaef3a683fcdf9.json
rename to rust/cloud-storage/channels/.sqlx/query-b0d3b6f03c4160e443a3fe91c870187c3178efdf6853a22ee319c0163b1f6013.json
index 04b9bd7034..b18fa9a1d9 100644
--- a/rust/cloud-storage/channels/.sqlx/query-4760be157b671303b9a00690179b7fa85258f1fb5b0f73de16eaef3a683fcdf9.json
+++ b/rust/cloud-storage/channels/.sqlx/query-b0d3b6f03c4160e443a3fe91c870187c3178efdf6853a22ee319c0163b1f6013.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "\n SELECT id, message_id, entity_type, entity_id, created_at\n FROM comms_attachments\n WHERE message_id = ANY($1)\n ORDER BY created_at ASC\n ",
+ "query": "\n SELECT id, message_id, entity_type, entity_id,\n width AS \"width?\", height AS \"height?\", created_at\n FROM comms_attachments\n WHERE message_id = ANY($1)\n ORDER BY created_at ASC\n ",
"describe": {
"columns": [
{
@@ -25,6 +25,16 @@
},
{
"ordinal": 4,
+ "name": "width?",
+ "type_info": "Int4"
+ },
+ {
+ "ordinal": 5,
+ "name": "height?",
+ "type_info": "Int4"
+ },
+ {
+ "ordinal": 6,
"name": "created_at",
"type_info": "Timestamptz"
}
@@ -39,8 +49,10 @@
false,
false,
false,
+ true,
+ true,
false
]
},
- "hash": "4760be157b671303b9a00690179b7fa85258f1fb5b0f73de16eaef3a683fcdf9"
+ "hash": "b0d3b6f03c4160e443a3fe91c870187c3178efdf6853a22ee319c0163b1f6013"
}
diff --git a/rust/cloud-storage/channels/src/domain/models.rs b/rust/cloud-storage/channels/src/domain/models.rs
index f9384ec8ec..c8aed4d2d4 100644
--- a/rust/cloud-storage/channels/src/domain/models.rs
+++ b/rust/cloud-storage/channels/src/domain/models.rs
@@ -114,6 +114,10 @@ pub struct MessageAttachment {
pub entity_type: String,
/// Id of the attached entity.
pub entity_id: String,
+ /// Optional width (for images).
+ pub width: Option<i32>,
+ /// Optional height (for images).
+ pub height: Option<i32>,
/// When the attachment was created.
pub created_at: DateTime<Utc>,
}
diff --git a/rust/cloud-storage/channels/src/domain/service/test.rs b/rust/cloud-storage/channels/src/domain/service/test.rs
index 278321d45f..627d290a37 100644
--- a/rust/cloud-storage/channels/src/domain/service/test.rs
+++ b/rust/cloud-storage/channels/src/domain/service/test.rs
@@ -131,6 +131,8 @@ async fn returns_messages_with_thread_info() {
id: Uuid::new_v4(),
entity_type: "document".into(),
entity_id: "doc_1".into(),
+ width: None,
+ height: None,
created_at: Utc::now(),
};
let attachment_clone = attachment.clone();
@@ -429,6 +431,8 @@ async fn thread_replies_resolve_and_hydrate() {
id: Uuid::new_v4(),
entity_type: "document".into(),
entity_id: "doc-1".into(),
+ width: None,
+ height: None,
created_at: Utc::now(),
}],
);
diff --git a/rust/cloud-storage/channels/src/inbound/axum_router.rs b/rust/cloud-storage/channels/src/inbound/axum_router.rs
index ceb5545c9f..1902165961 100644
--- a/rust/cloud-storage/channels/src/inbound/axum_router.rs
+++ b/rust/cloud-storage/channels/src/inbound/axum_router.rs
@@ -499,6 +499,10 @@ pub struct ApiMessageAttachment {
entity_type: String,
/// Entity id.
entity_id: String,
+ /// Width (for images).
+ width: Option<i32>,
+ /// Height (for images).
+ height: Option<i32>,
/// When the attachment was created.
created_at: DateTime<Utc>,
}
@@ -509,6 +513,8 @@ impl From<MessageAttachment> for ApiMessageAttachment {
id: a.id,
entity_type: a.entity_type,
entity_id: a.entity_id,
+ width: a.width,
+ height: a.height,
created_at: a.created_at,
}
}
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 5f66d58d31..4c03ea0312 100644
--- a/rust/cloud-storage/channels/src/outbound/pg_channels_repo.rs
+++ b/rust/cloud-storage/channels/src/outbound/pg_channels_repo.rs
@@ -80,6 +80,8 @@ struct AttachmentRow {
message_id: Uuid,
entity_type: String,
entity_id: String,
+ width: Option<i32>,
+ height: Option<i32>,
created_at: chrono::DateTime<chrono::Utc>,
}
@@ -383,7 +385,8 @@ impl ChannelMessagesRepo for PgChannelMessagesRepo {
let rows = sqlx::query_as!(
AttachmentRow,
r#"
- SELECT id, message_id, entity_type, entity_id, created_at
+ SELECT id, message_id, entity_type, entity_id,
+ width AS "width?", height AS "height?", created_at
FROM comms_attachments
WHERE message_id = ANY($1)
ORDER BY created_at ASC
@@ -401,6 +404,8 @@ impl ChannelMessagesRepo for PgChannelMessagesRepo {
id: r.id,
entity_type: r.entity_type,
entity_id: r.entity_id,
+ width: r.width,
+ height: r.height,
created_at: r.created_at,
});
}