Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
feat(channels): port entity-mentions endpoints to channels hex (#3618)
teof93f82419e3d
diff --git a/js/app/packages/core/signal/mention.ts b/js/app/packages/core/signal/mention.tsindex 688de6337e..7bdbd0b79f 100644--- a/js/app/packages/core/signal/mention.ts+++ b/js/app/packages/core/signal/mention.ts@@ -1,7 +1,6 @@import { ENABLE_MENTION_TRACKING } from '@core/constant/featureFlags';-import { commsServiceClient } from '@service-comms/client';-import type { ItemType } from '@service-storage/client';+import { type ItemType, storageServiceClient } from '@service-storage/client';import { getPermissionToken } from './token';type MentionId = string;@@ -15,7 +14,7 @@ export async function trackMention(const token = await getPermissionToken('document', sourceId);if (!token) return;- const response = await commsServiceClient.createEntityMention(+ const response = await storageServiceClient.createEntityMention({source_entity_type: 'document',source_entity_id: sourceId,@@ -41,7 +40,7 @@ export async function untrackMention(const token = await getPermissionToken('document', sourceId);if (!token) return;- const response = await commsServiceClient.deleteEntityMention(+ const response = await storageServiceClient.deleteEntityMention({mention_id: mentionId,},diff --git a/js/app/packages/service-clients/service-storage/client.ts b/js/app/packages/service-clients/service-storage/client.tsindex 4d2363edf4..22c2bdaade 100644--- a/js/app/packages/service-clients/service-storage/client.ts+++ b/js/app/packages/service-clients/service-storage/client.ts@@ -56,6 +56,8 @@ import type { CreateChannelResponse } from './generated/schemas/createChannelResimport type { CreateCommentResponse } from './generated/schemas/createCommentResponse';import type { CreateDocument200 as CreateDocumentResponse } from './generated/schemas/createDocument200';import type { CreateDocumentRequest } from './generated/schemas/createDocumentRequest';+import type { CreateEntityMentionRequest } from './generated/schemas/createEntityMentionRequest';+import type { CreateEntityMentionResponse } from './generated/schemas/createEntityMentionResponse';import type { CreateInstructionsDocumentResponse } from './generated/schemas/createInstructionsDocumentResponse';import type { CreateMarkdownDocumentRequest } from './generated/schemas/createMarkdownDocumentRequest';import type { CreateMarkdownHandler200 } from './generated/schemas/createMarkdownHandler200';@@ -64,6 +66,7 @@ import type { CreateTaskHandler200 } from './generated/schemas/createTaskHandlerimport type { CreateTaskRequest } from './generated/schemas/createTaskRequest';import type { CreateUnthreadedAnchorResponse } from './generated/schemas/createUnthreadedAnchorResponse';import type { DeleteCommentResponse } from './generated/schemas/deleteCommentResponse';+import type { DeleteEntityMentionResponse } from './generated/schemas/deleteEntityMentionResponse';import type { DeleteUnthreadedAnchorResponse } from './generated/schemas/deleteUnthreadedAnchorResponse';import type { DocumentMetadata } from './generated/schemas/documentMetadata';import type { DocumentPreview } from './generated/schemas/documentPreview';@@ -177,6 +180,7 @@ export type MessageResponse = { message: string };type WithChannelId = { channel_id: string };type WithMessageId = { message_id: string };+type WithMentionId = { mention_id: string };type WithEntity = { entity_type: string; entity_id: string };export type ChannelAttachmentType = 'static' | 'dss';@@ -664,6 +668,28 @@ export const storageServiceClient = {).map((result) => result);},+ async createEntityMention(args: CreateEntityMentionRequest, token?: string) {+ return (+ await dssFetch<CreateEntityMentionResponse>(`/channels/mentions`, {+ method: 'POST',+ body: JSON.stringify(args),+ headers: token ? { 'x-permissions-token': token } : undefined,+ })+ ).map((result) => result);+ },++ async deleteEntityMention(args: WithMentionId, token?: string) {+ return (+ await dssFetch<DeleteEntityMentionResponse>(+ `/channels/mentions/${args.mention_id}`,+ {+ method: 'DELETE',+ headers: token ? { 'x-permissions-token': token } : undefined,+ }+ )+ ).map((result) => result);+ },+async attachmentReferences(args: WithEntity) {const { entity_type, entity_id } = args;return (diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/createEntityMentionRequest.ts b/js/app/packages/service-clients/service-storage/generated/schemas/createEntityMentionRequest.tsnew file mode 100644index 0000000000..86e9a184f0--- /dev/null+++ b/js/app/packages/service-clients/service-storage/generated/schemas/createEntityMentionRequest.ts@@ -0,0 +1,20 @@+/**+ * Generated by orval v7.21.0 🍺+ * Do not edit manually.+ * document_storage_service+ * OpenAPI spec version: 0.1.0+ */++/**+ * Request body for `POST /channels/mentions`.+ */+export interface CreateEntityMentionRequest {+ /** Id of the mentioned entity. */+ entity_id: string;+ /** Type of the mentioned entity. */+ entity_type: string;+ /** Id of the entity that owns the mention. */+ source_entity_id: string;+ /** Type of the entity that owns the mention. */+ source_entity_type: string;+}diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/createEntityMentionResponse.ts b/js/app/packages/service-clients/service-storage/generated/schemas/createEntityMentionResponse.tsnew file mode 100644index 0000000000..2d7da3ec7f--- /dev/null+++ b/js/app/packages/service-clients/service-storage/generated/schemas/createEntityMentionResponse.ts@@ -0,0 +1,27 @@+/**+ * Generated by orval v7.21.0 🍺+ * Do not edit manually.+ * document_storage_service+ * OpenAPI spec version: 0.1.0+ */+import type { CreateEntityMentionResponseUserId } from './createEntityMentionResponseUserId';++/**+ * Response body for `POST /channels/mentions`.+ */+export interface CreateEntityMentionResponse {+ /** Created timestamp. */+ created_at: string;+ /** Id of the mentioned entity. */+ entity_id: string;+ /** Type of the mentioned entity. */+ entity_type: string;+ /** Mention id. */+ id: string;+ /** Id of the entity that owns the mention. */+ source_entity_id: string;+ /** Type of the entity that owns the mention. */+ source_entity_type: string;+ /** User who recorded the mention. */+ user_id?: CreateEntityMentionResponseUserId;+}diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/createEntityMentionResponseUserId.ts b/js/app/packages/service-clients/service-storage/generated/schemas/createEntityMentionResponseUserId.tsnew file mode 100644index 0000000000..09b22645f6--- /dev/null+++ b/js/app/packages/service-clients/service-storage/generated/schemas/createEntityMentionResponseUserId.ts@@ -0,0 +1,11 @@+/**+ * Generated by orval v7.21.0 🍺+ * Do not edit manually.+ * document_storage_service+ * OpenAPI spec version: 0.1.0+ */++/**+ * User who recorded the mention.+ */+export type CreateEntityMentionResponseUserId = string | null;diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/deleteEntityMentionResponse.ts b/js/app/packages/service-clients/service-storage/generated/schemas/deleteEntityMentionResponse.tsnew file mode 100644index 0000000000..c36be63bb5--- /dev/null+++ b/js/app/packages/service-clients/service-storage/generated/schemas/deleteEntityMentionResponse.ts@@ -0,0 +1,14 @@+/**+ * Generated by orval v7.21.0 🍺+ * Do not edit manually.+ * document_storage_service+ * OpenAPI spec version: 0.1.0+ */++/**+ * Response body for `DELETE /channels/mentions/{mention_id}`.+ */+export interface DeleteEntityMentionResponse {+ /** Whether the mention was deleted. */+ deleted: boolean;+}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.tsindex d1c2fa26aa..a1eef3969f 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@@ -208,6 +208,9 @@ export * from './createDocumentRequestTeamId';export * from './createDocumentResponseData';export * from './createDocumentResponseDataAllOf';export * from './createDocumentResponseDataAllOfFileType';+export * from './createEntityMentionRequest';+export * from './createEntityMentionResponse';+export * from './createEntityMentionResponseUserId';export * from './createInstructionsDocumentResponse';export * from './createMarkdownDocumentRequest';export * from './createMarkdownDocumentRequestMarkdown';@@ -247,6 +250,7 @@ export * from './deleteCommentRequest';export * from './deleteCommentRequestRemoveAnchorThreadOnly';export * from './deleteCommentResponse';export * from './deleteCommentResponseAnchor';+export * from './deleteEntityMentionResponse';export * from './deleteMessageParams';export * from './deleteMessageQuery';export * from './deleteMessageQueryNonce';diff --git a/js/app/packages/service-clients/service-storage/generated/zod.ts b/js/app/packages/service-clients/service-storage/generated/zod.tsindex facdeee4c7..7e5b278c27 100644--- a/js/app/packages/service-clients/service-storage/generated/zod.ts+++ b/js/app/packages/service-clients/service-storage/generated/zod.ts@@ -1398,6 +1398,35 @@ export const getOrCreatePrivateResponse = zod}).describe('Response for get-or-create channel operations.');+/**+ * @summary Handler for `POST /channels/mentions`.+ */+export const createEntityMentionBody = zod+ .object({+ entity_id: zod.string().describe('Id of the mentioned entity.'),+ entity_type: zod.string().describe('Type of the mentioned entity.'),+ source_entity_id: zod+ .string()+ .describe('Id of the entity that owns the mention.'),+ source_entity_type: zod+ .string()+ .describe('Type of the entity that owns the mention.'),+ })+ .describe('Request body for `POST \/channels\/mentions`.');++/**+ * @summary Handler for `DELETE /channels/mentions/{mention_id}`.+ */+export const deleteEntityMentionParams = zod.object({+ mention_id: zod.uuid().describe('Entity mention id'),+});++export const deleteEntityMentionResponse = zod+ .object({+ deleted: zod.boolean().describe('Whether the mention was deleted.'),+ })+ .describe('Response body for `DELETE \/channels\/mentions\/{mention_id}`.');+/*** @summary Handler for `DELETE /channels/{channel_id}`.*/diff --git a/js/app/packages/service-clients/service-storage/openapi.json b/js/app/packages/service-clients/service-storage/openapi.jsonindex b33b481a70..3e261cd638 100644--- a/js/app/packages/service-clients/service-storage/openapi.json+++ b/js/app/packages/service-clients/service-storage/openapi.json@@ -1502,6 +1502,146 @@}}},+ "/channels/mentions": {+ "post": {+ "tags": ["channels"],+ "summary": "Handler for `POST /channels/mentions`.",+ "operationId": "create_entity_mention",+ "requestBody": {+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/CreateEntityMentionRequest"+ }+ }+ },+ "required": true+ },+ "responses": {+ "201": {+ "description": "",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/CreateEntityMentionResponse"+ }+ }+ }+ },+ "400": {+ "description": "",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/ErrorResponse"+ }+ }+ }+ },+ "401": {+ "description": "",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/ErrorResponse"+ }+ }+ }+ },+ "404": {+ "description": "",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/ErrorResponse"+ }+ }+ }+ },+ "500": {+ "description": "",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/ErrorResponse"+ }+ }+ }+ }+ }+ }+ },+ "/channels/mentions/{mention_id}": {+ "delete": {+ "tags": ["channels"],+ "summary": "Handler for `DELETE /channels/mentions/{mention_id}`.",+ "operationId": "delete_entity_mention",+ "parameters": [+ {+ "name": "mention_id",+ "in": "path",+ "description": "Entity mention id",+ "required": true,+ "schema": {+ "type": "string",+ "format": "uuid"+ }+ }+ ],+ "responses": {+ "200": {+ "description": "",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/DeleteEntityMentionResponse"+ }+ }+ }+ },+ "400": {+ "description": "",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/ErrorResponse"+ }+ }+ }+ },+ "401": {+ "description": "",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/ErrorResponse"+ }+ }+ }+ },+ "404": {+ "description": "",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/ErrorResponse"+ }+ }+ }+ },+ "500": {+ "description": "",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/ErrorResponse"+ }+ }+ }+ }+ }+ }+ },"/channels/{channel_id}": {"delete": {"tags": ["channels"],@@ -9438,6 +9578,77 @@}]},+ "CreateEntityMentionRequest": {+ "type": "object",+ "description": "Request body for `POST /channels/mentions`.",+ "required": [+ "source_entity_type",+ "source_entity_id",+ "entity_type",+ "entity_id"+ ],+ "properties": {+ "entity_id": {+ "type": "string",+ "description": "Id of the mentioned entity."+ },+ "entity_type": {+ "type": "string",+ "description": "Type of the mentioned entity."+ },+ "source_entity_id": {+ "type": "string",+ "description": "Id of the entity that owns the mention."+ },+ "source_entity_type": {+ "type": "string",+ "description": "Type of the entity that owns the mention."+ }+ }+ },+ "CreateEntityMentionResponse": {+ "type": "object",+ "description": "Response body for `POST /channels/mentions`.",+ "required": [+ "id",+ "source_entity_type",+ "source_entity_id",+ "entity_type",+ "entity_id",+ "created_at"+ ],+ "properties": {+ "created_at": {+ "type": "string",+ "format": "date-time",+ "description": "Created timestamp."+ },+ "entity_id": {+ "type": "string",+ "description": "Id of the mentioned entity."+ },+ "entity_type": {+ "type": "string",+ "description": "Type of the mentioned entity."+ },+ "id": {+ "type": "string",+ "description": "Mention id."+ },+ "source_entity_id": {+ "type": "string",+ "description": "Id of the entity that owns the mention."+ },+ "source_entity_type": {+ "type": "string",+ "description": "Type of the entity that owns the mention."+ },+ "user_id": {+ "type": ["string", "null"],+ "description": "User who recorded the mention."+ }+ }+ },"CreateInstructionsDocumentResponse": {"type": "object","required": ["documentId"],@@ -9716,6 +9927,17 @@}}},+ "DeleteEntityMentionResponse": {+ "type": "object",+ "description": "Response body for `DELETE /channels/mentions/{mention_id}`.",+ "required": ["deleted"],+ "properties": {+ "deleted": {+ "type": "boolean",+ "description": "Whether the mention was deleted."+ }+ }+ },"DeleteMessageQuery": {"type": "object","description": "Query parameters for deleting a message.",diff --git a/rust/cloud-storage/.sqlx/query-402db336b46141f0ff5f728de492c3c3897c0c17a0f53ce67c915b20e07b3545.json b/rust/cloud-storage/.sqlx/query-402db336b46141f0ff5f728de492c3c3897c0c17a0f53ce67c915b20e07b3545.jsonnew file mode 100644index 0000000000..8733c29969--- /dev/null+++ b/rust/cloud-storage/.sqlx/query-402db336b46141f0ff5f728de492c3c3897c0c17a0f53ce67c915b20e07b3545.json@@ -0,0 +1,58 @@+{+ "db_name": "PostgreSQL",+ "query": "\n SELECT id, source_entity_type, source_entity_id, entity_type, entity_id, user_id, created_at\n FROM comms_entity_mentions\n WHERE id = $1\n ",+ "describe": {+ "columns": [+ {+ "ordinal": 0,+ "name": "id",+ "type_info": "Uuid"+ },+ {+ "ordinal": 1,+ "name": "source_entity_type",+ "type_info": "Varchar"+ },+ {+ "ordinal": 2,+ "name": "source_entity_id",+ "type_info": "Varchar"+ },+ {+ "ordinal": 3,+ "name": "entity_type",+ "type_info": "Varchar"+ },+ {+ "ordinal": 4,+ "name": "entity_id",+ "type_info": "Varchar"+ },+ {+ "ordinal": 5,+ "name": "user_id",+ "type_info": "Varchar"+ },+ {+ "ordinal": 6,+ "name": "created_at",+ "type_info": "Timestamptz"+ }+ ],+ "parameters": {+ "Left": [+ "Uuid"+ ]+ },+ "nullable": [+ false,+ false,+ false,+ false,+ false,+ true,+ false+ ]+ },+ "hash": "402db336b46141f0ff5f728de492c3c3897c0c17a0f53ce67c915b20e07b3545"+}diff --git a/rust/cloud-storage/.sqlx/query-8ed522f5a19f1f7d136ed0fc5c4c57f4af547d21eb2f6c78c9e2335f4fcd64c2.json b/rust/cloud-storage/.sqlx/query-8ed522f5a19f1f7d136ed0fc5c4c57f4af547d21eb2f6c78c9e2335f4fcd64c2.jsonnew file mode 100644index 0000000000..130425a41e--- /dev/null+++ b/rust/cloud-storage/.sqlx/query-8ed522f5a19f1f7d136ed0fc5c4c57f4af547d21eb2f6c78c9e2335f4fcd64c2.json@@ -0,0 +1,63 @@+{+ "db_name": "PostgreSQL",+ "query": "\n INSERT INTO comms_entity_mentions (id, source_entity_type, source_entity_id, entity_type, entity_id, user_id)\n VALUES ($1, $2, $3, $4, $5, $6)\n RETURNING id, source_entity_type, source_entity_id, entity_type, entity_id, user_id, created_at\n ",+ "describe": {+ "columns": [+ {+ "ordinal": 0,+ "name": "id",+ "type_info": "Uuid"+ },+ {+ "ordinal": 1,+ "name": "source_entity_type",+ "type_info": "Varchar"+ },+ {+ "ordinal": 2,+ "name": "source_entity_id",+ "type_info": "Varchar"+ },+ {+ "ordinal": 3,+ "name": "entity_type",+ "type_info": "Varchar"+ },+ {+ "ordinal": 4,+ "name": "entity_id",+ "type_info": "Varchar"+ },+ {+ "ordinal": 5,+ "name": "user_id",+ "type_info": "Varchar"+ },+ {+ "ordinal": 6,+ "name": "created_at",+ "type_info": "Timestamptz"+ }+ ],+ "parameters": {+ "Left": [+ "Uuid",+ "Varchar",+ "Varchar",+ "Varchar",+ "Varchar",+ "Varchar"+ ]+ },+ "nullable": [+ false,+ false,+ false,+ false,+ false,+ true,+ false+ ]+ },+ "hash": "8ed522f5a19f1f7d136ed0fc5c4c57f4af547d21eb2f6c78c9e2335f4fcd64c2"+}diff --git a/rust/cloud-storage/.sqlx/query-f1afe1bb26ffc5e97fe3a5db39ca0fe594d449939c99f3dd8e338aff9d26753b.json b/rust/cloud-storage/.sqlx/query-f1afe1bb26ffc5e97fe3a5db39ca0fe594d449939c99f3dd8e338aff9d26753b.jsonnew file mode 100644index 0000000000..cbe9dea652--- /dev/null+++ b/rust/cloud-storage/.sqlx/query-f1afe1bb26ffc5e97fe3a5db39ca0fe594d449939c99f3dd8e338aff9d26753b.json@@ -0,0 +1,14 @@+{+ "db_name": "PostgreSQL",+ "query": "\n DELETE FROM comms_entity_mentions\n WHERE id = $1\n ",+ "describe": {+ "columns": [],+ "parameters": {+ "Left": [+ "Uuid"+ ]+ },+ "nullable": []+ },+ "hash": "f1afe1bb26ffc5e97fe3a5db39ca0fe594d449939c99f3dd8e338aff9d26753b"+}diff --git a/rust/cloud-storage/channels/src/domain/models.rs b/rust/cloud-storage/channels/src/domain/models.rsindex c611ee3e70..86b2c4057d 100644--- a/rust/cloud-storage/channels/src/domain/models.rs+++ b/rust/cloud-storage/channels/src/domain/models.rs@@ -785,3 +785,80 @@ pub struct ChannelInfo {/// Team id.pub team_id: Option<Uuid>,}++/// Persisted entity-to-entity mention.+#[derive(Debug, Clone, Serialize, Deserialize)]+#[cfg_attr(feature = "inbound", derive(utoipa::ToSchema))]+pub struct EntityMention {+ /// Mention id.+ pub id: Uuid,+ /// Type of the entity that owns the mention.+ pub source_entity_type: String,+ /// Id of the entity that owns the mention.+ pub source_entity_id: String,+ /// Type of the mentioned entity.+ pub entity_type: String,+ /// Id of the mentioned entity.+ pub entity_id: String,+ /// User who recorded the mention.+ pub user_id: Option<String>,+ /// Created timestamp.+ pub created_at: DateTime<Utc>,+}++/// Options for creating an entity mention.+#[derive(Debug, Clone)]+pub struct CreateEntityMentionOptions {+ /// Type of the entity that owns the mention.+ pub source_entity_type: String,+ /// Id of the entity that owns the mention.+ pub source_entity_id: String,+ /// Type of the mentioned entity.+ pub entity_type: String,+ /// Id of the mentioned entity.+ pub entity_id: String,+ /// User who recorded the mention.+ pub user_id: Option<String>,+}++/// Request body for `POST /channels/mentions`.+#[derive(Debug, Clone, Serialize, Deserialize)]+#[cfg_attr(feature = "inbound", derive(utoipa::ToSchema))]+pub struct CreateEntityMentionRequest {+ /// Type of the entity that owns the mention.+ pub source_entity_type: String,+ /// Id of the entity that owns the mention.+ pub source_entity_id: String,+ /// Type of the mentioned entity.+ pub entity_type: String,+ /// Id of the mentioned entity.+ pub entity_id: String,+}++/// Response body for `POST /channels/mentions`.+#[derive(Debug, Clone, Serialize, Deserialize)]+#[cfg_attr(feature = "inbound", derive(utoipa::ToSchema))]+pub struct CreateEntityMentionResponse {+ /// Mention id.+ pub id: String,+ /// Type of the entity that owns the mention.+ pub source_entity_type: String,+ /// Id of the entity that owns the mention.+ pub source_entity_id: String,+ /// Type of the mentioned entity.+ pub entity_type: String,+ /// Id of the mentioned entity.+ pub entity_id: String,+ /// User who recorded the mention.+ pub user_id: Option<String>,+ /// Created timestamp.+ pub created_at: DateTime<Utc>,+}++/// Response body for `DELETE /channels/mentions/{mention_id}`.+#[derive(Debug, Clone, Serialize, Deserialize)]+#[cfg_attr(feature = "inbound", derive(utoipa::ToSchema))]+pub struct DeleteEntityMentionResponse {+ /// Whether the mention was deleted.+ pub deleted: bool,+}diff --git a/rust/cloud-storage/channels/src/domain/ports.rs b/rust/cloud-storage/channels/src/domain/ports.rsindex 7f0b1e09eb..b14e9ef3c1 100644--- a/rust/cloud-storage/channels/src/domain/ports.rs+++ b/rust/cloud-storage/channels/src/domain/ports.rs@@ -2,13 +2,13 @@ use crate::domain::events::ChannelEvent;use crate::domain::models::{AddParticipantsRequest, AttachmentEntityReference, ChannelAttachment, ChannelAttachmentType,ChannelContextMessage, ChannelInfo, ChannelMessageFilters, ChannelMetadata, ChannelParticipant,- CountedReaction, CreateChannelRequest, CreateChannelResponse, DeleteMessageQuery,- GetOrCreateChannelResponse, GetOrCreateDmRequest, GetOrCreatePrivateRequest, MessageAttachment,- MessagePageDirection, MutatedAttachment, MutatedMessage, NewChannelAttachment,- PatchChannelRequest, PatchMessageRequest, PostMessageRequest, PostMessageResponse,- PostReactionRequest, PostTypingRequest, ReferencedShareItem, RemoveParticipantsRequest,- ResolvedChannelMessage, SimpleMention, ThreadData, ThreadReply, ThreadReplyRow,- TopLevelMessageRow,+ CountedReaction, CreateChannelRequest, CreateChannelResponse, CreateEntityMentionOptions,+ DeleteMessageQuery, EntityMention, GetOrCreateChannelResponse, GetOrCreateDmRequest,+ GetOrCreatePrivateRequest, MessageAttachment, MessagePageDirection, MutatedAttachment,+ MutatedMessage, NewChannelAttachment, PatchChannelRequest, PatchMessageRequest,+ PostMessageRequest, PostMessageResponse, PostReactionRequest, PostTypingRequest,+ ReferencedShareItem, RemoveParticipantsRequest, ResolvedChannelMessage, SimpleMention,+ ThreadData, ThreadReply, ThreadReplyRow, TopLevelMessageRow,};use crate::domain::side_effects::{ChannelDocumentMention, ChannelNotificationEffect, ChannelRealtimeEffect,@@ -248,6 +248,24 @@ pub trait ChannelRepo: Send + Sync + 'static {source_entity_id: String,) -> impl Future<Output = Result<(), Self::Err>> + Send;+ /// Create a single entity mention.+ fn create_entity_mention(+ &self,+ options: CreateEntityMentionOptions,+ ) -> impl Future<Output = Result<EntityMention, Self::Err>> + Send;++ /// Fetch an entity mention by id.+ fn get_entity_mention_by_id(+ &self,+ id: Uuid,+ ) -> impl Future<Output = Result<Option<EntityMention>, Self::Err>> + Send;++ /// Delete an entity mention by id. Returns whether a row was removed.+ fn delete_entity_mention_by_id(+ &self,+ id: Uuid,+ ) -> impl Future<Output = Result<bool, Self::Err>> + Send;+/// Patch message attachment state.fn patch_message_attachments(&self,@@ -597,6 +615,42 @@ pub trait ChannelService: Send + Sync + 'static {))}}++ /// Create an entity mention.+ fn create_entity_mention(+ &self,+ _options: CreateEntityMentionOptions,+ ) -> impl Future<Output = Result<EntityMention, ChannelMutationErr>> + Send {+ async move {+ Err(ChannelMutationErr::NotFound(+ "channel mutations are not configured".to_string(),+ ))+ }+ }++ /// Fetch an entity mention by id.+ fn get_entity_mention(+ &self,+ _id: Uuid,+ ) -> impl Future<Output = Result<Option<EntityMention>, ChannelMutationErr>> + Send {+ async move {+ Err(ChannelMutationErr::NotFound(+ "channel mutations are not configured".to_string(),+ ))+ }+ }++ /// Delete an entity mention by id. Returns whether a row was removed.+ fn delete_entity_mention(+ &self,+ _id: Uuid,+ ) -> impl Future<Output = Result<bool, ChannelMutationErr>> + Send {+ async move {+ Err(ChannelMutationErr::NotFound(+ "channel mutations are not configured".to_string(),+ ))+ }+ }}/// A paginated page of channel messages.diff --git a/rust/cloud-storage/channels/src/domain/service.rs b/rust/cloud-storage/channels/src/domain/service.rsindex 5220f3d45c..20304adde8 100644--- a/rust/cloud-storage/channels/src/domain/service.rs+++ b/rust/cloud-storage/channels/src/domain/service.rs@@ -3,12 +3,13 @@ use crate::domain::{models::{AddParticipantsRequest, AttachmentEntityReference, ChannelAttachmentType,ChannelContextMessage, ChannelMessage, ChannelMessageFilters, ChannelParticipant,- ChannelType, DeleteMessageQuery, GetOrCreateAction, GetOrCreateChannelResponse,- GetOrCreateDmRequest, GetOrCreatePrivateRequest, MessagePageDirection,- NewChannelAttachment, ParticipantRole, PatchChannelRequest, PatchMessageRequest,- PostMessageRequest, PostMessageResponse, PostReactionRequest, PostTypingRequest,- ReactionAction, ReferencedShareItem, RemoveParticipantsRequest, ResolvedChannelMessage,- SimpleMention, ThreadInfo, ThreadReply, TopLevelMessageRow,+ ChannelType, CreateEntityMentionOptions, DeleteMessageQuery, EntityMention,+ GetOrCreateAction, GetOrCreateChannelResponse, GetOrCreateDmRequest,+ GetOrCreatePrivateRequest, MessagePageDirection, NewChannelAttachment, ParticipantRole,+ PatchChannelRequest, PatchMessageRequest, PostMessageRequest, PostMessageResponse,+ PostReactionRequest, PostTypingRequest, ReactionAction, ReferencedShareItem,+ RemoveParticipantsRequest, ResolvedChannelMessage, SimpleMention, ThreadInfo, ThreadReply,+ TopLevelMessageRow,},ports::{ChannelAttachmentsPage, ChannelEventDispatcher, ChannelMessagesErr,@@ -1480,4 +1481,37 @@ where) -> Result<(), ChannelMutationErr> {ChannelServiceImpl::leave_channel(self, actor, channel_id).await}++ #[tracing::instrument(err, skip(self))]+ async fn create_entity_mention(+ &self,+ options: CreateEntityMentionOptions,+ ) -> Result<EntityMention, ChannelMutationErr> {+ self.repo+ .create_entity_mention(options)+ .await+ .map_err(anyhow::Error::from)+ .map_err(ChannelMutationErr::Repo)+ }++ #[tracing::instrument(err, skip(self))]+ async fn get_entity_mention(+ &self,+ id: Uuid,+ ) -> Result<Option<EntityMention>, ChannelMutationErr> {+ self.repo+ .get_entity_mention_by_id(id)+ .await+ .map_err(anyhow::Error::from)+ .map_err(ChannelMutationErr::Repo)+ }++ #[tracing::instrument(err, skip(self))]+ async fn delete_entity_mention(&self, id: Uuid) -> Result<bool, ChannelMutationErr> {+ self.repo+ .delete_entity_mention_by_id(id)+ .await+ .map_err(anyhow::Error::from)+ .map_err(ChannelMutationErr::Repo)+ }}diff --git a/rust/cloud-storage/channels/src/domain/service/test.rs b/rust/cloud-storage/channels/src/domain/service/test.rsindex e02eb05a5a..f9779bb6ee 100644--- a/rust/cloud-storage/channels/src/domain/service/test.rs+++ b/rust/cloud-storage/channels/src/domain/service/test.rs@@ -4,11 +4,11 @@ use crate::domain::{models::{ChannelAttachment, ChannelAttachmentType, ChannelContextMessage, ChannelInfo,ChannelMessageFilters, ChannelMetadata, ChannelParticipant, ChannelType, CountedReaction,- MessageAttachment, MessagePageDirection, MutatedAttachment, MutatedMessage,- NewChannelAttachment, ParticipantRole, PatchChannelRequest, PatchMessageRequest,- PostMessageRequest, PostReactionRequest, ReactionAction, ReferencedShareItem,- ReferencedShareItemType, ResolvedChannelMessage, SimpleMention, ThreadData, ThreadReplyRow,- TopLevelMessageRow,+ CreateEntityMentionOptions, EntityMention, MessageAttachment, MessagePageDirection,+ MutatedAttachment, MutatedMessage, NewChannelAttachment, ParticipantRole,+ PatchChannelRequest, PatchMessageRequest, PostMessageRequest, PostReactionRequest,+ ReactionAction, ReferencedShareItem, ReferencedShareItemType, ResolvedChannelMessage,+ SimpleMention, ThreadData, ThreadReplyRow, TopLevelMessageRow,},ports::{ChannelEventDispatcher, ChannelReferenceSharePermissions, ChannelRepo, MockChannelRepo,@@ -506,6 +506,24 @@ impl ChannelRepo for FakeMutationRepo {Ok(())}+ async fn create_entity_mention(+ &self,+ _options: CreateEntityMentionOptions,+ ) -> Result<EntityMention, Self::Err> {+ anyhow::bail!("not implemented in test repo")+ }++ async fn get_entity_mention_by_id(+ &self,+ _id: Uuid,+ ) -> Result<Option<EntityMention>, Self::Err> {+ Ok(None)+ }++ async fn delete_entity_mention_by_id(&self, _id: Uuid) -> Result<bool, Self::Err> {+ Ok(false)+ }+async fn patch_message_attachments(&self,_message_id: Uuid,diff --git a/rust/cloud-storage/channels/src/inbound/axum_router.rs b/rust/cloud-storage/channels/src/inbound/axum_router.rsindex 7c03bda83b..7d3f5760f5 100644--- a/rust/cloud-storage/channels/src/inbound/axum_router.rs+++ b/rust/cloud-storage/channels/src/inbound/axum_router.rs@@ -2,16 +2,18 @@mod test;pub use crate::domain::models::{- AddParticipantsRequest, CreateChannelRequest, CreateChannelResponse, DeleteMessageQuery,- GetOrCreateChannelResponse, GetOrCreateDmRequest, GetOrCreatePrivateRequest,- PatchChannelRequest, PatchMessageRequest, PostMessageRequest, PostMessageResponse,- PostReactionRequest, PostTypingRequest, RemoveParticipantsRequest,+ AddParticipantsRequest, CreateChannelRequest, CreateChannelResponse,+ CreateEntityMentionRequest, CreateEntityMentionResponse, DeleteEntityMentionResponse,+ DeleteMessageQuery, GetOrCreateChannelResponse, GetOrCreateDmRequest,+ GetOrCreatePrivateRequest, PatchChannelRequest, PatchMessageRequest, PostMessageRequest,+ PostMessageResponse, PostReactionRequest, PostTypingRequest, RemoveParticipantsRequest,};use crate::domain::models::{AttachmentChannelReference, AttachmentEntityReference, AttachmentGenericReference,ChannelAttachment, ChannelAttachmentType, ChannelContextMessage, ChannelMessage,- ChannelMessageKind, ChannelParticipant, CountedReaction, MessageAttachment,- MessagePageDirection, ParticipantRole, ResolvedChannelMessage, ThreadInfo, ThreadReply,+ ChannelMessageKind, ChannelParticipant, CountedReaction, CreateEntityMentionOptions,+ MessageAttachment, MessagePageDirection, ParticipantRole, ResolvedChannelMessage, ThreadInfo,+ ThreadReply,};pub use crate::domain::models::{ChannelMessageFilters, NotificationFilters};use crate::domain::ports::{@@ -29,8 +31,8 @@ use chrono::{DateTime, Utc};use entity_access::{domain::{models::{- AdminParticipantRole, EntityAccessReceipt, EntityPermission, MemberParticipantRole,- OwnerParticipantRole, RequiredPermission,+ AccessError, AccessLevel, AdminParticipantRole, EntityAccessReceipt, EntityPermission,+ EntityType, MemberParticipantRole, OwnerParticipantRole, RequiredPermission,},ports::EntityAccessService,},@@ -231,6 +233,11 @@ where"/get_or_create_private",post(get_or_create_private_handler::<S, Svc>),)+ .route("/mentions", post(create_mention_handler::<S, Svc>))+ .route(+ "/mentions/{mention_id}",+ delete(delete_mention_handler::<S, Svc>),+ ).route("/{channel_id}", patch(patch_channel_handler::<S, Svc>)).route("/{channel_id}", delete(delete_channel_handler::<S, Svc>)).route(@@ -739,6 +746,148 @@ pub async fn leave_channel_handler<S: ChannelService, Svc: EntityAccessService>(Ok(StatusCode::OK)}+async fn require_document_edit_access<Svc: EntityAccessService>(+ access_service: &Svc,+ actor: &MacroUserIdStr<'static>,+ source_entity_type: &str,+ source_entity_id: &str,+) -> Result<(), ChannelsHandlerErr> {+ if source_entity_type != "document" {+ return Err(ChannelsHandlerErr::BadRequest("invalid source entity type"));+ }+ access_service+ .check_access(+ Some(actor),+ source_entity_id,+ EntityType::Document,+ AccessLevel::Edit,+ )+ .await+ .map(|_| ())+ .map_err(map_access_error)+}++fn map_access_error(err: AccessError) -> ChannelsHandlerErr {+ match err {+ AccessError::Unauthorized => ChannelsHandlerErr::Unauthorized("unauthorized"),+ AccessError::UnauthorizedWithMessage(msg) => ChannelsHandlerErr::Unauthorized(msg),+ AccessError::BadRequest(msg) => ChannelsHandlerErr::BadRequest(msg),+ AccessError::NotFound(msg) => ChannelsHandlerErr::NotFound(msg),+ AccessError::DatabaseError(e) => {+ tracing::error!(error=?e, "entity access database error");+ ChannelsHandlerErr::Internal(ChannelMessagesErr::Repo(anyhow::Error::from(e)))+ }+ AccessError::Internal => {+ tracing::error!("entity access internal error");+ ChannelsHandlerErr::Internal(ChannelMessagesErr::Repo(anyhow::anyhow!(+ "entity access internal error"+ )))+ }+ }+}++/// Handler for `POST /channels/mentions`.+#[utoipa::path(+ post,+ tag = "channels",+ operation_id = "create_entity_mention",+ path = "/channels/mentions",+ request_body = CreateEntityMentionRequest,+ responses(+ (status = 201, body = CreateEntityMentionResponse),+ (status = 400, body = ErrorResponse),+ (status = 401, body = ErrorResponse),+ (status = 404, body = ErrorResponse),+ (status = 500, body = ErrorResponse),+ )+)]+#[tracing::instrument(err, skip_all)]+pub async fn create_mention_handler<S: ChannelService, Svc: EntityAccessService>(+ State(state): State<ChannelsRouterState<S, Svc>>,+ macro_user: MacroUserExtractor,+ Json(req): Json<CreateEntityMentionRequest>,+) -> Result<(StatusCode, Json<CreateEntityMentionResponse>), ChannelsHandlerErr> {+ require_document_edit_access(+ state.access_service.as_ref(),+ ¯o_user.macro_user_id,+ &req.source_entity_type,+ &req.source_entity_id,+ )+ .await?;++ let mention = state+ .service+ .create_entity_mention(CreateEntityMentionOptions {+ source_entity_type: req.source_entity_type,+ source_entity_id: req.source_entity_id,+ entity_type: req.entity_type,+ entity_id: req.entity_id,+ user_id: Some(macro_user.user_context.user_id.clone()),+ })+ .await?;++ Ok((+ StatusCode::CREATED,+ Json(CreateEntityMentionResponse {+ id: mention.id.to_string(),+ source_entity_type: mention.source_entity_type,+ source_entity_id: mention.source_entity_id,+ entity_type: mention.entity_type,+ entity_id: mention.entity_id,+ user_id: mention.user_id,+ created_at: mention.created_at,+ }),+ ))+}++/// Handler for `DELETE /channels/mentions/{mention_id}`.+#[utoipa::path(+ delete,+ tag = "channels",+ operation_id = "delete_entity_mention",+ path = "/channels/mentions/{mention_id}",+ params(+ ("mention_id" = Uuid, Path, description = "Entity mention id"),+ ),+ responses(+ (status = 200, body = DeleteEntityMentionResponse),+ (status = 400, body = ErrorResponse),+ (status = 401, body = ErrorResponse),+ (status = 404, body = ErrorResponse),+ (status = 500, body = ErrorResponse),+ )+)]+#[tracing::instrument(err, skip_all)]+pub async fn delete_mention_handler<S: ChannelService, Svc: EntityAccessService>(+ State(state): State<ChannelsRouterState<S, Svc>>,+ macro_user: MacroUserExtractor,+ Path(mention_id): Path<Uuid>,+) -> Result<(StatusCode, Json<DeleteEntityMentionResponse>), ChannelsHandlerErr> {+ let mention = state+ .service+ .get_entity_mention(mention_id)+ .await?+ .ok_or(ChannelsHandlerErr::NotFound("entity mention not found"))?;++ require_document_edit_access(+ state.access_service.as_ref(),+ ¯o_user.macro_user_id,+ &mention.source_entity_type,+ &mention.source_entity_id,+ )+ .await?;++ let deleted = state.service.delete_entity_mention(mention_id).await?;+ if !deleted {+ return Err(ChannelsHandlerErr::NotFound("entity mention not found"));+ }++ Ok((+ StatusCode::OK,+ Json(DeleteEntityMentionResponse { deleted }),+ ))+}+/// Handler for `GET /channels/{channel_id}/messages`.#[utoipa::path(get,@@ -1649,6 +1798,12 @@ pub enum ChannelsHandlerErr {/// Bad request.#[error("{0}")]BadRequest(&'static str),+ /// Unauthorized.+ #[error("{0}")]+ Unauthorized(&'static str),+ /// Not found.+ #[error("{0}")]+ NotFound(&'static str),/// Internal server error.#[error("An internal server error occurred")]Internal(#[from] ChannelMessagesErr),@@ -1667,6 +1822,20 @@ impl IntoResponse for ChannelsHandlerErr {}),).into_response(),+ ChannelsHandlerErr::Unauthorized(message) => (+ StatusCode::UNAUTHORIZED,+ Json(ErrorResponse {+ message: message.into(),+ }),+ )+ .into_response(),+ ChannelsHandlerErr::NotFound(message) => (+ StatusCode::NOT_FOUND,+ Json(ErrorResponse {+ message: message.into(),+ }),+ )+ .into_response(),ChannelsHandlerErr::Mutation(err) => {let status = match &err {ChannelMutationErr::BadRequest(_) => StatusCode::BAD_REQUEST,diff --git a/rust/cloud-storage/channels/src/outbound/pg_channels_repo.rs b/rust/cloud-storage/channels/src/outbound/pg_channels_repo.rsindex c9aac70eec..9edb848d64 100644--- a/rust/cloud-storage/channels/src/outbound/pg_channels_repo.rs+++ b/rust/cloud-storage/channels/src/outbound/pg_channels_repo.rs@@ -6,10 +6,10 @@ use crate::domain::{AttachmentChannelReference, AttachmentEntityReference, AttachmentGenericReference,ChannelAttachment, ChannelAttachmentType, ChannelContextMessage, ChannelInfo,ChannelMessageFilters, ChannelMessageKind, ChannelMetadata, ChannelParticipant,- ChannelType, CountedReaction, CreateChannelRequest, MessageAttachment,- MessagePageDirection, MutatedAttachment, MutatedMessage, NewChannelAttachment,- ParticipantRole, PatchChannelRequest, ResolvedChannelMessage, SimpleMention, ThreadData,- ThreadReplyRow, TopLevelMessageRow,+ ChannelType, CountedReaction, CreateChannelRequest, CreateEntityMentionOptions,+ EntityMention, MessageAttachment, MessagePageDirection, MutatedAttachment, MutatedMessage,+ NewChannelAttachment, ParticipantRole, PatchChannelRequest, ResolvedChannelMessage,+ SimpleMention, ThreadData, ThreadReplyRow, TopLevelMessageRow,},ports::{ChannelRepo, TopLevelMessagesQueryResult},};@@ -2006,6 +2006,61 @@ impl ChannelRepo for PgChannelsRepo {Ok(())}+ async fn create_entity_mention(+ &self,+ options: CreateEntityMentionOptions,+ ) -> Result<EntityMention, Self::Err> {+ let id = macro_uuid::generate_uuid_v7();+ let mention = sqlx::query_as!(+ EntityMention,+ r#"+ INSERT INTO comms_entity_mentions (id, source_entity_type, source_entity_id, entity_type, entity_id, user_id)+ VALUES ($1, $2, $3, $4, $5, $6)+ RETURNING id, source_entity_type, source_entity_id, entity_type, entity_id, user_id, created_at+ "#,+ id,+ options.source_entity_type,+ options.source_entity_id,+ options.entity_type,+ options.entity_id,+ options.user_id,+ )+ .fetch_one(&self.pool)+ .await+ .context("failed to create entity mention")?;+ Ok(mention)+ }++ async fn get_entity_mention_by_id(&self, id: Uuid) -> Result<Option<EntityMention>, Self::Err> {+ let mention = sqlx::query_as!(+ EntityMention,+ r#"+ SELECT id, source_entity_type, source_entity_id, entity_type, entity_id, user_id, created_at+ FROM comms_entity_mentions+ WHERE id = $1+ "#,+ id,+ )+ .fetch_optional(&self.pool)+ .await+ .context("failed to fetch entity mention")?;+ Ok(mention)+ }++ async fn delete_entity_mention_by_id(&self, id: Uuid) -> Result<bool, Self::Err> {+ let result = sqlx::query!(+ r#"+ DELETE FROM comms_entity_mentions+ WHERE id = $1+ "#,+ id,+ )+ .execute(&self.pool)+ .await+ .context("failed to delete entity mention")?;+ Ok(result.rows_affected() > 0)+ }+async fn patch_message_attachments(&self,message_id: Uuid,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.rsindex 651adf8545..f21bc582ab 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@@ -1,6 +1,6 @@use crate::domain::models::{- AttachmentEntityReference, ChannelMessageFilters, MessagePageDirection, NotificationFilters,- ParticipantRole,+ AttachmentEntityReference, ChannelMessageFilters, CreateEntityMentionOptions,+ MessagePageDirection, NotificationFilters, ParticipantRole,};use crate::domain::ports::ChannelRepo;use crate::outbound::pg_channels_repo::PgChannelsRepo;@@ -1174,6 +1174,107 @@ async fn notification_filter_requires_requesting_user(pool: Pool<Postgres>) -> aOk(())}+fn mention_opts(+ source_id: &str,+ entity_type: &str,+ entity_id: &str,+ user_id: Option<&str>,+) -> CreateEntityMentionOptions {+ CreateEntityMentionOptions {+ source_entity_type: "document".to_string(),+ source_entity_id: source_id.to_string(),+ entity_type: entity_type.to_string(),+ entity_id: entity_id.to_string(),+ user_id: user_id.map(str::to_string),+ }+}++#[sqlx::test(migrator = "MACRO_DB_MIGRATIONS")]+async fn create_entity_mention_persists_row(pool: Pool<Postgres>) -> anyhow::Result<()> {+ let repo = repo(pool);+ let mention = repo+ .create_entity_mention(mention_opts("doc-1", "user", "user-x", Some(USER_A)))+ .await?;++ assert_eq!(mention.source_entity_type, "document");+ assert_eq!(mention.source_entity_id, "doc-1");+ assert_eq!(mention.entity_type, "user");+ assert_eq!(mention.entity_id, "user-x");+ assert_eq!(mention.user_id.as_deref(), Some(USER_A));++ let fetched = repo+ .get_entity_mention_by_id(mention.id)+ .await?+ .expect("mention should exist");+ assert_eq!(fetched.id, mention.id);+ assert_eq!(fetched.source_entity_id, "doc-1");+ Ok(())+}++#[sqlx::test(migrator = "MACRO_DB_MIGRATIONS")]+async fn create_entity_mention_allows_duplicates(pool: Pool<Postgres>) -> anyhow::Result<()> {+ let repo = repo(pool);+ let opts = mention_opts("doc-2", "user", "user-y", None);++ let first = repo.create_entity_mention(opts.clone()).await?;+ let second = repo.create_entity_mention(opts).await?;+ assert_ne!(first.id, second.id);++ let count = sqlx::query_scalar!(+ r#"+ SELECT COUNT(*) AS "count!"+ FROM comms_entity_mentions+ WHERE source_entity_id = $1 AND entity_id = $2+ "#,+ "doc-2",+ "user-y",+ )+ .fetch_one(&repo.pool)+ .await?;+ assert_eq!(count, 2);+ Ok(())+}++#[sqlx::test(migrator = "MACRO_DB_MIGRATIONS")]+async fn get_entity_mention_by_id_returns_none_when_missing(+ pool: Pool<Postgres>,+) -> anyhow::Result<()> {+ let repo = repo(pool);+ assert!(+ repo.get_entity_mention_by_id(Uuid::new_v4())+ .await?+ .is_none()+ );+ Ok(())+}++#[sqlx::test(migrator = "MACRO_DB_MIGRATIONS")]+async fn delete_entity_mention_by_id_removes_only_targeted_row(+ pool: Pool<Postgres>,+) -> anyhow::Result<()> {+ let repo = repo(pool);+ let target = repo+ .create_entity_mention(mention_opts("doc-3", "user", "user-z", None))+ .await?;+ let other = repo+ .create_entity_mention(mention_opts("doc-3", "user", "user-w", None))+ .await?;++ assert!(repo.delete_entity_mention_by_id(target.id).await?);+ assert!(repo.get_entity_mention_by_id(target.id).await?.is_none());+ assert!(repo.get_entity_mention_by_id(other.id).await?.is_some());+ Ok(())+}++#[sqlx::test(migrator = "MACRO_DB_MIGRATIONS")]+async fn delete_entity_mention_by_id_returns_false_when_missing(+ pool: Pool<Postgres>,+) -> anyhow::Result<()> {+ let repo = repo(pool);+ assert!(!repo.delete_entity_mention_by_id(Uuid::new_v4()).await?);+ Ok(())+}+// --- get_attachment_references ---//// The query is a byte-identical port of comms_db_client::get_attachment_references;diff --git a/rust/cloud-storage/document_storage_service/src/api/swagger.rs b/rust/cloud-storage/document_storage_service/src/api/swagger.rsindex b2e58d9a3b..8c434b5762 100644--- a/rust/cloud-storage/document_storage_service/src/api/swagger.rs+++ b/rust/cloud-storage/document_storage_service/src/api/swagger.rs@@ -67,8 +67,8 @@ use channels::inbound::axum_router::{ApiChannelAttachment, ApiChannelAttachmentsPage, ApiChannelContextMessage, ApiChannelMessage,ApiChannelMessageKind, ApiChannelMessagesPage, ApiChannelParticipant, ApiCountedReaction,ApiMessageAttachment, ApiParticipantRole, ApiResolvedChannelMessage, ApiThreadInfo,- ApiThreadReply, ChannelMessageFilters, GetAttachmentReferencesResponse,- GetMessageWithContextResponse,+ ApiThreadReply, ChannelMessageFilters, CreateEntityMentionRequest, CreateEntityMentionResponse,+ DeleteEntityMentionResponse, GetAttachmentReferencesResponse, GetMessageWithContextResponse,};use document_sub_type::DocumentSubType;use documents_hex::inbound::axum_router::{@@ -216,6 +216,8 @@ use utoipa::OpenApi;channels::inbound::axum_router::resolve_channel_message_handler,channels::inbound::axum_router::get_channel_attachments_handler,channels::inbound::axum_router::get_channel_participants_handler,+ channels::inbound::axum_router::create_mention_handler,+ channels::inbound::axum_router::delete_mention_handler,channels::inbound::axum_router::get_attachment_references_handler,// calls@@ -406,6 +408,9 @@ use utoipa::OpenApi;channels::domain::models::PostTypingRequest,channels::domain::models::AddParticipantsRequest,channels::domain::models::RemoveParticipantsRequest,+ CreateEntityMentionRequest,+ CreateEntityMentionResponse,+ DeleteEntityMentionResponse,// Callscall::domain::models::CallTokenResponse,diff --git a/rust/cloud-storage/document_storage_service/src/main.rs b/rust/cloud-storage/document_storage_service/src/main.rsindex 41f4c64c08..5e8f1ea4ec 100644--- a/rust/cloud-storage/document_storage_service/src/main.rs+++ b/rust/cloud-storage/document_storage_service/src/main.rs@@ -620,7 +620,10 @@ async fn main() -> anyhow::Result<()> {documents_hex::outbound::document_bytes_upload::ReqwestDocumentBytesUploader::default(),),},- channels_state: ChannelsRouterState::new(channels_service, (*entity_access_service).clone()),+ channels_state: ChannelsRouterState::new(+ channels_service,+ (*entity_access_service).clone(),+ ),call_state,call_webhook_state,call_internal_state,