1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
// 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),
ServiceMessage(Id, BareJid, Body, StanzaTimeInfo),
HttpUploadedFile(String),
}