xmpp: Use ResourcePart for sender of room events
This commit is contained in:
parent
c16456f381
commit
5477cf1240
4 changed files with 10 additions and 8 deletions
|
|
@ -8,6 +8,8 @@ XXXX-YY-ZZ [ RELEASER <admin@localhost> ]
|
|||
- builder::ClientBuilder::set_default_nick no longer takes a &str, but
|
||||
any type that implements AsRef<jid::ResourceRef>, such as produced
|
||||
by ResourcePart::new (!485)
|
||||
- Event::RoomMessage, Event::RoomPrivateMessage, and Event::RoomSubject now
|
||||
use ResourcePart as sender nickname (!485)
|
||||
* Added:
|
||||
- Agent::send_room_message takes RoomMessageSettings argument (!483)
|
||||
* Fixes:
|
||||
|
|
|
|||
|
|
@ -4,12 +4,12 @@
|
|||
// 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::jid::BareJid;
|
||||
#[cfg(feature = "avatars")]
|
||||
use tokio_xmpp::jid::Jid;
|
||||
use tokio_xmpp::jid::{BareJid, ResourcePart};
|
||||
use tokio_xmpp::parsers::{message::Body, roster::Item as RosterItem};
|
||||
|
||||
use crate::{delay::StanzaTimeInfo, Error, Id, RoomNick};
|
||||
use crate::{delay::StanzaTimeInfo, Error, Id};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Event {
|
||||
|
|
@ -28,15 +28,15 @@ pub enum Event {
|
|||
ChatMessage(Id, BareJid, Body, StanzaTimeInfo),
|
||||
RoomJoined(BareJid),
|
||||
RoomLeft(BareJid),
|
||||
RoomMessage(Id, BareJid, RoomNick, Body, StanzaTimeInfo),
|
||||
RoomMessage(Id, BareJid, ResourcePart, Body, StanzaTimeInfo),
|
||||
/// The subject of a room was received.
|
||||
/// - The BareJid is the room's address.
|
||||
/// - The RoomNick is the nickname of the room member who set the subject.
|
||||
/// - The String is the new subject.
|
||||
RoomSubject(BareJid, Option<RoomNick>, String, StanzaTimeInfo),
|
||||
RoomSubject(BareJid, Option<ResourcePart>, String, StanzaTimeInfo),
|
||||
/// A private message received from a room, containing the message ID, the room's BareJid,
|
||||
/// the sender's nickname, and the message body.
|
||||
RoomPrivateMessage(Id, BareJid, RoomNick, Body, StanzaTimeInfo),
|
||||
RoomPrivateMessage(Id, BareJid, ResourcePart, Body, StanzaTimeInfo),
|
||||
ServiceMessage(Id, BareJid, Body, StanzaTimeInfo),
|
||||
HttpUploadedFile(String),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ pub async fn handle_message_chat(
|
|||
Ok(full) => Event::RoomPrivateMessage(
|
||||
message.id.clone(),
|
||||
full.to_bare(),
|
||||
full.resource().to_string(),
|
||||
full.resource().into(),
|
||||
body.clone(),
|
||||
time_info.clone(),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ pub async fn handle_message_group_chat(
|
|||
if let Some((_lang, subject)) = message.get_best_subject(langs.clone()) {
|
||||
events.push(Event::RoomSubject(
|
||||
from.to_bare(),
|
||||
from.resource().map(|x| x.to_string()),
|
||||
from.resource().map(Into::into),
|
||||
subject.0.clone(),
|
||||
time_info.clone(),
|
||||
));
|
||||
|
|
@ -31,7 +31,7 @@ pub async fn handle_message_group_chat(
|
|||
Ok(full) => Event::RoomMessage(
|
||||
message.id.clone(),
|
||||
from.to_bare(),
|
||||
full.resource().to_string(),
|
||||
full.resource().into(),
|
||||
body.clone(),
|
||||
time_info,
|
||||
),
|
||||
|
|
|
|||
Loading…
Reference in a new issue