Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix breaking changes from Tungstenite #305

Merged
merged 1 commit into from
Jan 1, 2025
Merged
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
5 changes: 3 additions & 2 deletions docs/src/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Cargo.toml dependencies example:

```toml
[dependencies]
slack-morphism = { version = "2.7", features = ["hyper", "axum"] }
slack-morphism = { version = "2.8", features = ["hyper", "axum"] }
```

All imports you need:
Expand All @@ -14,8 +14,9 @@ use slack_morphism::prelude::*;
```

## Ready to use examples

- Slack Web API client and Block kit example
- Events API server example using either pure hyper solution or axum
- Slack Web API client with Socket Mode

You can find them on [github](https://github.com/abdolence/slack-morphism-rust/tree/master/examples)
You can find them on [GitHub](https://github.com/abdolence/slack-morphism-rust/tree/master/examples)
15 changes: 9 additions & 6 deletions src/hyper_tokio/socket_mode/tungstenite_wss_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use std::time::SystemTime;
use tokio::net::TcpStream;
use tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender};
use tokio::sync::RwLock;
use tokio_tungstenite::tungstenite::Utf8Bytes;
use tokio_tungstenite::*;
use tracing::*;

Expand Down Expand Up @@ -231,7 +232,7 @@ where
match message {
SlackTungsteniteWssClientCommand::Message(body) => {
if writer
.send(tokio_tungstenite::tungstenite::Message::Text(body))
.send(tokio_tungstenite::tungstenite::Message::Text(body.into()))
.await
.is_err()
{
Expand All @@ -246,7 +247,7 @@ where
body
);
if writer
.send(tokio_tungstenite::tungstenite::Message::Pong(body))
.send(tokio_tungstenite::tungstenite::Message::Pong(body.into()))
.await
.is_err()
{
Expand All @@ -259,7 +260,7 @@ where
slack_wss_client_id = thread_identity.id.to_string().as_str(),
"[{}] Ping to Slack: {:?}",
thread_identity.id.to_string(),
body
&body
);

let seen_pong_time_in_secs = {
Expand All @@ -283,7 +284,9 @@ where
);
rx.close()
} else if let Err(err) = writer
.send(tokio_tungstenite::tungstenite::Message::Ping(body.to_vec()))
.send(tokio_tungstenite::tungstenite::Message::Ping(
body.to_vec().into(),
))
.await
{
warn!(
Expand Down Expand Up @@ -362,7 +365,7 @@ where
);
if let Some(reply) = thread_identity
.client_listener
.on_message(&thread_identity.id, body)
.on_message(&thread_identity.id, body.as_str().into())
.await
{
trace!(
Expand All @@ -382,7 +385,7 @@ where
thread_identity.id.to_string(),
body
);
tx.send(SlackTungsteniteWssClientCommand::Pong(body))
tx.send(SlackTungsteniteWssClientCommand::Pong(body.into()))
.unwrap_or(());
}
Ok(tokio_tungstenite::tungstenite::Message::Pong(body)) => {
Expand Down
2 changes: 1 addition & 1 deletion src/socket_mode/clients_manager_listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ where
if let Some(clients_manager) = self.clients_manager.upgrade() {
match serde_json::from_str::<SlackSocketModeEvent>(message_body.as_str()).map_err(|e| {
SlackClientProtocolError::new(e)
.with_json_body(message_body.to_string())
.with_json_body(message_body)
.into()
}) {
Ok(sm_event) => match sm_event {
Expand Down
Loading