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.

fix(email-service): Make email signature optional in /links endpoint (#687)

Evan Hutnik0060c7825e3b
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 9888b0a14e..4f8f973247 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
@@ -1,6 +1,6 @@
use crate::api::context::ApiContext;
use crate::util::gmail::auth::fetch_gmail_access_token_from_link;
-use axum::extract::State;
+use axum::extract::{Query, State};
use axum::http::StatusCode;
use axum::response::{IntoResponse, Response};
use axum::{Extension, Json};
@@ -41,6 +41,13 @@ pub struct ListLinksResponse {
pub links: Vec<api::link::Link>,
}
+#[derive(serde::Deserialize, Debug, ToSchema)]
+pub struct QueryParams {
+ /// if we should include the user's gmail signature in the response. hits gmail api
+ #[serde(default)]
+ pub include_signature: bool,
+}
+
/// List all links belonging to the user.
#[utoipa::path(
get,
@@ -58,6 +65,7 @@ pub struct ListLinksResponse {
pub async fn list_links_handler(
State(ctx): State<ApiContext>,
user_context: Extension<UserContext>,
+ Query(query_params): Query<QueryParams>,
) -> Result<Response, ListLinksError> {
let links = email_db_client::links::get::fetch_links_by_fusionauth_user_id(
&ctx.db,
@@ -73,19 +81,22 @@ pub async fn list_links_handler(
.await
.map_err(ListLinksError::DatabaseError)?;
- let access_token = fetch_gmail_access_token_from_link(
- &link,
- &ctx.redis_client,
- &ctx.auth_service_client,
- )
- .await
- .map_err(ListLinksError::AuthError)?;
-
- let signature = ctx
- .gmail_client
- .get_email_signature(&access_token, link.email_address.0.as_ref())
+ let signature = if query_params.include_signature {
+ let access_token = fetch_gmail_access_token_from_link(
+ &link,
+ &ctx.redis_client,
+ &ctx.auth_service_client,
+ )
.await
- .unwrap_or(None);
+ .map_err(ListLinksError::AuthError)?;
+
+ ctx.gmail_client
+ .get_email_signature(&access_token, link.email_address.0.as_ref())
+ .await
+ .unwrap_or(None)
+ } else {
+ None
+ };
Ok(api::link::Link::new(
link,