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(email): return inbox photo from links API for the from-inbox selector (#3762)

gbirmanac09abc1a6f2
diff --git a/js/app/packages/block-email/component/EmailParticipants.tsx b/js/app/packages/block-email/component/EmailParticipants.tsx
index a71610e3cb..ddd31f7834 100644
--- a/js/app/packages/block-email/component/EmailParticipants.tsx
+++ b/js/app/packages/block-email/component/EmailParticipants.tsx
@@ -77,6 +77,7 @@ export function EmailParticipants() {
{(participant) => (
<EmailUserTooltip
recipient={{ email: participant.email, name: participant.name }}
+ photoUrl={participant.photoUrl}
>
<div
role="listitem"
@@ -87,6 +88,7 @@ export function EmailParticipants() {
isDeleted={false}
size="sm"
suppressClick
+ showTooltip={false}
/>
<span class="truncate max-w-32">
{getDisplayName(participant)}
diff --git a/js/app/packages/block-email/component/EmailUserTooltip.tsx b/js/app/packages/block-email/component/EmailUserTooltip.tsx
index bb517e6466..7f741dab85 100644
--- a/js/app/packages/block-email/component/EmailUserTooltip.tsx
+++ b/js/app/packages/block-email/component/EmailUserTooltip.tsx
@@ -12,6 +12,8 @@ interface EmailUserTooltipProps {
recipient?: Recipient | null;
children: JSX.Element;
bold?: boolean;
+ /** Fallback photo (e.g. a synced contact photo) when there's no Macro profile picture. */
+ photoUrl?: string;
}
export function EmailUserTooltip(props: EmailUserTooltipProps) {
@@ -33,6 +35,7 @@ export function EmailUserTooltip(props: EmailUserTooltipProps) {
? emailToMacroId(props.recipient.email)
: undefined
}
+ photoUrl={props.photoUrl}
onClose={() => setOpen(false)}
/>
}
diff --git a/js/app/packages/block-email/component/FromInboxSelector.tsx b/js/app/packages/block-email/component/FromInboxSelector.tsx
index 063a441996..4202e6e356 100644
--- a/js/app/packages/block-email/component/FromInboxSelector.tsx
+++ b/js/app/packages/block-email/component/FromInboxSelector.tsx
@@ -6,7 +6,11 @@ import Check from '@phosphor/check.svg';
import { Dropdown } from '@ui';
import { For, Show } from 'solid-js';
-type FromInbox = { id: string; email_address: string };
+type FromInbox = {
+ id: string;
+ email_address: string;
+ photo_url?: string | null;
+};
/** A single inbox: the account's user icon, name, and address. */
function FromInboxOption(props: { inbox: FromInbox }) {
@@ -15,6 +19,7 @@ function FromInboxOption(props: { inbox: FromInbox }) {
<>
<UserIcon
{...inboxIconProps(props.inbox.email_address)}
+ photoUrl={props.inbox.photo_url ?? undefined}
size="sm"
suppressClick
class="shrink-0"
diff --git a/js/app/packages/block-email/component/compose/ComposeContext.ts b/js/app/packages/block-email/component/compose/ComposeContext.ts
index b03220edcc..0c167fabba 100644
--- a/js/app/packages/block-email/component/compose/ComposeContext.ts
+++ b/js/app/packages/block-email/component/compose/ComposeContext.ts
@@ -68,7 +68,9 @@ export interface ComposeContextValue {
fromAddress?: Accessor<string | undefined>;
// From-inbox selection: the inboxes the user can send from, the active one,
// and a setter to change it.
- fromInboxes?: Accessor<{ id: string; email_address: string }[]>;
+ fromInboxes?: Accessor<
+ { id: string; email_address: string; photo_url?: string | null }[]
+ >;
selectedFromLinkId?: Accessor<string | undefined>;
onSelectFromLink?: (linkId: string) => void;
hasPaidAccess: Accessor<boolean>;
diff --git a/js/app/packages/entity/src/composed/list-entity/email.tsx b/js/app/packages/entity/src/composed/list-entity/email.tsx
index 2f48ebaddb..9918323c07 100644
--- a/js/app/packages/entity/src/composed/list-entity/email.tsx
+++ b/js/app/packages/entity/src/composed/list-entity/email.tsx
@@ -42,6 +42,7 @@ export function EmailInboxChip(props: { entity: EmailEntity; class?: string }) {
>
<UserIcon
{...inboxIconProps(link().email_address)}
+ photoUrl={link().photo_url ?? undefined}
size="sm"
suppressClick
class="shrink-0"
diff --git a/js/app/packages/service-clients/service-email/generated/schemas/index.ts b/js/app/packages/service-clients/service-email/generated/schemas/index.ts
index 4bfa012e37..1765357cca 100644
--- a/js/app/packages/service-clients/service-email/generated/schemas/index.ts
+++ b/js/app/packages/service-clients/service-email/generated/schemas/index.ts
@@ -186,6 +186,7 @@ export * from './labelName';
export * from './labelType';
export * from './labelTypeProperty';
export * from './link';
+export * from './linkPhotoUrl';
export * from './linkSignature';
export * from './listBlockedResponse';
export * from './listContactsResponse';
diff --git a/js/app/packages/service-clients/service-email/generated/schemas/link.ts b/js/app/packages/service-clients/service-email/generated/schemas/link.ts
index aa22e6d985..ae28108133 100644
--- a/js/app/packages/service-clients/service-email/generated/schemas/link.ts
+++ b/js/app/packages/service-clients/service-email/generated/schemas/link.ts
@@ -4,7 +4,7 @@
* email_service
* OpenAPI spec version: 0.1.0
*/
-
+import type { LinkPhotoUrl } from './linkPhotoUrl';
import type { LinkSignature } from './linkSignature';
import type { Settings } from './settings';
import type { SyncStatus } from './syncStatus';
@@ -17,6 +17,8 @@ export interface Link {
id: string;
is_sync_active: boolean;
macro_id: string;
+ /** The inbox's own profile photo (its self-contact's SFS photo), if synced. */
+ photo_url?: LinkPhotoUrl;
provider: UserProvider;
settings: Settings;
signature?: LinkSignature;
diff --git a/js/app/packages/service-clients/service-email/generated/schemas/linkPhotoUrl.ts b/js/app/packages/service-clients/service-email/generated/schemas/linkPhotoUrl.ts
new file mode 100644
index 0000000000..57dc2fc6a6
--- /dev/null
+++ b/js/app/packages/service-clients/service-email/generated/schemas/linkPhotoUrl.ts
@@ -0,0 +1,11 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * email_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * The inbox's own profile photo (its self-contact's SFS photo), if synced.
+ */
+export type LinkPhotoUrl = string | null;
diff --git a/js/app/packages/service-clients/service-email/openapi.json b/js/app/packages/service-clients/service-email/openapi.json
index 04ebe4a85d..a580f59217 100644
--- a/js/app/packages/service-clients/service-email/openapi.json
+++ b/js/app/packages/service-clients/service-email/openapi.json
@@ -4158,6 +4158,10 @@
"macro_id": {
"type": "string"
},
+ "photo_url": {
+ "type": ["string", "null"],
+ "description": "The inbox's own profile photo (its self-contact's SFS photo), if synced."
+ },
"provider": {
"$ref": "#/components/schemas/UserProvider"
},
diff --git a/rust/cloud-storage/email_service/src/api/email/links/list.rs b/rust/cloud-storage/email_service/src/api/email/links/list.rs
index 390a20d7ee..2375a0a5c6 100644
--- a/rust/cloud-storage/email_service/src/api/email/links/list.rs
+++ b/rust/cloud-storage/email_service/src/api/email/links/list.rs
@@ -93,6 +93,16 @@ pub async fn list_links_handler(
latest_job.map(|job| job.status),
);
+ // The inbox's own photo comes from its self-contact (synced from people/me).
+ let photo_url = email_db_client::contacts::get::fetch_contact_by_email(
+ &ctx.db,
+ link.id,
+ link.email_address.0.as_ref(),
+ )
+ .await
+ .map_err(ListLinksError::DatabaseError)?
+ .and_then(|contact| contact.photo_url);
+
let signature = if query_params.include_signature {
let access_token = fetch_gmail_access_token_from_link(
&link,
@@ -115,6 +125,7 @@ pub async fn list_links_handler(
signature,
api::settings::Settings::from(settings),
sync_status,
+ photo_url,
))
}
});
diff --git a/rust/cloud-storage/models_email/src/email/api/link.rs b/rust/cloud-storage/models_email/src/email/api/link.rs
index 103c5c7f50..b2c7998257 100644
--- a/rust/cloud-storage/models_email/src/email/api/link.rs
+++ b/rust/cloud-storage/models_email/src/email/api/link.rs
@@ -75,6 +75,8 @@ pub struct Link {
pub fusionauth_user_id: String,
#[schema(value_type = String)]
pub email_address: EmailStr<'static>,
+ /// The inbox's own profile photo (its self-contact's SFS photo), if synced.
+ pub photo_url: Option<String>,
pub provider: UserProvider,
pub is_sync_active: bool,
pub sync_status: SyncStatus,
@@ -90,12 +92,14 @@ impl Link {
signature: Option<String>,
settings: Settings,
sync_status: SyncStatus,
+ photo_url: Option<String>,
) -> Self {
Link {
id: source.id,
macro_id: source.macro_id,
fusionauth_user_id: source.fusionauth_user_id,
email_address: source.email_address,
+ photo_url,
provider: UserProvider::from(source.provider),
is_sync_active: source.is_sync_active,
sync_status,