feat: support rauth events
feat: add platform user wipe event
This commit is contained in:
14
Cargo.lock
generated
14
Cargo.lock
generated
@@ -2580,8 +2580,8 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rauth"
|
name = "rauth"
|
||||||
version = "1.0.0"
|
version = "1.0.2"
|
||||||
source = "git+https://github.com/insertish/rauth?rev=195f1703cc4c57be01a39f465296cab4e22524b3#195f1703cc4c57be01a39f465296cab4e22524b3"
|
source = "git+https://github.com/insertish/rauth?tag=1.0.2#d466718bb4f1c8ca03f4a17265a646a52e07dff5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-std",
|
"async-std",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
@@ -2790,7 +2790,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "revolt-bonfire"
|
name = "revolt-bonfire"
|
||||||
version = "0.5.5"
|
version = "0.5.6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-std",
|
"async-std",
|
||||||
"async-tungstenite",
|
"async-tungstenite",
|
||||||
@@ -2806,7 +2806,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "revolt-delta"
|
name = "revolt-delta"
|
||||||
version = "0.5.5"
|
version = "0.5.6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-channel",
|
"async-channel",
|
||||||
"async-std",
|
"async-std",
|
||||||
@@ -2846,7 +2846,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "revolt-quark"
|
name = "revolt-quark"
|
||||||
version = "0.1.0"
|
version = "0.5.6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-recursion",
|
"async-recursion",
|
||||||
"async-std",
|
"async-std",
|
||||||
@@ -3080,8 +3080,8 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rocket_rauth"
|
name = "rocket_rauth"
|
||||||
version = "1.0.0"
|
version = "1.0.2"
|
||||||
source = "git+https://github.com/insertish/rauth?rev=195f1703cc4c57be01a39f465296cab4e22524b3#195f1703cc4c57be01a39f465296cab4e22524b3"
|
source = "git+https://github.com/insertish/rauth?tag=1.0.2#d466718bb4f1c8ca03f4a17265a646a52e07dff5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"iso8601-timestamp",
|
"iso8601-timestamp",
|
||||||
"rauth",
|
"rauth",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-bonfire"
|
name = "revolt-bonfire"
|
||||||
version = "0.5.5"
|
version = "0.5.6"
|
||||||
license = "AGPL-3.0-or-later"
|
license = "AGPL-3.0-or-later"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-delta"
|
name = "revolt-delta"
|
||||||
version = "0.5.5"
|
version = "0.5.6"
|
||||||
license = "AGPL-3.0-or-later"
|
license = "AGPL-3.0-or-later"
|
||||||
authors = ["Paul Makles <paulmakles@gmail.com>"]
|
authors = ["Paul Makles <paulmakles@gmail.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
@@ -52,7 +52,7 @@ mobc-redis = { version = "0.7.0", default-features = false, features = ["async-s
|
|||||||
# web
|
# web
|
||||||
rocket = { version = "0.5.0-rc.2", default-features = false, features = ["json"] }
|
rocket = { version = "0.5.0-rc.2", default-features = false, features = ["json"] }
|
||||||
rocket_empty = { version = "0.1.1", features = ["schema"] }
|
rocket_empty = { version = "0.1.1", features = ["schema"] }
|
||||||
rocket_rauth = { git = "https://github.com/insertish/rauth", rev = "195f1703cc4c57be01a39f465296cab4e22524b3" }
|
rocket_rauth = { git = "https://github.com/insertish/rauth", tag = "1.0.2" }
|
||||||
|
|
||||||
# spec generation
|
# spec generation
|
||||||
schemars = "0.8.8"
|
schemars = "0.8.8"
|
||||||
|
|||||||
@@ -10,7 +10,9 @@ extern crate lazy_static;
|
|||||||
pub mod routes;
|
pub mod routes;
|
||||||
pub mod util;
|
pub mod util;
|
||||||
|
|
||||||
use revolt_quark::rauth::RAuth;
|
use async_std::channel::unbounded;
|
||||||
|
use revolt_quark::events::client::EventV1;
|
||||||
|
use revolt_quark::rauth::{RAuth, RAuthEvent};
|
||||||
use revolt_quark::DatabaseInfo;
|
use revolt_quark::DatabaseInfo;
|
||||||
|
|
||||||
#[launch]
|
#[launch]
|
||||||
@@ -25,13 +27,33 @@ async fn rocket() -> _ {
|
|||||||
let db = DatabaseInfo::Auto.connect().await.unwrap();
|
let db = DatabaseInfo::Auto.connect().await.unwrap();
|
||||||
db.migrate_database().await.unwrap();
|
db.migrate_database().await.unwrap();
|
||||||
|
|
||||||
|
// Setup rAuth event channel
|
||||||
|
let (sender, receiver) = unbounded();
|
||||||
|
|
||||||
// Setup rAuth
|
// Setup rAuth
|
||||||
let rauth = RAuth {
|
let rauth = RAuth {
|
||||||
database: db.clone().into(),
|
database: db.clone().into(),
|
||||||
config: revolt_quark::util::rauth::config(),
|
config: revolt_quark::util::rauth::config(),
|
||||||
|
event_channel: Some(sender),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Launch background task workers.
|
// Launch a listener for rAuth events
|
||||||
|
async_std::task::spawn(async move {
|
||||||
|
while let Ok(event) = receiver.recv().await {
|
||||||
|
match &event {
|
||||||
|
RAuthEvent::CreateSession { .. } | RAuthEvent::CreateAccount { .. } => {
|
||||||
|
EventV1::Auth(event).global().await
|
||||||
|
}
|
||||||
|
RAuthEvent::DeleteSession { user_id, .. }
|
||||||
|
| RAuthEvent::DeleteAllSessions { user_id, .. } => {
|
||||||
|
let id = user_id.to_string();
|
||||||
|
EventV1::Auth(event).private(id).await
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Launch background task workers
|
||||||
async_std::task::spawn(revolt_quark::tasks::start_workers(db.clone()));
|
async_std::task::spawn(revolt_quark::tasks::start_workers(db.clone()));
|
||||||
|
|
||||||
// Configure CORS
|
// Configure CORS
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-quark"
|
name = "revolt-quark"
|
||||||
version = "0.1.0"
|
version = "0.5.6"
|
||||||
license = "AGPL-3.0-or-later"
|
license = "AGPL-3.0-or-later"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
@@ -84,7 +84,7 @@ rocket_empty = { version = "0.1.1", optional = true, features = [ "schema" ] }
|
|||||||
rocket_cors = { optional = true, git = "https://github.com/lawliet89/rocket_cors", rev = "c17e8145baa4790319fdb6a473e465b960f55e7c" }
|
rocket_cors = { optional = true, git = "https://github.com/lawliet89/rocket_cors", rev = "c17e8145baa4790319fdb6a473e465b960f55e7c" }
|
||||||
|
|
||||||
# rAuth
|
# rAuth
|
||||||
rauth = { git = "https://github.com/insertish/rauth", rev = "195f1703cc4c57be01a39f465296cab4e22524b3", features = [ "async-std-runtime" ] }
|
rauth = { git = "https://github.com/insertish/rauth", tag = "1.0.2", features = [ "async-std-runtime" ] }
|
||||||
|
|
||||||
# Sentry
|
# Sentry
|
||||||
sentry = "0.25.0"
|
sentry = "0.25.0"
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
use rauth::RAuthEvent;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::models::channel::{FieldsChannel, PartialChannel};
|
use crate::models::channel::{FieldsChannel, PartialChannel};
|
||||||
@@ -195,9 +196,23 @@ pub enum EventV1 {
|
|||||||
/// Settings updated remotely
|
/// Settings updated remotely
|
||||||
UserSettingsUpdate { id: String, update: UserSettings },
|
UserSettingsUpdate { id: String, update: UserSettings },
|
||||||
|
|
||||||
|
/// User has been platform banned or deleted their account
|
||||||
|
///
|
||||||
|
/// Clients should remove the following associated data:
|
||||||
|
/// - Messages
|
||||||
|
/// - DM Channels
|
||||||
|
/// - Relationships
|
||||||
|
/// - Server Memberships
|
||||||
|
///
|
||||||
|
/// User flags are specified to explain why a wipe is occurring though not all reasons will necessarily ever appear.
|
||||||
|
UserPlatformWipe { user_id: String, flags: i32 },
|
||||||
|
|
||||||
/// New emoji
|
/// New emoji
|
||||||
EmojiCreate(Emoji),
|
EmojiCreate(Emoji),
|
||||||
|
|
||||||
/// Delete emoji
|
/// Delete emoji
|
||||||
EmojiDelete { id: String },
|
EmojiDelete { id: String },
|
||||||
|
|
||||||
|
/// Auth events
|
||||||
|
Auth(RAuthEvent),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -559,4 +559,9 @@ impl EventV1 {
|
|||||||
pub async fn private(self, id: String) {
|
pub async fn private(self, id: String) {
|
||||||
self.p(format!("{}!", id)).await;
|
self.p(format!("{}!", id)).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Publish internal global event
|
||||||
|
pub async fn global(self) {
|
||||||
|
self.p("global".to_string()).await;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,6 +105,8 @@ pub enum Flags {
|
|||||||
Deleted = 2,
|
Deleted = 2,
|
||||||
/// User was banned off the platform
|
/// User was banned off the platform
|
||||||
Banned = 4,
|
Banned = 4,
|
||||||
|
/// User was marked as spam and removed from platform
|
||||||
|
Spam = 8,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Bot information for if the user is a bot
|
/// Bot information for if the user is a bot
|
||||||
|
|||||||
Reference in New Issue
Block a user