add: live browser notifications
This commit is contained in:
parent
58d206eb81
commit
98d6f21e6e
18 changed files with 291 additions and 15 deletions
|
@ -40,6 +40,10 @@ pub struct User {
|
|||
/// External service connection details.
|
||||
#[serde(default)]
|
||||
pub connections: UserConnections,
|
||||
/// Subscribed channels data. Each entry is a channel ID, as well as the ID of
|
||||
/// the last message the user saw in that channel.
|
||||
#[serde(default)]
|
||||
pub subscriptions: HashMap<usize, usize>,
|
||||
}
|
||||
|
||||
pub type UserConnections =
|
||||
|
@ -232,6 +236,7 @@ impl User {
|
|||
post_count: 0,
|
||||
request_count: 0,
|
||||
connections: HashMap::new(),
|
||||
subscriptions: HashMap::new(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -370,14 +375,12 @@ pub struct ExternalConnectionInfo {
|
|||
pub show_on_profile: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
#[derive(Default)]
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, Default)]
|
||||
pub struct ExternalConnectionData {
|
||||
pub external_urls: HashMap<String, String>,
|
||||
pub data: HashMap<String, String>,
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct Notification {
|
||||
pub id: usize,
|
||||
|
|
|
@ -1,11 +1,19 @@
|
|||
use serde::{Serialize, Deserialize, de::DeserializeOwned};
|
||||
|
||||
#[derive(Serialize, Deserialize, PartialEq, Eq)]
|
||||
pub enum CrudMessageType {
|
||||
Create,
|
||||
Delete,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, PartialEq, Eq)]
|
||||
pub enum PacketType {
|
||||
/// A regular check to ensure the connection is still alive.
|
||||
Ping,
|
||||
/// General text which can be ignored.
|
||||
Text,
|
||||
/// A CRUD operation.
|
||||
Crud(CrudMessageType),
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, PartialEq, Eq)]
|
||||
|
@ -20,6 +28,8 @@ pub enum SocketMethod {
|
|||
Forward(PacketType),
|
||||
/// A general packet from client to server. (ws to Redis pubsub)
|
||||
Misc(PacketType),
|
||||
/// A general packet from client to server. (ws to Redis pubsub)
|
||||
Packet(PacketType),
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue