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(notif): send pp url in ios notif payload (#1721)

Sean Aye92f48da3a1ec
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/channelInviteMetadataAllOf.ts b/js/app/packages/service-clients/service-notification/generated/schemas/channelInviteMetadataAllOf.ts
index 46db2dcfea..0368df339a 100644
--- a/js/app/packages/service-clients/service-notification/generated/schemas/channelInviteMetadataAllOf.ts
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/channelInviteMetadataAllOf.ts
@@ -4,7 +4,9 @@
* notification_service
* OpenAPI spec version: 0.1.0
*/
+import type { ChannelInviteMetadataAllOfSenderProfilePictureUrl } from './channelInviteMetadataAllOfSenderProfilePictureUrl';
export type ChannelInviteMetadataAllOf = {
invitedBy: string;
+ senderProfilePictureUrl?: ChannelInviteMetadataAllOfSenderProfilePictureUrl;
};
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/channelInviteMetadataAllOfSenderProfilePictureUrl.ts b/js/app/packages/service-clients/service-notification/generated/schemas/channelInviteMetadataAllOfSenderProfilePictureUrl.ts
new file mode 100644
index 0000000000..cb82d595e3
--- /dev/null
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/channelInviteMetadataAllOfSenderProfilePictureUrl.ts
@@ -0,0 +1,8 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * notification_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+export type ChannelInviteMetadataAllOfSenderProfilePictureUrl = string | null;
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/channelMentionMetadataAllOf.ts b/js/app/packages/service-clients/service-notification/generated/schemas/channelMentionMetadataAllOf.ts
index d2d58b1802..a181db5ddd 100644
--- a/js/app/packages/service-clients/service-notification/generated/schemas/channelMentionMetadataAllOf.ts
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/channelMentionMetadataAllOf.ts
@@ -4,6 +4,7 @@
* notification_service
* OpenAPI spec version: 0.1.0
*/
+import type { ChannelMentionMetadataAllOfSenderProfilePictureUrl } from './channelMentionMetadataAllOfSenderProfilePictureUrl';
import type { ChannelMentionMetadataAllOfThreadId } from './channelMentionMetadataAllOfThreadId';
export type ChannelMentionMetadataAllOf = {
@@ -11,6 +12,7 @@ export type ChannelMentionMetadataAllOf = {
messageContent: string;
/** The message you were mentioned in */
messageId: string;
+ senderProfilePictureUrl?: ChannelMentionMetadataAllOfSenderProfilePictureUrl;
/** the id of the thread */
threadId?: ChannelMentionMetadataAllOfThreadId;
};
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/channelMentionMetadataAllOfSenderProfilePictureUrl.ts b/js/app/packages/service-clients/service-notification/generated/schemas/channelMentionMetadataAllOfSenderProfilePictureUrl.ts
new file mode 100644
index 0000000000..7c470cfd9c
--- /dev/null
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/channelMentionMetadataAllOfSenderProfilePictureUrl.ts
@@ -0,0 +1,8 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * notification_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+export type ChannelMentionMetadataAllOfSenderProfilePictureUrl = string | null;
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/channelMessageSendMetadataAllOf.ts b/js/app/packages/service-clients/service-notification/generated/schemas/channelMessageSendMetadataAllOf.ts
index d7468c2fa0..fddc20ea17 100644
--- a/js/app/packages/service-clients/service-notification/generated/schemas/channelMessageSendMetadataAllOf.ts
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/channelMessageSendMetadataAllOf.ts
@@ -4,6 +4,7 @@
* notification_service
* OpenAPI spec version: 0.1.0
*/
+import type { ChannelMessageSendMetadataAllOfSenderProfilePictureUrl } from './channelMessageSendMetadataAllOfSenderProfilePictureUrl';
export type ChannelMessageSendMetadataAllOf = {
/** The content of the message */
@@ -12,4 +13,5 @@ export type ChannelMessageSendMetadataAllOf = {
messageId: string;
/** The user who sent the message */
sender: string;
+ senderProfilePictureUrl?: ChannelMessageSendMetadataAllOfSenderProfilePictureUrl;
};
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/channelMessageSendMetadataAllOfSenderProfilePictureUrl.ts b/js/app/packages/service-clients/service-notification/generated/schemas/channelMessageSendMetadataAllOfSenderProfilePictureUrl.ts
new file mode 100644
index 0000000000..5ac456cae1
--- /dev/null
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/channelMessageSendMetadataAllOfSenderProfilePictureUrl.ts
@@ -0,0 +1,10 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * notification_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+export type ChannelMessageSendMetadataAllOfSenderProfilePictureUrl =
+ | string
+ | null;
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/channelReplyMetadataAllOf.ts b/js/app/packages/service-clients/service-notification/generated/schemas/channelReplyMetadataAllOf.ts
index 80b0887f05..f8c13607ad 100644
--- a/js/app/packages/service-clients/service-notification/generated/schemas/channelReplyMetadataAllOf.ts
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/channelReplyMetadataAllOf.ts
@@ -4,6 +4,7 @@
* notification_service
* OpenAPI spec version: 0.1.0
*/
+import type { ChannelReplyMetadataAllOfSenderProfilePictureUrl } from './channelReplyMetadataAllOfSenderProfilePictureUrl';
import type { ChannelReplyMetadataAllOfThreadParentSenderId } from './channelReplyMetadataAllOfThreadParentSenderId';
export type ChannelReplyMetadataAllOf = {
@@ -11,6 +12,7 @@ export type ChannelReplyMetadataAllOf = {
messageContent: string;
/** The id of the new message */
messageId: string;
+ senderProfilePictureUrl?: ChannelReplyMetadataAllOfSenderProfilePictureUrl;
/** The id of the thread that has the reply */
threadId: string;
/** The user who sent the root message of the thread */
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/channelReplyMetadataAllOfSenderProfilePictureUrl.ts b/js/app/packages/service-clients/service-notification/generated/schemas/channelReplyMetadataAllOfSenderProfilePictureUrl.ts
new file mode 100644
index 0000000000..e7a29b892d
--- /dev/null
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/channelReplyMetadataAllOfSenderProfilePictureUrl.ts
@@ -0,0 +1,8 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * notification_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+export type ChannelReplyMetadataAllOfSenderProfilePictureUrl = string | null;
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/documentMentionMetadata.ts b/js/app/packages/service-clients/service-notification/generated/schemas/documentMentionMetadata.ts
index f8afe6496b..0846d39af7 100644
--- a/js/app/packages/service-clients/service-notification/generated/schemas/documentMentionMetadata.ts
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/documentMentionMetadata.ts
@@ -5,6 +5,7 @@
* OpenAPI spec version: 0.1.0
*/
import type { DocumentMentionMetadataFileType } from './documentMentionMetadataFileType';
+import type { DocumentMentionMetadataSenderProfilePictureUrl } from './documentMentionMetadataSenderProfilePictureUrl';
/**
* Someone mentioned a document in a channel
@@ -16,4 +17,5 @@ export interface DocumentMentionMetadata {
fileType?: DocumentMentionMetadataFileType;
/** The owner of the document */
owner: string;
+ senderProfilePictureUrl?: DocumentMentionMetadataSenderProfilePictureUrl;
}
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/documentMentionMetadataSenderProfilePictureUrl.ts b/js/app/packages/service-clients/service-notification/generated/schemas/documentMentionMetadataSenderProfilePictureUrl.ts
new file mode 100644
index 0000000000..4c5236cbad
--- /dev/null
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/documentMentionMetadataSenderProfilePictureUrl.ts
@@ -0,0 +1,8 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * notification_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+export type DocumentMentionMetadataSenderProfilePictureUrl = string | null;
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/index.ts b/js/app/packages/service-clients/service-notification/generated/schemas/index.ts
index 28c3bf20ed..4145b0d127 100644
--- a/js/app/packages/service-clients/service-notification/generated/schemas/index.ts
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/index.ts
@@ -17,13 +17,17 @@ export * from './bulkGetByEventItemIdsRequest';
export * from './bulkGetTypedNotificationsByEventItemIdsParams';
export * from './channelInviteMetadata';
export * from './channelInviteMetadataAllOf';
+export * from './channelInviteMetadataAllOfSenderProfilePictureUrl';
export * from './channelMentionMetadata';
export * from './channelMentionMetadataAllOf';
+export * from './channelMentionMetadataAllOfSenderProfilePictureUrl';
export * from './channelMentionMetadataAllOfThreadId';
export * from './channelMessageSendMetadata';
export * from './channelMessageSendMetadataAllOf';
+export * from './channelMessageSendMetadataAllOfSenderProfilePictureUrl';
export * from './channelReplyMetadata';
export * from './channelReplyMetadataAllOf';
+export * from './channelReplyMetadataAllOfSenderProfilePictureUrl';
export * from './channelReplyMetadataAllOfThreadParentSenderId';
export * from './channelType';
export * from './commonChannelMetadata';
@@ -33,6 +37,7 @@ export * from './deviceRequest';
export * from './deviceType';
export * from './documentMentionMetadata';
export * from './documentMentionMetadataFileType';
+export * from './documentMentionMetadataSenderProfilePictureUrl';
export * from './emptyResponse';
export * from './entity';
export * from './entityType';
@@ -48,6 +53,7 @@ export * from './itemSharedMetadataPermissionLevel';
export * from './listTypedNotificationsParams';
export * from './mentionedInDocumentCommentMetadata';
export * from './mentionedInDocumentCommentMetadataFileType';
+export * from './mentionedInDocumentCommentMetadataSenderProfilePictureUrl';
export * from './newEmailMetadata';
export * from './newEmailMetadataSender';
export * from './notifEvent';
@@ -74,7 +80,9 @@ export * from './notifEventOneOfThreeTag';
export * from './notificationBulkRequest';
export * from './notificationServiceApiVersion';
export * from './pushNotificationData';
+export * from './pushNotificationDataSenderProfilePictureUrl';
export * from './taskAssignedMetadata';
+export * from './taskAssignedMetadataSenderProfilePictureUrl';
export * from './taskAssignedMetadataTaskName';
export * from './unsubscribeItemPathParams';
export * from './userUnsubscribe';
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/mentionedInDocumentCommentMetadata.ts b/js/app/packages/service-clients/service-notification/generated/schemas/mentionedInDocumentCommentMetadata.ts
index 518908a8a5..7b3ef0e767 100644
--- a/js/app/packages/service-clients/service-notification/generated/schemas/mentionedInDocumentCommentMetadata.ts
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/mentionedInDocumentCommentMetadata.ts
@@ -5,6 +5,7 @@
* OpenAPI spec version: 0.1.0
*/
import type { MentionedInDocumentCommentMetadataFileType } from './mentionedInDocumentCommentMetadataFileType';
+import type { MentionedInDocumentCommentMetadataSenderProfilePictureUrl } from './mentionedInDocumentCommentMetadataSenderProfilePictureUrl';
/**
* Notification sent when a user is mentioned in a document comment.
@@ -20,6 +21,7 @@ export interface MentionedInDocumentCommentMetadata {
mentionId: string;
/** The owner of the document. */
owner: string;
+ senderProfilePictureUrl?: MentionedInDocumentCommentMetadataSenderProfilePictureUrl;
/** the text of the comment */
text: string;
/** the thread id */
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/mentionedInDocumentCommentMetadataSenderProfilePictureUrl.ts b/js/app/packages/service-clients/service-notification/generated/schemas/mentionedInDocumentCommentMetadataSenderProfilePictureUrl.ts
new file mode 100644
index 0000000000..1620839f95
--- /dev/null
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/mentionedInDocumentCommentMetadataSenderProfilePictureUrl.ts
@@ -0,0 +1,10 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * notification_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+export type MentionedInDocumentCommentMetadataSenderProfilePictureUrl =
+ | string
+ | null;
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/pushNotificationData.ts b/js/app/packages/service-clients/service-notification/generated/schemas/pushNotificationData.ts
index 99d807cf10..78ead8a759 100644
--- a/js/app/packages/service-clients/service-notification/generated/schemas/pushNotificationData.ts
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/pushNotificationData.ts
@@ -4,8 +4,12 @@
* notification_service
* OpenAPI spec version: 0.1.0
*/
+import type { PushNotificationDataSenderProfilePictureUrl } from './pushNotificationDataSenderProfilePictureUrl';
export interface PushNotificationData {
/** The id of the notification record (UserNotification.id) */
notificationId: string;
+ /** The sender's profile picture URL, used by the Notification Service Extension
+to download and attach as a rich notification image. */
+ senderProfilePictureUrl?: PushNotificationDataSenderProfilePictureUrl;
}
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/pushNotificationDataSenderProfilePictureUrl.ts b/js/app/packages/service-clients/service-notification/generated/schemas/pushNotificationDataSenderProfilePictureUrl.ts
new file mode 100644
index 0000000000..f1536c7d47
--- /dev/null
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/pushNotificationDataSenderProfilePictureUrl.ts
@@ -0,0 +1,12 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * notification_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * The sender's profile picture URL, used by the Notification Service Extension
+to download and attach as a rich notification image.
+ */
+export type PushNotificationDataSenderProfilePictureUrl = string | null;
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/taskAssignedMetadata.ts b/js/app/packages/service-clients/service-notification/generated/schemas/taskAssignedMetadata.ts
index 790bd4f870..3892ebc41a 100644
--- a/js/app/packages/service-clients/service-notification/generated/schemas/taskAssignedMetadata.ts
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/taskAssignedMetadata.ts
@@ -4,6 +4,7 @@
* notification_service
* OpenAPI spec version: 0.1.0
*/
+import type { TaskAssignedMetadataSenderProfilePictureUrl } from './taskAssignedMetadataSenderProfilePictureUrl';
import type { TaskAssignedMetadataTaskName } from './taskAssignedMetadataTaskName';
/**
@@ -12,6 +13,7 @@ import type { TaskAssignedMetadataTaskName } from './taskAssignedMetadataTaskNam
export interface TaskAssignedMetadata {
/** The user who assigned the task */
assignedBy: string;
+ senderProfilePictureUrl?: TaskAssignedMetadataSenderProfilePictureUrl;
/** The unique identifier of the task */
taskId: string;
/** The name of the task (optional) */
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/taskAssignedMetadataSenderProfilePictureUrl.ts b/js/app/packages/service-clients/service-notification/generated/schemas/taskAssignedMetadataSenderProfilePictureUrl.ts
new file mode 100644
index 0000000000..0cde27be07
--- /dev/null
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/taskAssignedMetadataSenderProfilePictureUrl.ts
@@ -0,0 +1,8 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * notification_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+export type TaskAssignedMetadataSenderProfilePictureUrl = string | null;
diff --git a/js/app/packages/service-clients/service-notification/openapi.json b/js/app/packages/service-clients/service-notification/openapi.json
index 27cb72642e..c5ce1ee422 100644
--- a/js/app/packages/service-clients/service-notification/openapi.json
+++ b/js/app/packages/service-clients/service-notification/openapi.json
@@ -1059,6 +1059,9 @@
"properties": {
"invitedBy": {
"type": "string"
+ },
+ "senderProfilePictureUrl": {
+ "type": ["string", "null"]
}
}
}
@@ -1082,6 +1085,9 @@
"type": "string",
"description": "The message you were mentioned in"
},
+ "senderProfilePictureUrl": {
+ "type": ["string", "null"]
+ },
"threadId": {
"type": ["string", "null"],
"description": "the id of the thread"
@@ -1110,6 +1116,9 @@
"sender": {
"type": "string",
"description": "The user who sent the message"
+ },
+ "senderProfilePictureUrl": {
+ "type": ["string", "null"]
}
}
}
@@ -1132,6 +1141,9 @@
"type": "string",
"description": "The id of the new message"
},
+ "senderProfilePictureUrl": {
+ "type": ["string", "null"]
+ },
"threadId": {
"type": "string",
"description": "The id of the thread that has the reply"
@@ -1222,6 +1234,9 @@
"owner": {
"type": "string",
"description": "The owner of the document"
+ },
+ "senderProfilePictureUrl": {
+ "type": ["string", "null"]
}
}
},
@@ -1375,6 +1390,9 @@
"type": "string",
"description": "The owner of the document."
},
+ "senderProfilePictureUrl": {
+ "type": ["string", "null"]
+ },
"text": {
"type": "string",
"description": "the text of the comment"
@@ -1589,6 +1607,10 @@
"type": "string",
"format": "uuid",
"description": "The id of the notification record (UserNotification.id)"
+ },
+ "senderProfilePictureUrl": {
+ "type": ["string", "null"],
+ "description": "The sender's profile picture URL, used by the Notification Service Extension\nto download and attach as a rich notification image."
}
}
},
@@ -1601,6 +1623,9 @@
"type": "string",
"description": "The user who assigned the task"
},
+ "senderProfilePictureUrl": {
+ "type": ["string", "null"]
+ },
"taskId": {
"type": "string",
"description": "The unique identifier of the task"
diff --git a/rust/cloud-storage/comms_service/src/notification.rs b/rust/cloud-storage/comms_service/src/notification.rs
index e374296f42..28a87cd94b 100644
--- a/rust/cloud-storage/comms_service/src/notification.rs
+++ b/rust/cloud-storage/comms_service/src/notification.rs
@@ -86,6 +86,7 @@ impl<'a> ChannelInviteEvent<'a> {
NotifEvent::ChannelInvite(ChannelInviteMetadata {
invited_by: self.invited_by_user_id.clone(),
common: self.common.clone(),
+ sender_profile_picture_url: None,
}),
));
}
@@ -111,6 +112,7 @@ impl ChannelMessageEvent<'_> {
message_id: self.message.id.to_string(),
thread_id: self.message.thread_id.map(|t| t.to_string()),
common: self.channel_metadata.clone(),
+ sender_profile_picture_url: None,
}),
));
}
@@ -130,6 +132,7 @@ impl ChannelMessageEvent<'_> {
document_name: mention.item_name.clone(),
owner: mention.item_owner.clone(),
file_type: mention.file_type.clone(),
+ sender_profile_picture_url: None,
}),
));
}
@@ -164,6 +167,7 @@ impl ChannelMessageEvent<'_> {
message_content: self.message.content.clone(),
thread_parent_sender_id: self.thread_parent_sender_id.clone(),
common: self.channel_metadata.clone(),
+ sender_profile_picture_url: None,
}),
));
} else {
@@ -179,6 +183,7 @@ impl ChannelMessageEvent<'_> {
NotifEvent::ChannelInvite(ChannelInviteMetadata {
invited_by: self.message.sender_id.clone(),
common: self.channel_metadata.clone(),
+ sender_profile_picture_url: None,
}),
));
}
@@ -193,6 +198,7 @@ impl ChannelMessageEvent<'_> {
sender: self.message.sender_id.clone(),
message_content: self.message.content.to_string(),
common: self.channel_metadata.clone(),
+ sender_profile_picture_url: None,
}),
));
}
@@ -301,6 +307,9 @@ pub async fn dispatch_notifications_for_invite(
recipient_user_ids: Vec<String>,
common: CommonChannelMetadata,
) -> anyhow::Result<()> {
+ let sender_profile_picture_url =
+ get_sender_profile_picture_url(&api_context.db, invited_by_user_id).await;
+
let event = ChannelInviteEvent {
channel_id,
invited_by_user_id,
@@ -308,7 +317,13 @@ pub async fn dispatch_notifications_for_invite(
common: &common,
};
- let notifications = event.generate_notifications();
+ let mut notifications = event.generate_notifications();
+ for n in &mut notifications {
+ set_sender_profile_picture(
+ &mut n.notification_event,
+ sender_profile_picture_url.clone(),
+ );
+ }
for notification in notifications {
send_notification_queue_message(&*api_context.notification_ingress_service, notification)
@@ -381,7 +396,16 @@ pub async fn dispatch_notifications_for_message(
thread_parent_sender_id,
};
- let notifications = channel_message_event.generate_notifications();
+ let sender_profile_picture_url =
+ get_sender_profile_picture_url(&api_context.db, &message.sender_id).await;
+
+ let mut notifications = channel_message_event.generate_notifications();
+ for n in &mut notifications {
+ set_sender_profile_picture(
+ &mut n.notification_event,
+ sender_profile_picture_url.clone(),
+ );
+ }
for notification in notifications {
send_notification_queue_message(&*api_context.notification_ingress_service, notification)
@@ -391,6 +415,30 @@ pub async fn dispatch_notifications_for_message(
Ok(())
}
+async fn get_sender_profile_picture_url(
+ db: &sqlx::PgPool,
+ sender_id: &MacroUserIdStr<'_>,
+) -> Option<String> {
+ macro_db_client::user::update_profile_picture::get_profile_pictures(
+ db,
+ &vec![sender_id.as_ref().to_string()],
+ )
+ .await
+ .ok()
+ .and_then(|pics| pics.pictures.into_iter().next().map(|p| p.url))
+}
+
+fn set_sender_profile_picture(event: &mut NotifEvent, url: Option<String>) {
+ match event {
+ NotifEvent::ChannelInvite(m) => m.sender_profile_picture_url = url,
+ NotifEvent::ChannelMessageSend(m) => m.sender_profile_picture_url = url,
+ NotifEvent::ChannelMention(m) => m.sender_profile_picture_url = url,
+ NotifEvent::ChannelMessageReply(m) => m.sender_profile_picture_url = url,
+ NotifEvent::DocumentMention(m) => m.sender_profile_picture_url = url,
+ _ => {}
+ }
+}
+
#[cfg(test)]
mod tests {
use super::*;
diff --git a/rust/cloud-storage/document_storage_service/src/api/annotations/create_comment.rs b/rust/cloud-storage/document_storage_service/src/api/annotations/create_comment.rs
index 61582e605b..c1b0507309 100644
--- a/rust/cloud-storage/document_storage_service/src/api/annotations/create_comment.rs
+++ b/rust/cloud-storage/document_storage_service/src/api/annotations/create_comment.rs
@@ -71,6 +71,15 @@ pub async fn create_comment_handler(
if let Some(Mentions { users, mention_id }) = &req.mentions
&& let Some(comment) = res.comment_thread.comments.first()
{
+ let sender_profile_picture_url =
+ macro_db_client::user::update_profile_picture::get_profile_pictures(
+ &db,
+ &vec![user_id.clone()],
+ )
+ .await
+ .ok()
+ .and_then(|pics| pics.pictures.into_iter().next().map(|p| p.url));
+
let request = build_mention_notif(
req.text,
comment,
@@ -82,6 +91,7 @@ pub async fn create_comment_handler(
user_id.clone().try_into().ok(),
document_id.to_string(),
mention_id,
+ sender_profile_picture_url,
)
.into_request()
.with_apns()
diff --git a/rust/cloud-storage/document_storage_service/src/api/annotations/edit_comment.rs b/rust/cloud-storage/document_storage_service/src/api/annotations/edit_comment.rs
index 5c0cf9ce2c..91b9bd7af0 100644
--- a/rust/cloud-storage/document_storage_service/src/api/annotations/edit_comment.rs
+++ b/rust/cloud-storage/document_storage_service/src/api/annotations/edit_comment.rs
@@ -56,6 +56,15 @@ pub async fn edit_comment_handler(
match edit_document_comment(&db, comment_id, &user_id, &req).await {
Ok(res) => {
if let Some(Mentions { users, mention_id }) = req.mentions {
+ let sender_profile_picture_url =
+ macro_db_client::user::update_profile_picture::get_profile_pictures(
+ &db,
+ &vec![user_id.clone()],
+ )
+ .await
+ .ok()
+ .and_then(|pics| pics.pictures.into_iter().next().map(|p| p.url));
+
let request = build_mention_notif(
req.text.clone().unwrap_or_else(|| "".to_string()),
&res.comment,
@@ -67,6 +76,7 @@ pub async fn edit_comment_handler(
user_id.clone().try_into().ok(),
res.document_id.to_string(),
&mention_id,
+ sender_profile_picture_url,
)
.into_request()
.with_apns()
diff --git a/rust/cloud-storage/document_storage_service/src/api/annotations/mod.rs b/rust/cloud-storage/document_storage_service/src/api/annotations/mod.rs
index 9f845b232a..2ee01c5f81 100644
--- a/rust/cloud-storage/document_storage_service/src/api/annotations/mod.rs
+++ b/rust/cloud-storage/document_storage_service/src/api/annotations/mod.rs
@@ -134,6 +134,7 @@ fn build_mention_notif<'a>(
sender_id: Option<MacroUserIdStr<'static>>,
document_id: String,
mention_id: &str,
+ sender_profile_picture_url: Option<String>,
) -> SendNotificationRequestBuilder<'a, MentionedInDocumentCommentMetadata> {
let notification = MentionedInDocumentCommentMetadata {
document_name,
@@ -143,6 +144,7 @@ fn build_mention_notif<'a>(
comment_id: comment.comment_id,
thread_id,
text,
+ sender_profile_picture_url,
};
let recipient_ids: HashSet<MacroUserIdStr<'a>> = mentions
@@ -172,6 +174,7 @@ mod tests {
thread_id: 42,
comment_id: 99,
text: "yy".to_string(),
+ sender_profile_picture_url: None,
};
let res = serde_json::to_string(&m).unwrap();
assert!(res.contains(r#"mentionId":"xxx""#));
diff --git a/rust/cloud-storage/model_notifications/src/metadata.rs b/rust/cloud-storage/model_notifications/src/metadata.rs
index 21505a1cbb..517a67ffc8 100644
--- a/rust/cloud-storage/model_notifications/src/metadata.rs
+++ b/rust/cloud-storage/model_notifications/src/metadata.rs
@@ -66,6 +66,8 @@ pub struct ChannelInviteMetadata {
pub invited_by: MacroUserIdStr<'static>,
#[serde(flatten)]
pub common: CommonChannelMetadata,
+ #[serde(default)]
+ pub sender_profile_picture_url: Option<String>,
}
#[derive(Serialize, Deserialize, Debug, Clone, ToSchema)]
@@ -85,6 +87,8 @@ pub struct ChannelMessageSendMetadata {
pub message_id: String,
#[serde(flatten)]
pub common: CommonChannelMetadata,
+ #[serde(default)]
+ pub sender_profile_picture_url: Option<String>,
}
/// Metadata for when a item is shared with a user
@@ -143,6 +147,8 @@ pub struct ChannelMentionMetadata {
pub thread_id: Option<String>,
#[serde(flatten)]
pub common: CommonChannelMetadata,
+ #[serde(default)]
+ pub sender_profile_picture_url: Option<String>,
}
#[derive(Serialize, Deserialize, Debug, Clone, ToSchema)]
@@ -168,6 +174,8 @@ pub struct ChannelReplyMetadata {
pub thread_parent_sender_id: Option<MacroUserIdStr<'static>>,
#[serde(flatten)]
pub common: CommonChannelMetadata,
+ #[serde(default)]
+ pub sender_profile_picture_url: Option<String>,
}
/// Someone mentioned a document in a channel
@@ -183,6 +191,8 @@ pub struct DocumentMentionMetadata {
/// The file type of the document
#[serde(alias = "file_type")]
pub file_type: Option<String>,
+ #[serde(default)]
+ pub sender_profile_picture_url: Option<String>,
}
impl From<DocumentMentionMetadata> for serde_json::Value {
@@ -249,6 +259,8 @@ pub struct TaskAssignedMetadata {
#[serde(alias = "assigned_by")]
#[schema(value_type = String)]
pub assigned_by: MacroUserIdStr<'static>,
+ #[serde(default)]
+ pub sender_profile_picture_url: Option<String>,
}
// Plain text formatter for converting XML message content to plain text for APNS payloads.
@@ -312,8 +324,14 @@ fn parse_message_plain_text(content: &str) -> Option<String> {
fn alert_apns(
title: String,
body: String,
- data: PushNotificationData,
+ notification_id: Uuid,
+ sender_profile_picture_url: Option<String>,
) -> APNSPushNotification<PushNotificationData> {
+ let mutable_content = if sender_profile_picture_url.is_some() {
+ Some(1)
+ } else {
+ None
+ };
APNSPushNotification {
aps: Aps {
alert: Some(notification::domain::models::apple::Alert::Dictionary(
@@ -323,9 +341,13 @@ fn alert_apns(
..Default::default()
},
)),
+ mutable_content,
..Default::default()
},
- push_notification_data: data,
+ push_notification_data: PushNotificationData {
+ notification_id,
+ sender_profile_picture_url,
+ },
}
}
@@ -346,7 +368,8 @@ impl NotificationExtIos for ChannelInviteMetadata {
Some(alert_apns(
format!("{} Invite", self.common.channel_name),
format!("{} invited you to join the channel", self.invited_by),
- PushNotificationData { notification_id },
+ notification_id,
+ self.sender_profile_picture_url,
))
}
}
@@ -366,7 +389,8 @@ impl NotificationExtIos for AiResponseMetadata {
Some(alert_apns(
"Ai Response".into(),
self.summary,
- PushNotificationData { notification_id },
+ notification_id,
+ None,
))
}
}
@@ -396,7 +420,8 @@ impl NotificationExtIos for ChannelMessageSendMetadata {
Some(alert_apns(
title,
body,
- PushNotificationData { notification_id },
+ notification_id,
+ self.sender_profile_picture_url,
))
}
}
@@ -429,7 +454,8 @@ impl NotificationExtIos for ChannelMentionMetadata {
Some(alert_apns(
title,
body,
- PushNotificationData { notification_id },
+ notification_id,
+ self.sender_profile_picture_url,
))
}
}
@@ -453,7 +479,8 @@ impl NotificationExtIos for ChannelReplyMetadata {
Some(alert_apns(
title,
body,
- PushNotificationData { notification_id },
+ notification_id,
+ self.sender_profile_picture_url,
))
}
}
@@ -482,7 +509,8 @@ impl NotificationExtIos for DocumentMentionMetadata {
Some(alert_apns(
title,
body,
- PushNotificationData { notification_id },
+ notification_id,
+ self.sender_profile_picture_url,
))
}
}
@@ -514,7 +542,8 @@ impl NotificationExtIos for TaskAssignedMetadata {
Some(alert_apns(
title,
body,
- PushNotificationData { notification_id },
+ notification_id,
+ self.sender_profile_picture_url,
))
}
}
@@ -538,6 +567,8 @@ pub struct MentionedInDocumentCommentMetadata {
pub thread_id: i64,
/// the text of the comment
pub text: String,
+ #[serde(default)]
+ pub sender_profile_picture_url: Option<String>,
}
impl Notification for MentionedInDocumentCommentMetadata {
@@ -566,18 +597,11 @@ impl NotificationExtIos for MentionedInDocumentCommentMetadata {
self.document_name, file_type_str
);
- Some(APNSPushNotification {
- aps: Aps {
- alert: Some(notification::domain::models::apple::Alert::Dictionary(
- AlertDictionary {
- title: Some(title),
- body: Some(body),
- ..Default::default()
- },
- )),
- ..Default::default()
- },
- push_notification_data: PushNotificationData { notification_id },
- })
+ Some(alert_apns(
+ title,
+ body,
+ notification_id,
+ self.sender_profile_picture_url,
+ ))
}
}
diff --git a/rust/cloud-storage/notification/src/domain/models/apple.rs b/rust/cloud-storage/notification/src/domain/models/apple.rs
index 182b062ef0..7c3584cccb 100644
--- a/rust/cloud-storage/notification/src/domain/models/apple.rs
+++ b/rust/cloud-storage/notification/src/domain/models/apple.rs
@@ -163,4 +163,9 @@ pub struct APNSPushNotification<T> {
pub struct PushNotificationData {
/// The id of the notification record (UserNotification.id)
pub notification_id: Uuid,
+ /// The sender's profile picture URL, used by the Notification Service Extension
+ /// to download and attach as a rich notification image.
+ #[serde(skip_serializing_if = "Option::is_none")]
+ #[serde(default)]
+ pub sender_profile_picture_url: Option<String>,
}
diff --git a/rust/cloud-storage/notification_sandbox/src/main.rs b/rust/cloud-storage/notification_sandbox/src/main.rs
index da5d72dde8..ac9e04e179 100644
--- a/rust/cloud-storage/notification_sandbox/src/main.rs
+++ b/rust/cloud-storage/notification_sandbox/src/main.rs
@@ -307,6 +307,7 @@ async fn run_notification_cycle<I: NotificationIngress>(
channel_type: model_notifications::ChannelType::Public,
channel_name: "test-channel-name".to_string(),
},
+ sender_profile_picture_url: None,
},
sender_id: None,
recipient_ids: HashSet::from([user_id.copied()]),
diff --git a/rust/cloud-storage/notification_service/src/api/user_notification/test.rs b/rust/cloud-storage/notification_service/src/api/user_notification/test.rs
index 20ba042ce4..4a1e38f888 100644
--- a/rust/cloud-storage/notification_service/src/api/user_notification/test.rs
+++ b/rust/cloud-storage/notification_service/src/api/user_notification/test.rs
@@ -215,6 +215,7 @@ fn api_user_notification_and_conn_gateway_inner_notif_metadata_serialize_identic
channel_type: model_notifications::ChannelType::Public,
channel_name: "general".to_string(),
},
+ sender_profile_picture_url: None,
};
// Create ApiUserNotification (used by HTTP API)
@@ -292,6 +293,7 @@ fn conn_gateway_inner_val_has_identical_serialization() {
channel_type: model_notifications::ChannelType::Public,
channel_name: "my channel".to_string(),
},
+ sender_profile_picture_url: None,
};
// TaggedContent<T> is what ConnGatewayInnerNotif uses for notification_metadata
diff --git a/rust/cloud-storage/notification_service/src/notification/send/push/mod.rs b/rust/cloud-storage/notification_service/src/notification/send/push/mod.rs
index cff961a392..e5364fda11 100644
--- a/rust/cloud-storage/notification_service/src/notification/send/push/mod.rs
+++ b/rust/cloud-storage/notification_service/src/notification/send/push/mod.rs
@@ -7,12 +7,18 @@ use uuid::Uuid;
pub struct PushNotificationData {
/// The id of the notification record (UserNotification.id)
pub notification_id: Uuid,
+ /// The sender's profile picture URL, used by the Notification Service Extension
+ /// to download and attach as a rich notification image.
+ #[serde(skip_serializing_if = "Option::is_none")]
+ #[serde(default)]
+ pub sender_profile_picture_url: Option<String>,
}
impl PushNotificationData {
pub fn new_from_inner(val: notification::domain::models::apple::PushNotificationData) -> Self {
Self {
notification_id: val.notification_id,
+ sender_profile_picture_url: val.sender_profile_picture_url,
}
}
}
diff --git a/rust/cloud-storage/properties/src/domain/ports.rs b/rust/cloud-storage/properties/src/domain/ports.rs
index 100c6ad695..06bd57cc46 100644
--- a/rust/cloud-storage/properties/src/domain/ports.rs
+++ b/rust/cloud-storage/properties/src/domain/ports.rs
@@ -97,6 +97,13 @@ pub trait PropertiesRepo: Send + Sync + 'static {
&self,
id: &str,
) -> impl Future<Output = Result<Option<String>, Self::Err>> + Send;
+
+ /// Get the profile picture URL for a user.
+ /// Returns `None` if the user doesn't exist or has no profile picture.
+ fn get_user_profile_picture(
+ &self,
+ user_id: &str,
+ ) -> impl Future<Output = Result<Option<String>, Self::Err>> + Send;
}
/// Permission service trait for entity access control.
diff --git a/rust/cloud-storage/properties/src/domain/service_impl/task_properties.rs b/rust/cloud-storage/properties/src/domain/service_impl/task_properties.rs
index 2e23af1767..b5c91a7e1e 100644
--- a/rust/cloud-storage/properties/src/domain/service_impl/task_properties.rs
+++ b/rust/cloud-storage/properties/src/domain/service_impl/task_properties.rs
@@ -193,6 +193,13 @@ where
let notification_entity =
model_entity::EntityType::Document.with_entity_string(task_id.to_string());
+ let sender_profile_picture_url = self
+ .repository
+ .get_user_profile_picture(assigned_by_user_id)
+ .await
+ .ok()
+ .flatten();
+
let notification_futures: Vec<_> = recipient_ids
.iter()
.map(|recipient_id| {
@@ -200,6 +207,7 @@ where
task_id: task_id.to_string(),
task_name: task_name.clone(),
assigned_by: assigned_by.clone(),
+ sender_profile_picture_url: sender_profile_picture_url.clone(),
};
let request = SendNotificationRequestBuilder {
diff --git a/rust/cloud-storage/properties/src/domain/test.rs b/rust/cloud-storage/properties/src/domain/test.rs
index 4d647b8d36..fe3569c990 100644
--- a/rust/cloud-storage/properties/src/domain/test.rs
+++ b/rust/cloud-storage/properties/src/domain/test.rs
@@ -522,7 +522,7 @@ async fn check_notifications(test_case: NotificationTestCase) {
}
});
- // Mock: get task name (only if we expect notifications)
+ // Mock: get task name and profile picture (only if we expect notifications)
if test_case.expected_notification_count > 0 {
let task_id_clone = task_id;
let task_name_result = task_name.clone();
@@ -532,6 +532,8 @@ async fn check_notifications(test_case: NotificationTestCase) {
let name = task_name_result.clone();
Box::pin(async move { Ok(name) })
});
+ repo.expect_get_user_profile_picture()
+ .returning(|_| Box::pin(async { Ok(None) }));
}
// Mock: send notifications
@@ -696,6 +698,10 @@ async fn test_handle_task_assignees_property_calls_both_handlers() {
repo.expect_get_document_name()
.returning(|_| Box::pin(async { Ok(Some("Test Task".to_string())) }));
+ // Mock: get sender profile picture
+ repo.expect_get_user_profile_picture()
+ .returning(|_| Box::pin(async { Ok(None) }));
+
// Mock: permissions should be granted to all assignees
let entity_id_clone = entity_id.clone();
perm_service
diff --git a/rust/cloud-storage/properties/src/outbound/properties_pg_repo.rs b/rust/cloud-storage/properties/src/outbound/properties_pg_repo.rs
index 580442e662..2626bd11ac 100644
--- a/rust/cloud-storage/properties/src/outbound/properties_pg_repo.rs
+++ b/rust/cloud-storage/properties/src/outbound/properties_pg_repo.rs
@@ -149,4 +149,14 @@ impl PropertiesRepo for PropertiesPgRepo {
}
}
}
+
+ #[tracing::instrument(skip(self))]
+ async fn get_user_profile_picture(&self, user_id: &str) -> Result<Option<String>, Self::Err> {
+ let pics = macro_db_client::user::update_profile_picture::get_profile_pictures(
+ &self.pool,
+ &vec![user_id.to_string()],
+ )
+ .await?;
+ Ok(pics.pictures.into_iter().next().map(|p| p.url))
+ }
}