1
0
mirror of https://gitlab.com/xmpp-rs/xmpp-rs.git synced 2024-06-09 09:44:03 +02:00
xmpp-rs/xmpp/src/event.rs
2024-01-26 22:38:00 +01:00

90 lines
4.6 KiB
Rust

// 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/.
#[cfg(feature = "avatars")]
use tokio_xmpp::parsers::Jid;
use tokio_xmpp::parsers::{bookmarks2, message::Body, roster::Item as RosterItem, BareJid};
use crate::message::MucMessageId;
use crate::{delay::StanzaTimeInfo, Error, Id, RoomNick};
#[derive(Debug)]
pub enum Event {
Online,
Disconnected(Error),
ContactAdded(RosterItem),
ContactRemoved(RosterItem),
ContactChanged(RosterItem),
#[cfg(feature = "avatars")]
AvatarRetrieved(Jid, String),
/// A chat message was received. It may have been delayed on the network.
/// - The [`Id`] is a unique identifier for this message.
/// - The [`BareJid`] is the sender's JID.
/// - The [`Body`] is the message body.
/// - The [`StanzaTimeInfo`] about when message was received, and when the message was claimed sent.
ChatMessage(Id, BareJid, Body, StanzaTimeInfo),
JoinRoom(BareJid, bookmarks2::Conference),
LeaveRoom(BareJid),
LeaveAllRooms,
RoomJoined(BareJid),
RoomLeft(BareJid),
/// A message received from a group chat room.
/// - The [`MucMessageId`] is the ID of the message; it contains the ID assigned by the room,
/// and the ID assigned by the sending client.
/// - The [`BareJid`] is the room's address.
/// - The [`RoomNick`] is the nickname of the room member who sent the message.
/// - The [`Body`] is the message body.
/// - The [`StanzaTimeInfo`] about when message was received, and when the message was claimed sent.
///
/// Note: if the sender_assigned_id matches the ID returned by Agent::send_message,
/// then the message is an echo of a message sent by the client.
RoomMessage(MucMessageId, BareJid, RoomNick, Body, StanzaTimeInfo),
/// The subject of a room was received.
/// - The MucMessageId is the ID of the message that contained the subject;
/// it contains the ID assigned by the room, and the ID assigned by the sending client.
/// - 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.
/// - The [`StanzaTimeInfo`] about when message was received, and when the message was claimed sent.
RoomSubject(
MucMessageId,
BareJid,
Option<RoomNick>,
String,
StanzaTimeInfo,
),
/// A private message received from a member of a room.
/// - The [`MucMessageId`] is the ID of the message; it contains the ID assigned by the room,
/// and the ID assigned by the sending client.
/// - The [`BareJid`] is the room's address.
/// - The [`RoomNick`] is the nickname of the room member who sent the message.
/// - The [`Body`] is the message body.
/// - The [`StanzaTimeInfo`] about when message was received, and when the message was claimed sent.
///
/// Note: if the sender_assigned_id matches the ID returned by Agent::send_room_private_message,
/// then the message is an echo of a message sent by the client.
RoomPrivateMessage(MucMessageId, BareJid, RoomNick, Body, StanzaTimeInfo),
/// A message in a one-to-one chat was corrected/edited.
/// - The [`Id`] is the ID of the message that was corrected. (Only
/// - The [`BareJid`] is the JID of the other participant in the chat.
/// - The [`Body`] is the new body of the message, to replace the old one.
ChatMessageCorrection(Id, BareJid, Body),
/// A message in a MUC was corrected/edited.
/// - The [`MucMessageId`] is the ID of the message that was corrected. (Only muc_assigned_id is set.)
/// - The [`BareJid`] is the JID of the room where the message was sent.
/// - The [`RoomNick`] is the nickname of the sender of the message.
/// - The [`Body`] is the new body of the message, to replace the old one.
RoomMessageCorrection(MucMessageId, BareJid, RoomNick, Body),
/// A private message in a MUC was corrected/edited.
/// - The [`MucMessageId`] is the ID of the message that was corrected. (Only muc_assigned_id is set.)
/// - The [`BareJid`] is the JID of the room where the message was sent.
/// - The [`RoomNick`] is the nickname of the sender of the message.
/// - The [`Body`] is the new body of the message, to replace the old one.
RoomPrivateMessageCorrection(MucMessageId, BareJid, RoomNick, Body),
ServiceMessage(Id, BareJid, Body, StanzaTimeInfo),
HttpUploadedFile(String),
}