use std::time::Duration;
use actix::{Addr, Message};
use anyhow::Result;
use irc_proto::{ChannelMode, Mode};
use tracing::Span;
use crate::{
channel::Channel,
client::Client,
connection::{InitiatedConnection, UserId},
host_mask::HostMask,
server::response::NoSuchNick,
};
#[derive(Message, Clone)]
#[rtype(result = "()")]
pub struct UserConnected {
pub handle: Addr<Client>,
pub connection: InitiatedConnection,
pub span: Span,
}
#[derive(Message, Clone)]
#[rtype(result = "()")]
pub struct ServerDisconnect {
pub client: Addr<Client>,
pub message: Option<String>,
pub span: Span,
}
#[derive(Message, Clone)]
#[rtype(result = "()")]
pub struct KillUser {
pub span: Span,
pub killer: String,
pub comment: String,
pub killed: String,
}
#[derive(Message, Clone)]
#[rtype(result = "Result<(), NoSuchNick>")]
pub struct ForceDisconnect {
pub span: Span,
pub user: String,
pub comment: String,
}
#[derive(Message, Clone)]
#[rtype(result = "()")]
pub struct UserNickChangeInternal {
pub old_nick: String,
pub new_nick: String,
pub span: Span,
}
#[derive(Message, Clone)]
#[rtype(result = "()")]
pub struct UserNickChange {
pub client: Addr<Client>,
pub connection: InitiatedConnection,
pub new_nick: String,
pub span: Span,
}
#[derive(Message, Clone)]
#[rtype(result = "()")]
pub struct Wallops {
pub message: String,
pub span: Span,
}
#[derive(Message, Clone)]
#[rtype(result = "Vec<(crate::channel::permissions::Permission, String)>")]
pub struct ConnectedChannels {
pub span: Span,
}
#[derive(Message, Clone)]
#[rtype(result = "()")]
pub struct ClientAway {
pub span: Span,
pub handle: Addr<Client>,
pub message: Option<String>,
}
#[derive(Message, Clone)]
#[rtype(result = "super::server::response::ChannelList")]
pub struct ChannelList {
pub span: Span,
}
#[derive(Message, Clone)]
#[rtype(result = "super::server::response::WhoList")]
pub struct FetchWhoList {
pub span: Span,
pub query: String,
}
#[derive(Message, Clone)]
#[rtype(result = "super::server::response::Whois")]
pub struct FetchWhois {
pub span: Span,
pub query: String,
}
#[derive(Message)]
#[rtype(
result = "Result<std::result::Result<Addr<Channel>, super::channel::response::ChannelJoinRejectionReason>>"
)]
pub struct ChannelJoin {
pub channel_name: String,
pub client: Addr<Client>,
pub connection: InitiatedConnection,
pub span: Span,
}
#[derive(Message)]
#[rtype(result = "()")]
pub struct ChannelPart {
pub client: Addr<Client>,
pub message: Option<String>,
pub span: Span,
}
#[derive(Message)]
#[rtype(result = "super::channel::response::ChannelNamesList")]
pub struct ChannelMemberList {
pub span: Span,
}
#[derive(Message)]
#[rtype(result = "crate::channel::permissions::Permission")]
pub struct FetchUserPermission {
pub span: Span,
pub host_mask: HostMask<'static>,
}
#[derive(Message)]
#[rtype(result = "super::channel::response::ChannelTopic")]
pub struct ChannelFetchTopic {
pub span: Span,
pub skip_on_none: bool,
}
#[derive(Message)]
#[rtype(result = "super::channel::response::ChannelWhoList")]
pub struct ChannelFetchWhoList {
pub span: Span,
}
#[derive(Message)]
#[rtype(result = "Option<super::channel::response::ModeList>")]
pub struct ChannelSetMode {
pub span: Span,
pub client: Addr<Client>,
pub modes: Vec<Mode<ChannelMode>>,
}
#[derive(Message)]
#[rtype(result = "()")]
pub struct Gline {
pub requester: InitiatedConnection,
pub mask: HostMask<'static>,
pub duration: Option<Duration>,
pub reason: Option<String>,
}
#[derive(Message)]
#[rtype(result = "()")]
pub struct RemoveGline {
pub mask: HostMask<'static>,
}
#[derive(Message)]
#[rtype(result = "Vec<super::server::response::ServerBan>")]
pub struct ListGline;
#[derive(Message)]
#[rtype(result = "super::server::response::ConnectionValidated")]
pub struct ValidateConnection(pub InitiatedConnection);
#[derive(Message)]
#[rtype(result = "()")]
pub struct ChannelKickUser {
pub span: Span,
pub client: Addr<Client>,
pub user: String,
pub reason: Option<String>,
}
#[derive(Message)]
#[rtype(result = "super::server::response::Motd")]
pub struct ServerFetchMotd {
pub span: Span,
}
#[derive(Message)]
#[rtype(result = "super::server::response::ListUsers")]
pub struct ServerListUsers {
pub span: Span,
}
#[derive(Message)]
#[rtype(result = "super::server::response::AdminInfo")]
pub struct ServerAdminInfo {
pub span: Span,
}
#[derive(Message)]
#[rtype(result = "()")]
pub struct UserKickedFromChannel {
pub channel: String,
pub span: Span,
}
#[derive(Message)]
#[rtype(result = "()")]
pub struct ChannelUpdateTopic {
pub topic: String,
pub client: Addr<Client>,
pub span: Span,
}
#[derive(Message, Clone)]
#[rtype(result = "()")]
pub struct Broadcast {
pub message: irc_proto::Message,
pub span: Span,
}
#[derive(Message)]
#[rtype(result = "crate::connection::InitiatedConnection")]
pub struct FetchClientDetails {
pub span: Span,
}
#[derive(Copy, Clone, Debug, sqlx::Type)]
#[repr(i16)]
pub enum MessageKind {
Normal = 0,
Notice = 1,
}
#[derive(Message)]
#[rtype(result = "()")]
pub struct ChannelMessage {
pub client: Addr<Client>,
pub kind: MessageKind,
pub message: String,
pub span: Span,
}
#[derive(Message)]
#[rtype(result = "super::channel::response::ChannelInviteResult")]
pub struct ChannelInvite {
pub nick: String,
pub client: Addr<Client>,
pub span: Span,
}
#[derive(Message)]
#[rtype(result = "Option<Addr<Client>>")]
pub struct FetchClientByNick {
pub nick: String,
}
#[derive(Message)]
#[rtype(result = "()")]
pub struct PrivateMessage {
pub destination: UserId,
pub message: String,
pub kind: MessageKind,
pub from: Addr<Client>,
pub span: Span,
}