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): Move access level into thread object (#498)

Evan Hutnik1b20c4104182
diff --git a/rust/cloud-storage/Cargo.lock b/rust/cloud-storage/Cargo.lock
index c0221f6b10..e17aa17624 100644
--- a/rust/cloud-storage/Cargo.lock
+++ b/rust/cloud-storage/Cargo.lock
@@ -5481,6 +5481,7 @@ dependencies = [
"macro_user_id",
"macro_uuid",
"models_pagination",
+ "models_permissions",
"regex",
"schemars",
"scraper",
diff --git a/rust/cloud-storage/email_service/src/api/email/threads/get.rs b/rust/cloud-storage/email_service/src/api/email/threads/get.rs
index c1e0eb6c89..162547c0a5 100644
--- a/rust/cloud-storage/email_service/src/api/email/threads/get.rs
+++ b/rust/cloud-storage/email_service/src/api/email/threads/get.rs
@@ -66,7 +66,6 @@ pub struct GetThreadParams {
pub struct GetThreadResponse {
/// the thread, with messages inside
pub thread: thread::APIThread,
- pub access_level: AccessLevel,
}
/// Represents pagination parameters with defaults applied
@@ -156,14 +155,11 @@ pub async fn get_thread_handler(
let result: Vec<MessageWithBodyReplyless> = join_all(tasks).await;
- let api_thread = APIThread::from_thread_with_messages(thread, result);
+ let api_thread = APIThread::from_thread_with_messages(thread, result, access_level);
Ok((
StatusCode::OK,
- Json(GetThreadResponse {
- access_level,
- thread: api_thread,
- }),
+ Json(GetThreadResponse { thread: api_thread }),
)
.into_response())
}
diff --git a/rust/cloud-storage/models_email/Cargo.toml b/rust/cloud-storage/models_email/Cargo.toml
index b743bb9cd8..5b3872c8b5 100644
--- a/rust/cloud-storage/models_email/Cargo.toml
+++ b/rust/cloud-storage/models_email/Cargo.toml
@@ -16,6 +16,7 @@ lazy_static = { workspace = true }
macro_user_id = { path = "../macro_user_id" }
macro_uuid = { path = "../macro_uuid" }
models_pagination = { path = "../models_pagination" }
+models_permissions = { path = "../models_permissions" }
regex = { workspace = true }
schemars = { workspace = true }
scraper = { workspace = true }
diff --git a/rust/cloud-storage/models_email/src/email/service/thread.rs b/rust/cloud-storage/models_email/src/email/service/thread.rs
index c41a2de11a..2521e8383a 100644
--- a/rust/cloud-storage/models_email/src/email/service/thread.rs
+++ b/rust/cloud-storage/models_email/src/email/service/thread.rs
@@ -4,6 +4,7 @@ use crate::service::contact::Contact;
use crate::service::message::MessageWithBodyReplyless;
use chrono::{DateTime, Utc};
use models_pagination::{Identify, SimpleSortMethod, SortOn};
+use models_permissions::share_permission::access_level::AccessLevel;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use serde_with::{DeserializeFromStr, SerializeDisplay};
@@ -51,6 +52,7 @@ pub struct APIThread {
pub link_id: Uuid,
pub inbox_visible: bool,
pub is_read: bool,
+ pub access_level: AccessLevel,
// this field is only set w.r.t incoming messages (see is_inbound), for inbox thread ordering
pub latest_inbound_message_ts: Option<DateTime<Utc>>,
// this field is only set w.r.t outgoing messages (see is_outbound), for sent message thread ordering
@@ -66,6 +68,7 @@ impl APIThread {
pub fn from_thread_with_messages(
thread: Thread,
messages: Vec<MessageWithBodyReplyless>,
+ access_level: AccessLevel,
) -> Self {
Self {
db_id: thread.db_id,
@@ -73,6 +76,7 @@ impl APIThread {
link_id: thread.link_id,
inbox_visible: thread.inbox_visible,
is_read: thread.is_read,
+ access_level,
latest_inbound_message_ts: thread.latest_inbound_message_ts,
latest_outbound_message_ts: thread.latest_outbound_message_ts,
latest_non_spam_message_ts: thread.latest_non_spam_message_ts,