mirror of
https://gitlab.com/xmpp-rs/xmpp-rs.git
synced 2024-07-12 22:21:53 +00:00
Move send_room_private_message to muc::private_message module
This commit is contained in:
parent
fecacf84c3
commit
0e31739934
3 changed files with 33 additions and 8 deletions
|
@ -12,7 +12,6 @@ pub use tokio_xmpp::parsers;
|
||||||
use tokio_xmpp::parsers::{
|
use tokio_xmpp::parsers::{
|
||||||
disco::DiscoInfoResult,
|
disco::DiscoInfoResult,
|
||||||
message::{Body, Message, MessageType},
|
message::{Body, Message, MessageType},
|
||||||
muc::user::MucUser,
|
|
||||||
};
|
};
|
||||||
use tokio_xmpp::AsyncClient as TokioXmppClient;
|
use tokio_xmpp::AsyncClient as TokioXmppClient;
|
||||||
pub use tokio_xmpp::{BareJid, Element, FullJid, Jid};
|
pub use tokio_xmpp::{BareJid, Element, FullJid, Jid};
|
||||||
|
@ -120,13 +119,7 @@ impl Agent {
|
||||||
lang: &str,
|
lang: &str,
|
||||||
text: &str,
|
text: &str,
|
||||||
) {
|
) {
|
||||||
let recipient: Jid = room.with_resource_str(&recipient).unwrap().into();
|
muc::private_message::send_room_private_message(self, room, recipient, lang, text).await
|
||||||
let mut message = Message::new(recipient).with_payload(MucUser::new());
|
|
||||||
message.type_ = MessageType::Chat;
|
|
||||||
message
|
|
||||||
.bodies
|
|
||||||
.insert(String::from(lang), Body(String::from(text)));
|
|
||||||
let _ = self.client.send_stanza(message.into()).await;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Wait for new events.
|
/// Wait for new events.
|
||||||
|
|
|
@ -4,4 +4,5 @@
|
||||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
pub mod private_message;
|
||||||
pub mod room;
|
pub mod room;
|
||||||
|
|
31
xmpp/src/muc/private_message.rs
Normal file
31
xmpp/src/muc/private_message.rs
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
// Copyright (c) 2023 xmpp-rs contributors.
|
||||||
|
//
|
||||||
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
use tokio_xmpp::{
|
||||||
|
parsers::{
|
||||||
|
message::{Body, Message, MessageType},
|
||||||
|
muc::user::MucUser,
|
||||||
|
},
|
||||||
|
BareJid, Jid,
|
||||||
|
};
|
||||||
|
|
||||||
|
use crate::{Agent, RoomNick};
|
||||||
|
|
||||||
|
pub async fn send_room_private_message(
|
||||||
|
agent: &mut Agent,
|
||||||
|
room: BareJid,
|
||||||
|
recipient: RoomNick,
|
||||||
|
lang: &str,
|
||||||
|
text: &str,
|
||||||
|
) {
|
||||||
|
let recipient: Jid = room.with_resource_str(&recipient).unwrap().into();
|
||||||
|
let mut message = Message::new(recipient).with_payload(MucUser::new());
|
||||||
|
message.type_ = MessageType::Chat;
|
||||||
|
message
|
||||||
|
.bodies
|
||||||
|
.insert(String::from(lang), Body(String::from(text)));
|
||||||
|
let _ = agent.client.send_stanza(message.into()).await;
|
||||||
|
}
|
Loading…
Reference in a new issue