feat(support): add support-chat domain models#1162
Conversation
TypeShare types for the upcoming device support-chat API: SupportConversation, SupportMessage, SupportAgent, and status enums. Models only — no backend logic.
There was a problem hiding this comment.
Code Review
This pull request introduces support-related primitives, including structs and enums for agents, conversations, and messages. The reviewer pointed out inconsistencies where several structs (SupportAgent, SupportConversation, and SupportMessage) are marked with Swift typeshare attributes indicating they are equatable, but their Rust definitions do not derive PartialEq or Eq. Suggestions were provided to add these derives to ensure consistency and support testing.
| Failed, | ||
| } | ||
|
|
||
| #[derive(Debug, Clone, Serialize, Deserialize)] |
There was a problem hiding this comment.
The SupportAgent struct is marked with #[typeshare(swift = "Sendable, Equatable")], indicating it should be equatable. However, the Rust struct does not derive PartialEq or Eq. To ensure consistency between the Rust models and the generated Swift models, and to allow equality comparisons in Rust (especially useful for testing), please derive PartialEq and Eq.
| #[derive(Debug, Clone, Serialize, Deserialize)] | |
| #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] |
| pub avatar_url: Option<String>, | ||
| } | ||
|
|
||
| #[derive(Debug, Clone, Serialize, Deserialize)] |
There was a problem hiding this comment.
The SupportConversation struct is marked with #[typeshare(swift = "Sendable, Equatable, Hashable, Identifiable")], but it does not derive PartialEq or Eq in Rust. To align with the Swift typeshare attributes and enable equality comparisons in Rust, please derive PartialEq and Eq.
| #[derive(Debug, Clone, Serialize, Deserialize)] | |
| #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] |
| pub unread_count: i32, | ||
| } | ||
|
|
||
| #[derive(Debug, Clone, Serialize, Deserialize)] |
There was a problem hiding this comment.
The SupportMessage struct is marked with #[typeshare(swift = "Sendable, Equatable")], but it does not derive PartialEq or Eq in Rust. Please derive PartialEq and Eq to ensure consistency with the Swift typeshare definitions and to support equality assertions in Rust tests.
| #[derive(Debug, Clone, Serialize, Deserialize)] | |
| #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] |
| pub direction: SupportMessageDirection, | ||
| pub delivery_status: SupportMessageDeliveryStatus, | ||
| #[serde(skip_serializing_if = "Option::is_none")] | ||
| pub agent: Option<SupportAgent>, |
… type
Per review: agent shouldn't be optional. New `SupportMessageSender { User,
Agent(SupportAgent) }` ties agent info to the agent case; `SupportMessageDirection`
is removed (sender encodes direction).
What
TypeShare models for the upcoming device support-chat API (Chatwoot-proxied):
SupportConversation,SupportMessage,SupportAgent, and status enums.Models only — no backend.
Chatwoot mappings the API must handle
Chatwoot
message_type: 0(contact) → ouroutgoing;1(agent) → ourincoming.Filter out
message_type: 2/3(activity/template).pending/snoozed→open;resolved→resolved.private: truenotes, non-textcontent_type.delivery_status: Chatwootsent/delivered/read→sent.sendingis client-only.first_message= first user message (title);last_message= last message (preview);unread_count= user POV (based oncontact_last_seen_at).