Event::RoomPrivateMessage does not expose sender FullJid ; add Agent::send_room_private_message method
This commit is contained in:
parent
6144a4c8b0
commit
9c39e3c195
1 changed files with 15 additions and 4 deletions
|
|
@ -91,8 +91,8 @@ pub enum Event {
|
||||||
RoomLeft(BareJid),
|
RoomLeft(BareJid),
|
||||||
RoomMessage(Id, BareJid, RoomNick, Body),
|
RoomMessage(Id, BareJid, RoomNick, Body),
|
||||||
/// A private message received from a room, containing the message ID, the room's BareJid,
|
/// A private message received from a room, containing the message ID, the room's BareJid,
|
||||||
/// the sender's FullJid, the corresponding nickname, and the message body.
|
/// the sender's nickname, and the message body.
|
||||||
RoomPrivateMessage(Id, BareJid, FullJid, RoomNick, Body),
|
RoomPrivateMessage(Id, BareJid, RoomNick, Body),
|
||||||
ServiceMessage(Id, BareJid, Body),
|
ServiceMessage(Id, BareJid, Body),
|
||||||
HttpUploadedFile(String),
|
HttpUploadedFile(String),
|
||||||
}
|
}
|
||||||
|
|
@ -255,6 +255,18 @@ impl Agent {
|
||||||
let _ = self.client.send_stanza(message.into()).await;
|
let _ = self.client.send_stanza(message.into()).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn send_room_private_message(
|
||||||
|
&mut self,
|
||||||
|
room: BareJid,
|
||||||
|
recipient: RoomNick,
|
||||||
|
type_: MessageType,
|
||||||
|
lang: &str,
|
||||||
|
text: &str,
|
||||||
|
) {
|
||||||
|
let recipient = room.with_resource(recipient);
|
||||||
|
self.send_message(recipient.into(), type_, lang, text).await
|
||||||
|
}
|
||||||
|
|
||||||
fn make_initial_presence(disco: &DiscoInfoResult, node: &str) -> Presence {
|
fn make_initial_presence(disco: &DiscoInfoResult, node: &str) -> Presence {
|
||||||
let caps_data = compute_disco(disco);
|
let caps_data = compute_disco(disco);
|
||||||
let hash = hash_caps(&caps_data, Algo::Sha_1).unwrap();
|
let hash = hash_caps(&caps_data, Algo::Sha_1).unwrap();
|
||||||
|
|
@ -272,7 +284,7 @@ impl Agent {
|
||||||
.clone()
|
.clone()
|
||||||
.unwrap_or_else(|| self.client.bound_jid().unwrap().clone());
|
.unwrap_or_else(|| self.client.bound_jid().unwrap().clone());
|
||||||
if let IqType::Get(payload) = iq.payload {
|
if let IqType::Get(payload) = iq.payload {
|
||||||
if payload.is("query", ns::DISCO_INFO) {
|
if MucUser::try_from(payload.clone()).is_ok() {
|
||||||
let query = DiscoInfoQuery::try_from(payload);
|
let query = DiscoInfoQuery::try_from(payload);
|
||||||
match query {
|
match query {
|
||||||
Ok(query) => {
|
Ok(query) => {
|
||||||
|
|
@ -375,7 +387,6 @@ impl Agent {
|
||||||
Jid::Full(full) => Event::RoomPrivateMessage(
|
Jid::Full(full) => Event::RoomPrivateMessage(
|
||||||
message.id.clone(),
|
message.id.clone(),
|
||||||
full.clone().into(),
|
full.clone().into(),
|
||||||
full.clone(),
|
|
||||||
full.resource,
|
full.resource,
|
||||||
body.clone(),
|
body.clone(),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue