Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src-tauri/src/chat_channel/backends/lark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ impl LarkBackend {
&self,
msg_type: &str,
content: &str,
) -> Result<SentMessageId, ChatChannelError> {
) -> Result<SendOutcome, ChatChannelError> {
let token = self.get_tenant_access_token().await?;

let resp = self
Expand Down Expand Up @@ -251,7 +251,7 @@ impl LarkBackend {
}

let message_id = result.data.and_then(|d| d.message_id).unwrap_or_default();
Ok(SentMessageId(message_id))
Ok(SendOutcome::Sent(SentMessageId(message_id)))
}

async fn start_ws_receiver(
Expand Down Expand Up @@ -603,15 +603,15 @@ impl ChatChannelBackend for LarkBackend {
*self.status.lock().await
}

async fn send_message(&self, text: &str) -> Result<SentMessageId, ChatChannelError> {
async fn send_message(&self, text: &str) -> Result<SendOutcome, ChatChannelError> {
let content = serde_json::json!({ "text": text }).to_string();
self.send_lark_message("text", &content).await
}

async fn send_rich_message(
&self,
message: &RichMessage,
) -> Result<SentMessageId, ChatChannelError> {
) -> Result<SendOutcome, ChatChannelError> {
let card = build_lark_card(message);
let content = serde_json::to_string(&card)
.map_err(|e| ChatChannelError::SendFailed(e.to_string()))?;
Expand Down
20 changes: 10 additions & 10 deletions src-tauri/src/chat_channel/backends/telegram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl TelegramBackend {
text: &str,
parse_mode: Option<&str>,
target: Option<&ChannelMessageTarget>,
) -> Result<SentMessageId, ChatChannelError> {
) -> Result<SendOutcome, ChatChannelError> {
self.send_text_with_reply_markup(text, parse_mode, target, None)
.await
}
Expand All @@ -102,7 +102,7 @@ impl TelegramBackend {
parse_mode: Option<&str>,
target: Option<&ChannelMessageTarget>,
reply_markup: Option<serde_json::Value>,
) -> Result<SentMessageId, ChatChannelError> {
) -> Result<SendOutcome, ChatChannelError> {
let body =
telegram_send_message_body(&self.chat_id, text, parse_mode, target, reply_markup)?;

Expand Down Expand Up @@ -137,14 +137,14 @@ impl TelegramBackend {
.map(|id| id.to_string())
.unwrap_or_default();

Ok(SentMessageId(message_id))
Ok(SendOutcome::Sent(SentMessageId(message_id)))
}

async fn send_interactive_message_with_target(
&self,
message: &InteractiveMessage,
target: Option<&ChannelMessageTarget>,
) -> Result<SentMessageId, ChatChannelError> {
) -> Result<SendOutcome, ChatChannelError> {
let reply_markup = telegram_inline_keyboard(message);
let markdown_text = format_telegram_markdown(&message.base);
let result = self
Expand Down Expand Up @@ -177,7 +177,7 @@ impl TelegramBackend {
&self,
message: &RichMessage,
target: Option<&ChannelMessageTarget>,
) -> Result<SentMessageId, ChatChannelError> {
) -> Result<SendOutcome, ChatChannelError> {
let markdown_text = format_telegram_markdown(message);
let result = self
.send_text(&markdown_text, Some("MarkdownV2"), target)
Expand Down Expand Up @@ -454,30 +454,30 @@ impl ChatChannelBackend for TelegramBackend {
*self.status.lock().await
}

async fn send_message(&self, text: &str) -> Result<SentMessageId, ChatChannelError> {
async fn send_message(&self, text: &str) -> Result<SendOutcome, ChatChannelError> {
self.send_text(text, None, None).await
}

async fn send_rich_message(
&self,
message: &RichMessage,
) -> Result<SentMessageId, ChatChannelError> {
) -> Result<SendOutcome, ChatChannelError> {
self.send_rich_message_with_target(message, None).await
}

async fn send_rich_message_to(
&self,
message: &RichMessage,
target: &ChannelMessageTarget,
) -> Result<SentMessageId, ChatChannelError> {
) -> Result<SendOutcome, ChatChannelError> {
self.send_rich_message_with_target(message, Some(target))
.await
}

async fn send_interactive_message(
&self,
message: &InteractiveMessage,
) -> Result<SentMessageId, ChatChannelError> {
) -> Result<SendOutcome, ChatChannelError> {
self.send_interactive_message_with_target(message, None)
.await
}
Expand All @@ -486,7 +486,7 @@ impl ChatChannelBackend for TelegramBackend {
&self,
message: &InteractiveMessage,
target: &ChannelMessageTarget,
) -> Result<SentMessageId, ChatChannelError> {
) -> Result<SendOutcome, ChatChannelError> {
self.send_interactive_message_with_target(message, Some(target))
.await
}
Expand Down
Loading
Loading