Update dependencies
parent
f8ab672453
commit
06f7fb729a
File diff suppressed because it is too large
Load Diff
12
Cargo.toml
12
Cargo.toml
|
@ -6,10 +6,10 @@ edition = "2018"
|
|||
[dependencies]
|
||||
bincode = "1.3.3"
|
||||
discord_message_format = { git = "https://git.lavender.software/charlotte/discord-message-format.git" }
|
||||
matrix-sdk = { git = "https://github.com/matrix-org/matrix-rust-sdk.git" }
|
||||
serde = { version = "1.0.129", features = ["derive"] }
|
||||
sled = "0.34.6"
|
||||
tokio = { version = "1.10.1", features = ["full"] }
|
||||
matrix-sdk = "0.4"
|
||||
serde = { version = "1.0.130", features = ["derive"] }
|
||||
sled = "0.34.7"
|
||||
tokio = { version = "1.11.0", features = ["full"] }
|
||||
url = "2.2.2"
|
||||
log = "0.4.14"
|
||||
env_logger = "0.9.0"
|
||||
|
@ -21,7 +21,3 @@ kuchiki = "0.8.1"
|
|||
version = "0.10.9"
|
||||
default-features = false
|
||||
features = ["builder", "cache", "client", "gateway", "model", "http", "utils", "rustls_backend"]
|
||||
|
||||
[patch.crates-io]
|
||||
olm-sys = { path = "./target/patch/olm-sys-1.1.2" }
|
||||
# You gotta apply the patch or simply clone olm-sys to that location :>
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
--- olm/tests/test_base64.cpp 2021-09-12 01:51:01.587794700 +0100
|
||||
+++ olm/tests/test_base64.cpp 2021-09-12 01:52:11.937270600 +0100
|
||||
@@ -1,6 +1,8 @@
|
||||
#include "olm/base64.hh"
|
||||
#include "olm/base64.h"
|
||||
#include "unittest.hh"
|
||||
+#include <cstring>
|
||||
+#include <vector>
|
||||
|
||||
int main() {
|
||||
|
||||
@@ -68,7 +70,6 @@
|
||||
|
||||
{
|
||||
TestCase test_case("Decoding base64 of invalid length fails with -1");
|
||||
-#include <iostream>
|
||||
std::uint8_t input[] = "SGVsbG8gV29ybGQab";
|
||||
std::size_t input_length = sizeof(input) - 1;
|
||||
|
||||
@@ -76,14 +77,12 @@
|
||||
* Nothing will be written to the output buffer anyway because the input is
|
||||
* invalid. */
|
||||
std::size_t buf_length = olm::decode_base64_length(input_length + 1);
|
||||
-std::uint8_t output[buf_length];
|
||||
-std::uint8_t expected_output[buf_length];
|
||||
-memset(output, 0, buf_length);
|
||||
-memset(expected_output, 0, buf_length);
|
||||
+std::vector<std::uint8_t> output(buf_length, 0);
|
||||
+std::vector<std::uint8_t> expected_output(buf_length, 0);
|
||||
|
||||
-std::size_t output_length = ::_olm_decode_base64(input, input_length, output);
|
||||
+std::size_t output_length = ::_olm_decode_base64(input, input_length, output.data());
|
||||
assert_equals(std::size_t(-1), output_length);
|
||||
-assert_equals(0, memcmp(output, expected_output, buf_length));
|
||||
+assert_equals(0, memcmp(output.data(), expected_output.data(), buf_length));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use matrix_sdk::{
|
||||
async_trait,
|
||||
room::{Joined, Room},
|
||||
ruma::{
|
||||
events::{
|
||||
|
@ -13,7 +14,7 @@ use matrix_sdk::{
|
|||
},
|
||||
EventId, UserId,
|
||||
},
|
||||
ClientConfig, EventHandler, SyncSettings,
|
||||
ClientConfig, SyncSettings,
|
||||
};
|
||||
pub use matrix_sdk::{ruma::RoomId, Client};
|
||||
|
||||
|
@ -100,10 +101,12 @@ impl MatrixHandler {
|
|||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl EventHandler for MatrixHandler {
|
||||
async fn on_room_message(&self, room: Room, event: &SyncMessageEvent<MessageEventContent>) {
|
||||
if event.sender == self.current_user_id {
|
||||
async fn on_room_message_event(
|
||||
ctx: Arc<MatrixHandler>,
|
||||
event: SyncMessageEvent<MessageEventContent>,
|
||||
room: Room,
|
||||
) {
|
||||
if event.sender == ctx.current_user_id {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -119,10 +122,10 @@ impl EventHandler for MatrixHandler {
|
|||
|
||||
match message_type {
|
||||
MessageType::Text(text) => {
|
||||
let content = self.get_content(&text.body, &text.formatted);
|
||||
let content = ctx.get_content(&text.body, &text.formatted);
|
||||
|
||||
if let Some(author) = self.get_message_author(&room, &event.sender).await {
|
||||
let _ = self.message_tx.send(MessageEvent::Send(SentMessage {
|
||||
if let Some(author) = ctx.get_message_author(&room, &event.sender).await {
|
||||
let _ = ctx.message_tx.send(MessageEvent::Send(SentMessage {
|
||||
source: message_ref,
|
||||
content,
|
||||
author,
|
||||
|
@ -131,11 +134,11 @@ impl EventHandler for MatrixHandler {
|
|||
}
|
||||
|
||||
MessageType::Emote(emote) => {
|
||||
let mut content = self.get_content(&emote.body, &emote.formatted);
|
||||
let mut content = ctx.get_content(&emote.body, &emote.formatted);
|
||||
content.insert(0, MessageComponent::Plain("* ".to_string()));
|
||||
|
||||
if let Some(author) = self.get_message_author(&room, &event.sender).await {
|
||||
let _ = self.message_tx.send(MessageEvent::Send(SentMessage {
|
||||
if let Some(author) = ctx.get_message_author(&room, &event.sender).await {
|
||||
let _ = ctx.message_tx.send(MessageEvent::Send(SentMessage {
|
||||
source: message_ref,
|
||||
content,
|
||||
author,
|
||||
|
@ -150,7 +153,6 @@ impl EventHandler for MatrixHandler {
|
|||
let _ = room.read_receipt(&event.event_id).await;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn forward_to_matrix(
|
||||
client: &Client,
|
||||
|
@ -198,11 +200,16 @@ pub async fn create_matrix_client(
|
|||
|
||||
let current_user_id = client.user_id().await.unwrap();
|
||||
|
||||
let event_handler = MatrixHandler {
|
||||
let event_handler = Arc::new(MatrixHandler {
|
||||
message_tx,
|
||||
current_user_id,
|
||||
};
|
||||
client.set_event_handler(Box::new(event_handler)).await;
|
||||
});
|
||||
|
||||
client
|
||||
.register_event_handler(move |ev, room| {
|
||||
on_room_message_event(Arc::clone(&event_handler), ev, room)
|
||||
})
|
||||
.await;
|
||||
|
||||
client
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue