xmpp crate now supports ServerConnector

This commit is contained in:
moparisthebest 2023-12-31 01:17:29 -05:00
commit 38bfba4a18
No known key found for this signature in database
GPG key ID: 88C93BFE27BC8229
20 changed files with 115 additions and 54 deletions

View file

@ -10,6 +10,7 @@ use reqwest::{
use std::path::PathBuf;
use tokio::fs::File;
use tokio_util::codec::{BytesCodec, FramedRead};
use tokio_xmpp::connect::ServerConnector;
use tokio_xmpp::{
parsers::http_upload::{Header as HttpUploadHeader, SlotResult},
Element, Jid,
@ -17,11 +18,11 @@ use tokio_xmpp::{
use crate::{Agent, Event};
pub async fn handle_upload_result(
pub async fn handle_upload_result<C: ServerConnector>(
from: &Jid,
iqid: String,
elem: Element,
agent: &mut Agent,
agent: &mut Agent<C>,
) -> impl IntoIterator<Item = Event> {
let mut res: Option<(usize, PathBuf)> = None;

View file

@ -6,6 +6,7 @@
use std::path::Path;
use tokio::fs::File;
use tokio_xmpp::connect::ServerConnector;
use tokio_xmpp::{
parsers::{http_upload::SlotRequest, iq::Iq},
Jid,
@ -13,7 +14,11 @@ use tokio_xmpp::{
use crate::Agent;
pub async fn upload_file_with(agent: &mut Agent, service: &str, path: &Path) {
pub async fn upload_file_with<C: ServerConnector>(
agent: &mut Agent<C>,
service: &str,
path: &Path,
) {
let name = path.file_name().unwrap().to_str().unwrap().to_string();
let file = File::open(path).await.unwrap();
let size = file.metadata().await.unwrap().len();