mirror of
https://github.com/stoatchat/stoatchat.git
synced 2026-07-14 13:36:59 +00:00
Compare commits
26 Commits
stable
...
20250807-1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
050ba16d4a | ||
|
|
65bc6c8fc6 | ||
|
|
6ad3da5f35 | ||
|
|
947eb15771 | ||
|
|
f4ee35fb09 | ||
|
|
6048587d34 | ||
|
|
80cf8fc4e8 | ||
|
|
4f54227495 | ||
|
|
aab1734615 | ||
|
|
40a41ffd64 | ||
|
|
d30ceea373 | ||
|
|
3e8a401077 | ||
|
|
99f400bc7b | ||
|
|
73b576a75f | ||
|
|
4e4e598daf | ||
|
|
77daf82b94 | ||
|
|
e00603f276 | ||
|
|
1b2c7b2fa1 | ||
|
|
c526095d4f | ||
|
|
8cc4bbea4d | ||
|
|
911ffc767e | ||
|
|
1690df998d | ||
|
|
519d3c08a8 | ||
|
|
9846d8aac2 | ||
|
|
c74b6255dd | ||
|
|
df91b8c990 |
2550
Cargo.lock
generated
2550
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -11,6 +11,8 @@ members = [
|
|||||||
|
|
||||||
[patch.crates-io]
|
[patch.crates-io]
|
||||||
redis23 = { package = "redis", version = "0.23.3", git = "https://github.com/revoltchat/redis-rs", rev = "523b2937367e17bd0073722bf6e23d06042cb4e4" }
|
redis23 = { package = "redis", version = "0.23.3", git = "https://github.com/revoltchat/redis-rs", rev = "523b2937367e17bd0073722bf6e23d06042cb4e4" }
|
||||||
|
#authifier = { package = "authifier", version = "1.0.10", path = "../authifier/crates/authifier" }
|
||||||
|
#rocket_authifier = { package = "rocket_authifier", version = "1.0.10", path = "../authifier/crates/rocket_authifier" }
|
||||||
|
|
||||||
# I'm 99% sure this is overloading the GitHub worker
|
# I'm 99% sure this is overloading the GitHub worker
|
||||||
# hence builds have been failing since, let's just
|
# hence builds have been failing since, let's just
|
||||||
|
|||||||
@@ -114,7 +114,8 @@ If you'd like to change anything, create a `Revolt.overrides.toml` file and spec
|
|||||||
> And corresponding Revolt configuration:
|
> And corresponding Revolt configuration:
|
||||||
>
|
>
|
||||||
> ```toml
|
> ```toml
|
||||||
> # Revolt.overrides.toml
|
> # Revolt.overrides.toml
|
||||||
|
> # and Revolt.test-overrides.toml
|
||||||
> [database]
|
> [database]
|
||||||
> mongodb = "mongodb://127.0.0.1:14017"
|
> mongodb = "mongodb://127.0.0.1:14017"
|
||||||
> redis = "redis://127.0.0.1:14079/"
|
> redis = "redis://127.0.0.1:14079/"
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ services:
|
|||||||
- minio
|
- minio
|
||||||
entrypoint: >
|
entrypoint: >
|
||||||
/bin/sh -c "while ! /usr/bin/mc ready minio; do
|
/bin/sh -c "while ! /usr/bin/mc ready minio; do
|
||||||
/usr/bin/mc config host add minio http://minio:9000 minioautumn minioautumn;
|
/usr/bin/mc alias set minio http://minio:9000 minioautumn minioautumn;
|
||||||
echo 'Waiting minio...' && sleep 1;
|
echo 'Waiting minio...' && sleep 1;
|
||||||
done; /usr/bin/mc mb minio/revolt-uploads; exit 0;"
|
done; /usr/bin/mc mb minio/revolt-uploads; exit 0;"
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-bonfire"
|
name = "revolt-bonfire"
|
||||||
version = "0.8.7"
|
version = "0.8.8"
|
||||||
license = "AGPL-3.0-or-later"
|
license = "AGPL-3.0-or-later"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
@@ -41,7 +41,7 @@ revolt-result = { path = "../core/result" }
|
|||||||
revolt-models = { path = "../core/models" }
|
revolt-models = { path = "../core/models" }
|
||||||
revolt-config = { path = "../core/config" }
|
revolt-config = { path = "../core/config" }
|
||||||
revolt-database = { path = "../core/database" }
|
revolt-database = { path = "../core/database" }
|
||||||
revolt-permissions = { version = "0.8.7", path = "../core/permissions" }
|
revolt-permissions = { version = "0.8.8", path = "../core/permissions" }
|
||||||
revolt-presence = { path = "../core/presence", features = ["redis-is-patched"] }
|
revolt-presence = { path = "../core/presence", features = ["redis-is-patched"] }
|
||||||
|
|
||||||
# redis
|
# redis
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ use redis_kiss::{PayloadType, REDIS_PAYLOAD_TYPE, REDIS_URI};
|
|||||||
use revolt_config::report_internal_error;
|
use revolt_config::report_internal_error;
|
||||||
use revolt_database::{
|
use revolt_database::{
|
||||||
events::{client::EventV1, server::ClientMessage},
|
events::{client::EventV1, server::ClientMessage},
|
||||||
|
iso8601_timestamp::Timestamp,
|
||||||
Database, User, UserHint,
|
Database, User, UserHint,
|
||||||
};
|
};
|
||||||
use revolt_presence::{create_session, delete_session};
|
use revolt_presence::{create_session, delete_session};
|
||||||
@@ -100,6 +101,10 @@ pub async fn client(db: &'static Database, stream: TcpStream, addr: SocketAddr)
|
|||||||
|
|
||||||
info!("User {addr:?} authenticated as @{}", user.username);
|
info!("User {addr:?} authenticated as @{}", user.username);
|
||||||
|
|
||||||
|
db.update_session_last_seen(&session_id, Timestamp::now_utc())
|
||||||
|
.await
|
||||||
|
.ok();
|
||||||
|
|
||||||
// Create local state.
|
// Create local state.
|
||||||
let mut state = State::from(user, session_id);
|
let mut state = State::from(user, session_id);
|
||||||
let user_id = state.cache.user_id.clone();
|
let user_id = state.cache.user_id.clone();
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-config"
|
name = "revolt-config"
|
||||||
version = "0.8.7"
|
version = "0.8.8"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
authors = ["Paul Makles <me@insrt.uk>"]
|
authors = ["Paul Makles <me@insrt.uk>"]
|
||||||
@@ -36,4 +36,4 @@ sentry = "0.31.5"
|
|||||||
sentry-anyhow = { version = "0.38.1", optional = true }
|
sentry-anyhow = { version = "0.38.1", optional = true }
|
||||||
|
|
||||||
# Core
|
# Core
|
||||||
revolt-result = { version = "0.8.7", path = "../result", optional = true }
|
revolt-result = { version = "0.8.8", path = "../result", optional = true }
|
||||||
|
|||||||
@@ -60,6 +60,9 @@ static CONFIG_SEARCH_PATHS: [&str; 3] = [
|
|||||||
"/Revolt.toml",
|
"/Revolt.toml",
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/// Path to search for test overrides
|
||||||
|
static TEST_OVERRIDE_PATH: &str = "Revolt.test-overrides.toml";
|
||||||
|
|
||||||
/// Configuration builder
|
/// Configuration builder
|
||||||
static CONFIG_BUILDER: Lazy<RwLock<Config>> = Lazy::new(|| {
|
static CONFIG_BUILDER: Lazy<RwLock<Config>> = Lazy::new(|| {
|
||||||
RwLock::new({
|
RwLock::new({
|
||||||
@@ -73,6 +76,20 @@ static CONFIG_BUILDER: Lazy<RwLock<Config>> = Lazy::new(|| {
|
|||||||
include_str!("../Revolt.test.toml"),
|
include_str!("../Revolt.test.toml"),
|
||||||
FileFormat::Toml,
|
FileFormat::Toml,
|
||||||
));
|
));
|
||||||
|
|
||||||
|
// recursively search upwards for an overrides file (if there is one)
|
||||||
|
if let Ok(cwd) = std::env::current_dir() {
|
||||||
|
let mut path = Some(cwd.as_path());
|
||||||
|
while let Some(current_path) = path {
|
||||||
|
let target_path = current_path.join(TEST_OVERRIDE_PATH);
|
||||||
|
if target_path.exists() {
|
||||||
|
builder = builder
|
||||||
|
.add_source(File::new(target_path.to_str().unwrap(), FileFormat::Toml));
|
||||||
|
}
|
||||||
|
|
||||||
|
path = current_path.parent();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for path in CONFIG_SEARCH_PATHS {
|
for path in CONFIG_SEARCH_PATHS {
|
||||||
@@ -388,6 +405,11 @@ pub async fn read() -> Config {
|
|||||||
pub async fn config() -> Settings {
|
pub async fn config() -> Settings {
|
||||||
let mut config = read().await.try_deserialize::<Settings>().unwrap();
|
let mut config = read().await.try_deserialize::<Settings>().unwrap();
|
||||||
|
|
||||||
|
// inject REDIS_URI for redis-kiss library
|
||||||
|
if std::env::var("REDIS_URL").is_err() {
|
||||||
|
std::env::set_var("REDIS_URI", config.database.redis.clone());
|
||||||
|
}
|
||||||
|
|
||||||
// auto-detect production nodes
|
// auto-detect production nodes
|
||||||
if config.hosts.api.contains("https") && config.hosts.api.contains("revolt.chat") {
|
if config.hosts.api.contains("https") && config.hosts.api.contains("revolt.chat") {
|
||||||
config.production = true;
|
config.production = true;
|
||||||
@@ -406,12 +428,6 @@ pub async fn setup_logging(release: &'static str, dsn: String) -> Option<sentry:
|
|||||||
std::env::set_var("ROCKET_ADDRESS", "0.0.0.0");
|
std::env::set_var("ROCKET_ADDRESS", "0.0.0.0");
|
||||||
}
|
}
|
||||||
|
|
||||||
if std::env::var("REDIS_URL").is_err() {
|
|
||||||
// Configure redis-kiss library
|
|
||||||
let config = config().await;
|
|
||||||
std::env::set_var("REDIS_URI", config.database.redis);
|
|
||||||
}
|
|
||||||
|
|
||||||
pretty_env_logger::init();
|
pretty_env_logger::init();
|
||||||
log::info!("Starting {release}");
|
log::info!("Starting {release}");
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-database"
|
name = "revolt-database"
|
||||||
version = "0.8.7"
|
version = "0.8.8"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "AGPL-3.0-or-later"
|
license = "AGPL-3.0-or-later"
|
||||||
authors = ["Paul Makles <me@insrt.uk>"]
|
authors = ["Paul Makles <me@insrt.uk>"]
|
||||||
@@ -24,19 +24,19 @@ default = ["mongodb", "async-std-runtime", "tasks"]
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# Core
|
# Core
|
||||||
revolt-config = { version = "0.8.7", path = "../config", features = [
|
revolt-config = { version = "0.8.8", path = "../config", features = [
|
||||||
"report-macros",
|
"report-macros",
|
||||||
] }
|
] }
|
||||||
revolt-result = { version = "0.8.7", path = "../result" }
|
revolt-result = { version = "0.8.8", path = "../result" }
|
||||||
revolt-models = { version = "0.8.7", path = "../models", features = [
|
revolt-models = { version = "0.8.8", path = "../models", features = [
|
||||||
"validator",
|
"validator",
|
||||||
] }
|
] }
|
||||||
revolt-presence = { version = "0.8.7", path = "../presence" }
|
revolt-presence = { version = "0.8.8", path = "../presence" }
|
||||||
revolt-permissions = { version = "0.8.7", path = "../permissions", features = [
|
revolt-permissions = { version = "0.8.8", path = "../permissions", features = [
|
||||||
"serde",
|
"serde",
|
||||||
"bson",
|
"bson",
|
||||||
] }
|
] }
|
||||||
revolt-parser = { version = "0.8.7", path = "../parser" }
|
revolt-parser = { version = "0.8.8", path = "../parser" }
|
||||||
|
|
||||||
# Utility
|
# Utility
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
|
|||||||
@@ -3,18 +3,21 @@
|
|||||||
"_object_type": "User",
|
"_object_type": "User",
|
||||||
"_id": "__ID:0__",
|
"_id": "__ID:0__",
|
||||||
"username": "Owner",
|
"username": "Owner",
|
||||||
|
"last_acknowledged_policy_change": "2025-06-07T04:04:48+0000",
|
||||||
"discriminator": "0001"
|
"discriminator": "0001"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"_object_type": "User",
|
"_object_type": "User",
|
||||||
"_id": "__ID:1__",
|
"_id": "__ID:1__",
|
||||||
"username": "Member",
|
"username": "Member",
|
||||||
|
"last_acknowledged_policy_change": "2025-06-07T04:04:48+0000",
|
||||||
"discriminator": "0001"
|
"discriminator": "0001"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"_object_type": "User",
|
"_object_type": "User",
|
||||||
"_id": "__ID:2__",
|
"_id": "__ID:2__",
|
||||||
"username": "Member",
|
"username": "Member",
|
||||||
|
"last_acknowledged_policy_change": "2025-06-07T04:04:48+0000",
|
||||||
"discriminator": "0002"
|
"discriminator": "0002"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -23,6 +26,9 @@
|
|||||||
"channel_type": "Group",
|
"channel_type": "Group",
|
||||||
"name": "My Group",
|
"name": "My Group",
|
||||||
"owner": "__ID:0__",
|
"owner": "__ID:0__",
|
||||||
"recipients": ["__ID:0__", "__ID:1__"]
|
"recipients": [
|
||||||
|
"__ID:0__",
|
||||||
|
"__ID:1__"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -3,18 +3,21 @@
|
|||||||
"_object_type": "User",
|
"_object_type": "User",
|
||||||
"_id": "__ID:0__",
|
"_id": "__ID:0__",
|
||||||
"username": "Owner",
|
"username": "Owner",
|
||||||
|
"last_acknowledged_policy_change": "2025-06-07T04:04:48+0000",
|
||||||
"discriminator": "0001"
|
"discriminator": "0001"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"_object_type": "User",
|
"_object_type": "User",
|
||||||
"_id": "__ID:1__",
|
"_id": "__ID:1__",
|
||||||
"username": "Moderator",
|
"username": "Moderator",
|
||||||
|
"last_acknowledged_policy_change": "2025-06-07T04:04:48+0000",
|
||||||
"discriminator": "0001"
|
"discriminator": "0001"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"_object_type": "User",
|
"_object_type": "User",
|
||||||
"_id": "__ID:2__",
|
"_id": "__ID:2__",
|
||||||
"username": "User",
|
"username": "User",
|
||||||
|
"last_acknowledged_policy_change": "2025-06-07T04:04:48+0000",
|
||||||
"discriminator": "0001"
|
"discriminator": "0001"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -39,7 +42,9 @@
|
|||||||
"_id": "__ID:4__",
|
"_id": "__ID:4__",
|
||||||
"owner": "__ID:0__",
|
"owner": "__ID:0__",
|
||||||
"name": "Server",
|
"name": "Server",
|
||||||
"channels": ["__ID:3__"],
|
"channels": [
|
||||||
|
"__ID:3__"
|
||||||
|
],
|
||||||
"roles": {
|
"roles": {
|
||||||
"__ID:5__": {
|
"__ID:5__": {
|
||||||
"name": "Moderator",
|
"name": "Moderator",
|
||||||
@@ -47,7 +52,7 @@
|
|||||||
"a": 545270208,
|
"a": 545270208,
|
||||||
"d": 0
|
"d": 0
|
||||||
},
|
},
|
||||||
"rank": 3
|
"rank": 1
|
||||||
},
|
},
|
||||||
"__ID:6__": {
|
"__ID:6__": {
|
||||||
"name": "Owner",
|
"name": "Owner",
|
||||||
@@ -66,7 +71,9 @@
|
|||||||
"user": "__ID:0__",
|
"user": "__ID:0__",
|
||||||
"server": "__ID:4__"
|
"server": "__ID:4__"
|
||||||
},
|
},
|
||||||
"roles": ["__ID:6__"],
|
"roles": [
|
||||||
|
"__ID:6__"
|
||||||
|
],
|
||||||
"joined_at": 1698318340195
|
"joined_at": 1698318340195
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -75,7 +82,9 @@
|
|||||||
"user": "__ID:1__",
|
"user": "__ID:1__",
|
||||||
"server": "__ID:4__"
|
"server": "__ID:4__"
|
||||||
},
|
},
|
||||||
"roles": ["__ID:5__"],
|
"roles": [
|
||||||
|
"__ID:5__"
|
||||||
|
],
|
||||||
"joined_at": 1698318340195
|
"joined_at": 1698318340195
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -86,4 +95,4 @@
|
|||||||
},
|
},
|
||||||
"joined_at": 1698318340195
|
"joined_at": 1698318340195
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -165,6 +165,9 @@ pub enum EventV1 {
|
|||||||
/// Server role deleted
|
/// Server role deleted
|
||||||
ServerRoleDelete { id: String, role_id: String },
|
ServerRoleDelete { id: String, role_id: String },
|
||||||
|
|
||||||
|
/// Server roles ranks updated
|
||||||
|
ServerRoleRanksUpdate { id: String, ranks: Vec<String> },
|
||||||
|
|
||||||
/// Update existing user
|
/// Update existing user
|
||||||
UserUpdate {
|
UserUpdate {
|
||||||
id: String,
|
id: String,
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
use std::{collections::HashSet, ops::BitXor, time::Duration};
|
use std::{
|
||||||
|
collections::{HashMap, HashSet},
|
||||||
|
ops::BitXor,
|
||||||
|
time::Duration,
|
||||||
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
mongodb::{
|
mongodb::{
|
||||||
@@ -22,7 +26,7 @@ struct MigrationInfo {
|
|||||||
revision: i32,
|
revision: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const LATEST_REVISION: i32 = 41; // MUST BE +1 to last migration
|
pub const LATEST_REVISION: i32 = 42; // MUST BE +1 to last migration
|
||||||
|
|
||||||
pub async fn migrate_database(db: &MongoDb) {
|
pub async fn migrate_database(db: &MongoDb) {
|
||||||
let migrations = db.col::<Document>("migrations");
|
let migrations = db.col::<Document>("migrations");
|
||||||
@@ -1165,6 +1169,63 @@ pub async fn run_migrations(db: &MongoDb, revision: i32) -> i32 {
|
|||||||
.expect("failed to update users");
|
.expect("failed to update users");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if revision <= 41 {
|
||||||
|
info!(
|
||||||
|
"Running migration [revision 41 / 05-06-2025]: convert role ranks to uniform numbers."
|
||||||
|
);
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Clone)]
|
||||||
|
struct Role {
|
||||||
|
pub rank: i64,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Clone)]
|
||||||
|
struct Server {
|
||||||
|
#[serde(rename = "_id")]
|
||||||
|
pub id: String,
|
||||||
|
#[serde(default = "HashMap::<String, Role>::new")]
|
||||||
|
pub roles: HashMap<String, Role>,
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut servers = db
|
||||||
|
.db()
|
||||||
|
.collection::<Server>("servers")
|
||||||
|
.find(doc! {
|
||||||
|
"roles": {
|
||||||
|
"$exists": true,
|
||||||
|
"$ne": []
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.unwrap()
|
||||||
|
.filter_map(|s| async { s.ok() })
|
||||||
|
.boxed();
|
||||||
|
|
||||||
|
while let Some(server) = servers.next().await {
|
||||||
|
let mut ordered_roles = server.roles.clone().into_iter().collect::<Vec<_>>();
|
||||||
|
ordered_roles.sort_by(|(_, role_a), (_, role_b)| role_a.rank.cmp(&role_b.rank));
|
||||||
|
let ordered_roles = ordered_roles
|
||||||
|
.into_iter()
|
||||||
|
.map(|(id, _)| id)
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
|
let mut doc = doc! {};
|
||||||
|
|
||||||
|
for id in server.roles.keys() {
|
||||||
|
doc.insert(
|
||||||
|
format!("roles.{id}.rank"),
|
||||||
|
ordered_roles.iter().position(|x| id == x).unwrap() as i64,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
db.db()
|
||||||
|
.collection::<Server>("servers")
|
||||||
|
.update_one(doc! { "_id": &server.id }, doc! { "$set": doc })
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Reminder to update LATEST_REVISION when adding new migrations.
|
// Reminder to update LATEST_REVISION when adding new migrations.
|
||||||
LATEST_REVISION.max(revision)
|
LATEST_REVISION.max(revision)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ impl Server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Update server data
|
/// Update server data
|
||||||
pub async fn update<'a>(
|
pub async fn update(
|
||||||
&mut self,
|
&mut self,
|
||||||
db: &Database,
|
db: &Database,
|
||||||
partial: PartialServer,
|
partial: PartialServer,
|
||||||
@@ -228,6 +228,13 @@ impl Server {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Ordered roles list
|
||||||
|
pub fn ordered_roles(&self) -> Vec<(String, Role)> {
|
||||||
|
let mut ordered_roles = self.roles.clone().into_iter().collect::<Vec<_>>();
|
||||||
|
ordered_roles.sort_by(|(_, role_a), (_, role_b)| role_a.rank.cmp(&role_b.rank));
|
||||||
|
ordered_roles
|
||||||
|
}
|
||||||
|
|
||||||
/// Set role permission on a server
|
/// Set role permission on a server
|
||||||
pub async fn set_role_permission(
|
pub async fn set_role_permission(
|
||||||
&mut self,
|
&mut self,
|
||||||
@@ -253,6 +260,37 @@ impl Server {
|
|||||||
Err(create_error!(NotFound))
|
Err(create_error!(NotFound))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Reorders the server's roles rankings
|
||||||
|
pub async fn set_role_ordering(&mut self, db: &Database, new_order: Vec<String>) -> Result<()> {
|
||||||
|
// New order must always contain every role
|
||||||
|
debug_assert_eq!(self.roles.len(), new_order.len());
|
||||||
|
|
||||||
|
// Set the role's ranks to the positions in the vec
|
||||||
|
for (rank, id) in new_order.iter().enumerate() {
|
||||||
|
self.roles.get_mut(id).unwrap().rank = rank as i64;
|
||||||
|
}
|
||||||
|
|
||||||
|
db.update_server(
|
||||||
|
&self.id,
|
||||||
|
&PartialServer {
|
||||||
|
roles: Some(self.roles.clone()),
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
Vec::new(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
// Publish bulk update event
|
||||||
|
EventV1::ServerRoleRanksUpdate {
|
||||||
|
id: self.id.clone(),
|
||||||
|
ranks: new_order,
|
||||||
|
}
|
||||||
|
.p(self.id.clone())
|
||||||
|
.await;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Role {
|
impl Role {
|
||||||
|
|||||||
@@ -7,11 +7,5 @@ mod rocket;
|
|||||||
#[cfg(feature = "rocket-impl")]
|
#[cfg(feature = "rocket-impl")]
|
||||||
mod schema;
|
mod schema;
|
||||||
|
|
||||||
#[cfg(feature = "axum-impl")]
|
|
||||||
pub use self::axum::*;
|
|
||||||
#[cfg(feature = "rocket-impl")]
|
|
||||||
pub use self::rocket::*;
|
|
||||||
#[cfg(feature = "rocket-impl")]
|
|
||||||
pub use self::schema::*;
|
|
||||||
pub use model::*;
|
pub use model::*;
|
||||||
pub use ops::*;
|
pub use ops::*;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
use authifier::models::Session;
|
use authifier::models::Session;
|
||||||
|
use iso8601_timestamp::Timestamp;
|
||||||
use revolt_result::Result;
|
use revolt_result::Result;
|
||||||
|
|
||||||
use crate::{FieldsUser, PartialUser, RelationshipStatus, User};
|
use crate::{FieldsUser, PartialUser, RelationshipStatus, User};
|
||||||
@@ -61,4 +62,6 @@ pub trait AbstractUsers: Sync + Send {
|
|||||||
|
|
||||||
/// Remove push subscription for a session by session id (TODO: remove)
|
/// Remove push subscription for a session by session id (TODO: remove)
|
||||||
async fn remove_push_subscription_by_session_id(&self, session_id: &str) -> Result<()>;
|
async fn remove_push_subscription_by_session_id(&self, session_id: &str) -> Result<()>;
|
||||||
|
|
||||||
|
async fn update_session_last_seen(&self, session_id: &str, when: Timestamp) -> Result<()>;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
use ::mongodb::options::{Collation, CollationStrength, FindOneOptions, FindOptions};
|
use ::mongodb::options::{Collation, CollationStrength, FindOneOptions, FindOptions};
|
||||||
use authifier::models::Session;
|
use authifier::models::Session;
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
|
use iso8601_timestamp::Timestamp;
|
||||||
use revolt_result::Result;
|
use revolt_result::Result;
|
||||||
|
|
||||||
use crate::DocumentId;
|
use crate::DocumentId;
|
||||||
@@ -211,16 +212,34 @@ impl AbstractUsers for MongoDb {
|
|||||||
partial: &PartialUser,
|
partial: &PartialUser,
|
||||||
remove: Vec<FieldsUser>,
|
remove: Vec<FieldsUser>,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
query!(
|
if remove.contains(&FieldsUser::StatusText) && partial.status.is_some() {
|
||||||
self,
|
// stupid-ass workaround to fix mongo conflicting the same item
|
||||||
update_one_by_id,
|
let _: Result<()> = query!(
|
||||||
COL,
|
self,
|
||||||
id,
|
update_one_by_id,
|
||||||
partial,
|
COL,
|
||||||
remove.iter().map(|x| x as &dyn IntoDocumentPath).collect(),
|
id,
|
||||||
None
|
PartialUser {
|
||||||
)
|
..Default::default()
|
||||||
.map(|_| ())
|
},
|
||||||
|
remove.iter().map(|x| x as &dyn IntoDocumentPath).collect(),
|
||||||
|
None
|
||||||
|
)
|
||||||
|
.map(|_| ());
|
||||||
|
|
||||||
|
query!(self, update_one_by_id, COL, id, partial, vec![], None).map(|_| ())
|
||||||
|
} else {
|
||||||
|
query!(
|
||||||
|
self,
|
||||||
|
update_one_by_id,
|
||||||
|
COL,
|
||||||
|
id,
|
||||||
|
partial,
|
||||||
|
remove.iter().map(|x| x as &dyn IntoDocumentPath).collect(),
|
||||||
|
None
|
||||||
|
)
|
||||||
|
.map(|_| ())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set relationship with another user
|
/// Set relationship with another user
|
||||||
@@ -317,7 +336,26 @@ impl AbstractUsers for MongoDb {
|
|||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.map(|_| ())
|
.map(|_| ())
|
||||||
.map_err(|_| create_database_error!("update_one", COL))
|
.map_err(|_| create_database_error!("update_one", "sessions"))
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn update_session_last_seen(&self, session_id: &str, when: Timestamp) -> Result<()> {
|
||||||
|
let formatted: &str = &when.format();
|
||||||
|
|
||||||
|
self.col::<Session>("sessions")
|
||||||
|
.update_one(
|
||||||
|
doc! {
|
||||||
|
"_id": session_id
|
||||||
|
},
|
||||||
|
doc! {
|
||||||
|
"$set": {
|
||||||
|
"last_seen": formatted
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.map(|_| ())
|
||||||
|
.map_err(|_| create_database_error!("update_one", "sessions"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
use authifier::models::Session;
|
use authifier::models::Session;
|
||||||
|
use iso8601_timestamp::Timestamp;
|
||||||
use revolt_result::Result;
|
use revolt_result::Result;
|
||||||
|
|
||||||
use crate::{FieldsUser, PartialUser, RelationshipStatus, User};
|
use crate::{FieldsUser, PartialUser, RelationshipStatus, User};
|
||||||
@@ -168,4 +169,8 @@ impl AbstractUsers for ReferenceDb {
|
|||||||
async fn remove_push_subscription_by_session_id(&self, _session_id: &str) -> Result<()> {
|
async fn remove_push_subscription_by_session_id(&self, _session_id: &str) -> Result<()> {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn update_session_last_seen(&self, _session_id: &str, _when: Timestamp) -> Result<()> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use once_cell::sync::Lazy;
|
|||||||
|
|
||||||
use crate::events::client::EventV1;
|
use crate::events::client::EventV1;
|
||||||
|
|
||||||
static Q: Lazy<(Sender<AuthifierEvent>, Receiver<AuthifierEvent>)> = Lazy::new(|| unbounded());
|
static Q: Lazy<(Sender<AuthifierEvent>, Receiver<AuthifierEvent>)> = Lazy::new(unbounded);
|
||||||
|
|
||||||
/// Get sender
|
/// Get sender
|
||||||
pub fn sender() -> Sender<AuthifierEvent> {
|
pub fn sender() -> Sender<AuthifierEvent> {
|
||||||
|
|||||||
@@ -15,8 +15,7 @@ impl crate::Bot {
|
|||||||
avatar: user.avatar.map(|x| x.id).unwrap_or_default(),
|
avatar: user.avatar.map(|x| x.id).unwrap_or_default(),
|
||||||
description: user
|
description: user
|
||||||
.profile
|
.profile
|
||||||
.map(|profile| profile.content)
|
.and_then(|profile| profile.content)
|
||||||
.flatten()
|
|
||||||
.unwrap_or_default(),
|
.unwrap_or_default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1114,7 +1113,7 @@ impl crate::User {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Convert user object into user model without presence information
|
/// Convert user object into user model without presence information
|
||||||
pub async fn into_known_static<'a>(self, is_online: bool) -> User {
|
pub async fn into_known_static(self, is_online: bool) -> User {
|
||||||
let badges = self.get_badges().await;
|
let badges = self.get_badges().await;
|
||||||
|
|
||||||
User {
|
User {
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ use revolt_rocket_okapi::{
|
|||||||
use schemars::schema::{InstanceType, SchemaObject, SingleOrVec};
|
use schemars::schema::{InstanceType, SchemaObject, SingleOrVec};
|
||||||
|
|
||||||
#[cfg(feature = "rocket-impl")]
|
#[cfg(feature = "rocket-impl")]
|
||||||
impl<'r> OpenApiFromRequest<'r> for IdempotencyKey {
|
impl OpenApiFromRequest<'_> for IdempotencyKey {
|
||||||
fn from_request_input(
|
fn from_request_input(
|
||||||
_gen: &mut OpenApiGenerator,
|
_gen: &mut OpenApiGenerator,
|
||||||
_name: String,
|
_name: String,
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ impl PermissionQuery for DatabasePermissionQuery<'_> {
|
|||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
|
|
||||||
self.cached_mutual_connection = Some(value);
|
self.cached_mutual_connection = Some(value);
|
||||||
matches!(value, true)
|
value
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-files"
|
name = "revolt-files"
|
||||||
version = "0.8.7"
|
version = "0.8.8"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "AGPL-3.0-or-later"
|
license = "AGPL-3.0-or-later"
|
||||||
authors = ["Paul Makles <me@insrt.uk>"]
|
authors = ["Paul Makles <me@insrt.uk>"]
|
||||||
@@ -20,10 +20,10 @@ typenum = "1.17.0"
|
|||||||
aws-config = "1.5.5"
|
aws-config = "1.5.5"
|
||||||
aws-sdk-s3 = { version = "1.46.0", features = ["behavior-version-latest"] }
|
aws-sdk-s3 = { version = "1.46.0", features = ["behavior-version-latest"] }
|
||||||
|
|
||||||
revolt-config = { version = "0.8.7", path = "../config", features = [
|
revolt-config = { version = "0.8.8", path = "../config", features = [
|
||||||
"report-macros",
|
"report-macros",
|
||||||
] }
|
] }
|
||||||
revolt-result = { version = "0.8.7", path = "../result" }
|
revolt-result = { version = "0.8.8", path = "../result" }
|
||||||
|
|
||||||
# image processing
|
# image processing
|
||||||
jxl-oxide = "0.8.1"
|
jxl-oxide = "0.8.1"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-models"
|
name = "revolt-models"
|
||||||
version = "0.8.7"
|
version = "0.8.8"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
authors = ["Paul Makles <me@insrt.uk>"]
|
authors = ["Paul Makles <me@insrt.uk>"]
|
||||||
@@ -20,8 +20,8 @@ default = ["serde", "partials", "rocket"]
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# Core
|
# Core
|
||||||
revolt-config = { version = "0.8.7", path = "../config" }
|
revolt-config = { version = "0.8.8", path = "../config" }
|
||||||
revolt-permissions = { version = "0.8.7", path = "../permissions" }
|
revolt-permissions = { version = "0.8.8", path = "../permissions" }
|
||||||
|
|
||||||
# Utility
|
# Utility
|
||||||
regex = "1.11"
|
regex = "1.11"
|
||||||
|
|||||||
@@ -132,8 +132,8 @@ auto_derived!(
|
|||||||
#[cfg_attr(feature = "validator", validate(length(min = 1, max = 2048)))]
|
#[cfg_attr(feature = "validator", validate(length(min = 1, max = 2048)))]
|
||||||
pub interactions_url: Option<String>,
|
pub interactions_url: Option<String>,
|
||||||
/// Fields to remove from bot object
|
/// Fields to remove from bot object
|
||||||
#[cfg_attr(feature = "validator", validate(length(min = 1)))]
|
#[cfg_attr(feature = "serde", serde(default))]
|
||||||
pub remove: Option<Vec<FieldsBot>>,
|
pub remove: Vec<FieldsBot>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Where we are inviting a bot to
|
/// Where we are inviting a bot to
|
||||||
|
|||||||
@@ -207,7 +207,7 @@ auto_derived!(
|
|||||||
|
|
||||||
/// Fields to remove from channel
|
/// Fields to remove from channel
|
||||||
#[cfg_attr(feature = "serde", serde(default))]
|
#[cfg_attr(feature = "serde", serde(default))]
|
||||||
pub remove: Option<Vec<FieldsChannel>>,
|
pub remove: Vec<FieldsChannel>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create new group
|
/// Create new group
|
||||||
@@ -310,14 +310,14 @@ impl Channel {
|
|||||||
/// This returns a Result because the recipient name can't be determined here without a db call,
|
/// This returns a Result because the recipient name can't be determined here without a db call,
|
||||||
/// which can't be done since this is models, which can't reference the database crate.
|
/// which can't be done since this is models, which can't reference the database crate.
|
||||||
///
|
///
|
||||||
/// If it returns Err, you need to fetch the name from the db.
|
/// If it returns None, you need to fetch the name from the db.
|
||||||
pub fn name(&self) -> Result<&str, ()> {
|
pub fn name(&self) -> Option<&str> {
|
||||||
match self {
|
match self {
|
||||||
Channel::DirectMessage { .. } => Err(()),
|
Channel::DirectMessage { .. } => None,
|
||||||
Channel::SavedMessages { .. } => Ok("Saved Messages"),
|
Channel::SavedMessages { .. } => Some("Saved Messages"),
|
||||||
Channel::TextChannel { name, .. }
|
Channel::TextChannel { name, .. }
|
||||||
| Channel::Group { name, .. }
|
| Channel::Group { name, .. }
|
||||||
| Channel::VoiceChannel { name, .. } => Ok(name),
|
| Channel::VoiceChannel { name, .. } => Some(name),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -215,7 +215,7 @@ auto_derived!(
|
|||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
#[cfg_attr(feature = "validator", derive(Validate))]
|
#[cfg_attr(feature = "validator", derive(Validate))]
|
||||||
pub struct SendableEmbed {
|
pub struct SendableEmbed {
|
||||||
#[cfg_attr(feature = "validator", validate(length(min = 1, max = 128)))]
|
#[cfg_attr(feature = "validator", validate(length(min = 1, max = 256)))]
|
||||||
pub icon_url: Option<String>,
|
pub icon_url: Option<String>,
|
||||||
#[cfg_attr(feature = "validator", validate(length(min = 1, max = 256)))]
|
#[cfg_attr(feature = "validator", validate(length(min = 1, max = 256)))]
|
||||||
pub url: Option<String>,
|
pub url: Option<String>,
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ auto_derived!(
|
|||||||
/// Timestamp this member is timed out until
|
/// Timestamp this member is timed out until
|
||||||
pub timeout: Option<Timestamp>,
|
pub timeout: Option<Timestamp>,
|
||||||
/// Fields to remove from channel object
|
/// Fields to remove from channel object
|
||||||
#[cfg_attr(feature = "validator", validate(length(min = 1)))]
|
#[cfg_attr(feature = "serde", serde(default))]
|
||||||
pub remove: Option<Vec<FieldsMember>>,
|
pub remove: Vec<FieldsMember>,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -175,6 +175,8 @@ auto_derived!(
|
|||||||
/// Ranking position
|
/// Ranking position
|
||||||
///
|
///
|
||||||
/// Smaller values take priority.
|
/// Smaller values take priority.
|
||||||
|
///
|
||||||
|
/// **Removed** - no effect, use the edit server role positions route
|
||||||
pub rank: Option<i64>,
|
pub rank: Option<i64>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -247,8 +249,8 @@ auto_derived!(
|
|||||||
pub analytics: Option<bool>,
|
pub analytics: Option<bool>,
|
||||||
|
|
||||||
/// Fields to remove from server object
|
/// Fields to remove from server object
|
||||||
#[cfg_attr(feature = "validator", validate(length(min = 1)))]
|
#[cfg_attr(feature = "serde", serde(default))]
|
||||||
pub remove: Option<Vec<FieldsServer>>,
|
pub remove: Vec<FieldsServer>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// New role information
|
/// New role information
|
||||||
@@ -267,11 +269,11 @@ auto_derived!(
|
|||||||
pub hoist: Option<bool>,
|
pub hoist: Option<bool>,
|
||||||
/// Ranking position
|
/// Ranking position
|
||||||
///
|
///
|
||||||
/// Smaller values take priority.
|
/// **Removed** - no effect, use the edit server role positions route
|
||||||
pub rank: Option<i64>,
|
pub rank: Option<i64>,
|
||||||
/// Fields to remove from role object
|
/// Fields to remove from role object
|
||||||
#[cfg_attr(feature = "validator", validate(length(min = 1)))]
|
#[cfg_attr(feature = "serde", serde(default))]
|
||||||
pub remove: Option<Vec<FieldsRole>>,
|
pub remove: Vec<FieldsRole>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// New role permissions
|
/// New role permissions
|
||||||
@@ -286,4 +288,9 @@ auto_derived!(
|
|||||||
/// Whether to not send a leave message
|
/// Whether to not send a leave message
|
||||||
pub leave_silently: Option<bool>,
|
pub leave_silently: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// New role positions
|
||||||
|
pub struct DataEditRoleRanks {
|
||||||
|
pub ranks: Vec<String>,
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -245,8 +245,8 @@ auto_derived!(
|
|||||||
pub flags: Option<i32>,
|
pub flags: Option<i32>,
|
||||||
|
|
||||||
/// Fields to remove from user object
|
/// Fields to remove from user object
|
||||||
#[cfg_attr(feature = "validator", validate(length(min = 1)))]
|
#[cfg_attr(feature = "serde", serde(default))]
|
||||||
pub remove: Option<Vec<FieldsUser>>,
|
pub remove: Vec<FieldsUser>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// User flag reponse
|
/// User flag reponse
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-parser"
|
name = "revolt-parser"
|
||||||
version = "0.8.7"
|
version = "0.8.8"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "AGPL-3.0-or-later"
|
license = "AGPL-3.0-or-later"
|
||||||
description = "Revolt Backend: Message Parser"
|
description = "Revolt Backend: Message Parser"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-permissions"
|
name = "revolt-permissions"
|
||||||
version = "0.8.7"
|
version = "0.8.8"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
authors = ["Paul Makles <me@insrt.uk>"]
|
authors = ["Paul Makles <me@insrt.uk>"]
|
||||||
@@ -21,7 +21,7 @@ async-std = { version = "1.8.0", features = ["attributes"] }
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# Core
|
# Core
|
||||||
revolt-result = { version = "0.8.7", path = "../result" }
|
revolt-result = { version = "0.8.8", path = "../result" }
|
||||||
|
|
||||||
# Utility
|
# Utility
|
||||||
auto_ops = "0.3.0"
|
auto_ops = "0.3.0"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-presence"
|
name = "revolt-presence"
|
||||||
version = "0.8.7"
|
version = "0.8.8"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "AGPL-3.0-or-later"
|
license = "AGPL-3.0-or-later"
|
||||||
authors = ["Paul Makles <me@insrt.uk>"]
|
authors = ["Paul Makles <me@insrt.uk>"]
|
||||||
@@ -15,6 +15,9 @@ redis-is-patched = []
|
|||||||
# Async
|
# Async
|
||||||
async-std = { version = "1.8.0", features = ["attributes"] }
|
async-std = { version = "1.8.0", features = ["attributes"] }
|
||||||
|
|
||||||
|
# Config for loading Redis URI
|
||||||
|
revolt-config = { version = "0.8.8", path = "../config" }
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# Utility
|
# Utility
|
||||||
log = "0.4.17"
|
log = "0.4.17"
|
||||||
|
|||||||
@@ -197,6 +197,8 @@ mod tests {
|
|||||||
|
|
||||||
#[async_std::test]
|
#[async_std::test]
|
||||||
async fn it_works() {
|
async fn it_works() {
|
||||||
|
revolt_config::config().await;
|
||||||
|
|
||||||
// Clear the region before we start the tests:
|
// Clear the region before we start the tests:
|
||||||
clear_region(None).await;
|
clear_region(None).await;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-result"
|
name = "revolt-result"
|
||||||
version = "0.8.7"
|
version = "0.8.8"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
authors = ["Paul Makles <me@insrt.uk>"]
|
authors = ["Paul Makles <me@insrt.uk>"]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-crond"
|
name = "revolt-crond"
|
||||||
version = "0.8.7"
|
version = "0.8.8"
|
||||||
license = "AGPL-3.0-or-later"
|
license = "AGPL-3.0-or-later"
|
||||||
authors = ["Paul Makles <me@insrt.uk>"]
|
authors = ["Paul Makles <me@insrt.uk>"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
@@ -16,7 +16,7 @@ log = "0.4"
|
|||||||
tokio = { version = "1" }
|
tokio = { version = "1" }
|
||||||
|
|
||||||
# Core
|
# Core
|
||||||
revolt-database = { version = "0.8.7", path = "../../core/database" }
|
revolt-database = { version = "0.8.8", path = "../../core/database" }
|
||||||
revolt-result = { version = "0.8.7", path = "../../core/result" }
|
revolt-result = { version = "0.8.8", path = "../../core/result" }
|
||||||
revolt-config = { version = "0.8.7", path = "../../core/config" }
|
revolt-config = { version = "0.8.8", path = "../../core/config" }
|
||||||
revolt-files = { version = "0.8.7", path = "../../core/files" }
|
revolt-files = { version = "0.8.8", path = "../../core/files" }
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-pushd"
|
name = "revolt-pushd"
|
||||||
version = "0.8.7"
|
version = "0.8.8"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "AGPL-3.0-or-later"
|
license = "AGPL-3.0-or-later"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
revolt-result = { version = "0.8.7", path = "../../core/result" }
|
revolt-result = { version = "0.8.8", path = "../../core/result" }
|
||||||
revolt-config = { version = "0.8.7", path = "../../core/config", features = [
|
revolt-config = { version = "0.8.8", path = "../../core/config", features = [
|
||||||
"report-macros",
|
"report-macros",
|
||||||
] }
|
] }
|
||||||
revolt-database = { version = "0.8.7", path = "../../core/database" }
|
revolt-database = { version = "0.8.8", path = "../../core/database" }
|
||||||
revolt-models = { version = "0.8.7", path = "../../core/models", features = [
|
revolt-models = { version = "0.8.8", path = "../../core/models", features = [
|
||||||
"validator",
|
"validator",
|
||||||
] }
|
] }
|
||||||
revolt-presence = { version = "0.8.7", path = "../../core/presence", features = [
|
revolt-presence = { version = "0.8.8", path = "../../core/presence", features = [
|
||||||
"redis-is-patched",
|
"redis-is-patched",
|
||||||
] }
|
] }
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-delta"
|
name = "revolt-delta"
|
||||||
version = "0.8.7"
|
version = "0.8.8"
|
||||||
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"
|
||||||
|
|||||||
114
crates/delta/fixtures/server_with_many_roles.json
Normal file
114
crates/delta/fixtures/server_with_many_roles.json
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"_object_type": "User",
|
||||||
|
"_id": "__ID:0__",
|
||||||
|
"username": "Owner",
|
||||||
|
"last_acknowledged_policy_change": "2025-06-07T04:04:48+0000",
|
||||||
|
"discriminator": "0001"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"_object_type": "User",
|
||||||
|
"_id": "__ID:1__",
|
||||||
|
"username": "Moderator",
|
||||||
|
"last_acknowledged_policy_change": "2025-06-07T04:04:48+0000",
|
||||||
|
"discriminator": "0001"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"_object_type": "User",
|
||||||
|
"_id": "__ID:2__",
|
||||||
|
"username": "User",
|
||||||
|
"last_acknowledged_policy_change": "2025-06-07T04:04:48+0000",
|
||||||
|
"discriminator": "0001"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"_object_type": "Channel",
|
||||||
|
"_id": "__ID:3__",
|
||||||
|
"channel_type": "TextChannel",
|
||||||
|
"name": "General",
|
||||||
|
"server": "__ID:4__",
|
||||||
|
"default_permissions": {
|
||||||
|
"a": 0,
|
||||||
|
"d": 1048576
|
||||||
|
},
|
||||||
|
"role_permissions": {
|
||||||
|
"__ID:5__": {
|
||||||
|
"a": 1048576,
|
||||||
|
"d": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"_object_type": "Server",
|
||||||
|
"_id": "__ID:4__",
|
||||||
|
"owner": "__ID:0__",
|
||||||
|
"name": "Server",
|
||||||
|
"channels": [
|
||||||
|
"__ID:3__"
|
||||||
|
],
|
||||||
|
"roles": {
|
||||||
|
"__ID:5__": {
|
||||||
|
"name": "Moderator",
|
||||||
|
"permissions": {
|
||||||
|
"a": 545270216,
|
||||||
|
"d": 0
|
||||||
|
},
|
||||||
|
"rank": 1
|
||||||
|
},
|
||||||
|
"__ID:6__": {
|
||||||
|
"name": "Owner",
|
||||||
|
"permissions": {
|
||||||
|
"a": 0,
|
||||||
|
"d": 0
|
||||||
|
},
|
||||||
|
"rank": 0
|
||||||
|
},
|
||||||
|
"__ID:7__": {
|
||||||
|
"name": "Lower Rank 1",
|
||||||
|
"permissions": {
|
||||||
|
"a": 0,
|
||||||
|
"d": 0
|
||||||
|
},
|
||||||
|
"rank": 2
|
||||||
|
},
|
||||||
|
"__ID:8__": {
|
||||||
|
"name": "Lower Rank 2",
|
||||||
|
"permissions": {
|
||||||
|
"a": 0,
|
||||||
|
"d": 0
|
||||||
|
},
|
||||||
|
"rank": 2
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"default_permissions": 4000322560
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"_object_type": "ServerMember",
|
||||||
|
"_id": {
|
||||||
|
"user": "__ID:0__",
|
||||||
|
"server": "__ID:4__"
|
||||||
|
},
|
||||||
|
"roles": [
|
||||||
|
"__ID:6__"
|
||||||
|
],
|
||||||
|
"joined_at": 1698318340195
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"_object_type": "ServerMember",
|
||||||
|
"_id": {
|
||||||
|
"user": "__ID:1__",
|
||||||
|
"server": "__ID:4__"
|
||||||
|
},
|
||||||
|
"roles": [
|
||||||
|
"__ID:5__"
|
||||||
|
],
|
||||||
|
"joined_at": 1698318340195
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"_object_type": "ServerMember",
|
||||||
|
"_id": {
|
||||||
|
"user": "__ID:2__",
|
||||||
|
"server": "__ID:4__"
|
||||||
|
},
|
||||||
|
"joined_at": 1698318340195
|
||||||
|
}
|
||||||
|
]
|
||||||
@@ -37,7 +37,7 @@ pub async fn edit_bot(
|
|||||||
if data.public.is_none()
|
if data.public.is_none()
|
||||||
&& data.analytics.is_none()
|
&& data.analytics.is_none()
|
||||||
&& data.interactions_url.is_none()
|
&& data.interactions_url.is_none()
|
||||||
&& data.remove.is_none()
|
&& data.remove.is_empty()
|
||||||
{
|
{
|
||||||
return Ok(Json(v0::BotWithUserResponse {
|
return Ok(Json(v0::BotWithUserResponse {
|
||||||
bot: bot.into(),
|
bot: bot.into(),
|
||||||
@@ -64,7 +64,6 @@ pub async fn edit_bot(
|
|||||||
db,
|
db,
|
||||||
partial,
|
partial,
|
||||||
remove
|
remove
|
||||||
.unwrap_or_default()
|
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|v| v.into())
|
.map(|v| v.into())
|
||||||
.collect(),
|
.collect(),
|
||||||
@@ -100,7 +99,7 @@ mod test {
|
|||||||
.body(
|
.body(
|
||||||
json!(v0::DataEditBot {
|
json!(v0::DataEditBot {
|
||||||
public: Some(true),
|
public: Some(true),
|
||||||
remove: Some(vec![FieldsBot::Token]),
|
remove: vec![FieldsBot::Token],
|
||||||
..Default::default()
|
..Default::default()
|
||||||
})
|
})
|
||||||
.to_string(),
|
.to_string(),
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ pub async fn fetch_public_bot(
|
|||||||
target: Reference,
|
target: Reference,
|
||||||
) -> Result<Json<PublicBot>> {
|
) -> Result<Json<PublicBot>> {
|
||||||
let bot = db.fetch_bot(&target.id).await?;
|
let bot = db.fetch_bot(&target.id).await?;
|
||||||
if !bot.public && user.map_or(true, |x| x.id != bot.owner) {
|
if !bot.public && user.is_none_or(|x| x.id != bot.owner) {
|
||||||
return Err(create_error!(NotFound));
|
return Err(create_error!(NotFound));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ pub async fn edit(
|
|||||||
&& data.icon.is_none()
|
&& data.icon.is_none()
|
||||||
&& data.nsfw.is_none()
|
&& data.nsfw.is_none()
|
||||||
&& data.owner.is_none()
|
&& data.owner.is_none()
|
||||||
&& data.remove.is_none()
|
&& data.remove.is_empty()
|
||||||
{
|
{
|
||||||
return Ok(Json(channel.into()));
|
return Ok(Json(channel.into()));
|
||||||
}
|
}
|
||||||
@@ -112,23 +112,21 @@ pub async fn edit(
|
|||||||
nsfw,
|
nsfw,
|
||||||
..
|
..
|
||||||
} => {
|
} => {
|
||||||
if let Some(fields) = &data.remove {
|
if data.remove.contains(&v0::FieldsChannel::Icon) {
|
||||||
if fields.contains(&v0::FieldsChannel::Icon) {
|
if let Some(icon) = &icon {
|
||||||
if let Some(icon) = &icon {
|
db.mark_attachment_as_deleted(&icon.id).await?;
|
||||||
db.mark_attachment_as_deleted(&icon.id).await?;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for field in fields {
|
for field in &data.remove {
|
||||||
match field {
|
match field {
|
||||||
v0::FieldsChannel::Description => {
|
v0::FieldsChannel::Description => {
|
||||||
description.take();
|
description.take();
|
||||||
}
|
|
||||||
v0::FieldsChannel::Icon => {
|
|
||||||
icon.take();
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
|
v0::FieldsChannel::Icon => {
|
||||||
|
icon.take();
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,11 +212,7 @@ pub async fn edit(
|
|||||||
.update(
|
.update(
|
||||||
db,
|
db,
|
||||||
partial,
|
partial,
|
||||||
data.remove
|
data.remove.into_iter().map(|f| f.into()).collect(),
|
||||||
.unwrap_or_default()
|
|
||||||
.into_iter()
|
|
||||||
.map(|f| f.into())
|
|
||||||
.collect(),
|
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,7 +84,8 @@ pub async fn message_send(
|
|||||||
// Create model user / members
|
// Create model user / members
|
||||||
let model_user = user
|
let model_user = user
|
||||||
.clone()
|
.clone()
|
||||||
.into_known_static(revolt_presence::is_online(&user.id).await).await;
|
.into_known_static(revolt_presence::is_online(&user.id).await)
|
||||||
|
.await;
|
||||||
|
|
||||||
let model_member: Option<v0::Member> = query
|
let model_member: Option<v0::Member> = query
|
||||||
.member_ref()
|
.member_ref()
|
||||||
@@ -491,7 +492,7 @@ mod test {
|
|||||||
let (_, _, other_user) = harness.new_user().await;
|
let (_, _, other_user) = harness.new_user().await;
|
||||||
let (server, _) = harness.new_server(&user).await;
|
let (server, _) = harness.new_server(&user).await;
|
||||||
let channel = harness.new_channel(&server).await;
|
let channel = harness.new_channel(&server).await;
|
||||||
let (role_id, mut role) = harness
|
let (role_id, _role) = harness
|
||||||
.new_role(
|
.new_role(
|
||||||
&server,
|
&server,
|
||||||
1,
|
1,
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ pub fn routes() -> (Vec<Route>, OpenApi) {
|
|||||||
group_remove_member::remove_member,
|
group_remove_member::remove_member,
|
||||||
voice_join::call,
|
voice_join::call,
|
||||||
permissions_set::set_role_permissions,
|
permissions_set::set_role_permissions,
|
||||||
permissions_set_default::set_default_permissions,
|
permissions_set_default::set_default_channel_permissions,
|
||||||
message_react::react_message,
|
message_react::react_message,
|
||||||
message_unreact::unreact_message,
|
message_unreact::unreact_message,
|
||||||
message_clear_reactions::clear_reactions,
|
message_clear_reactions::clear_reactions,
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ use rocket::{serde::json::Json, State};
|
|||||||
/// Channel must be a `Group`, `TextChannel` or `VoiceChannel`.
|
/// Channel must be a `Group`, `TextChannel` or `VoiceChannel`.
|
||||||
#[openapi(tag = "Channel Permissions")]
|
#[openapi(tag = "Channel Permissions")]
|
||||||
#[put("/<target>/permissions/default", data = "<data>", rank = 1)]
|
#[put("/<target>/permissions/default", data = "<data>", rank = 1)]
|
||||||
pub async fn set_default_permissions(
|
pub async fn set_default_channel_permissions(
|
||||||
db: &State<Database>,
|
db: &State<Database>,
|
||||||
user: User,
|
user: User,
|
||||||
target: Reference,
|
target: Reference,
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ pub async fn call(
|
|||||||
// - If not, create it.
|
// - If not, create it.
|
||||||
let client = reqwest::Client::new();
|
let client = reqwest::Client::new();
|
||||||
let result = client
|
let result = client
|
||||||
.get(&format!(
|
.get(format!(
|
||||||
"{}/room/{}",
|
"{}/room/{}",
|
||||||
config.hosts.voso_legacy,
|
config.hosts.voso_legacy,
|
||||||
channel.id()
|
channel.id()
|
||||||
@@ -59,7 +59,7 @@ pub async fn call(
|
|||||||
reqwest::StatusCode::OK => (),
|
reqwest::StatusCode::OK => (),
|
||||||
reqwest::StatusCode::NOT_FOUND => {
|
reqwest::StatusCode::NOT_FOUND => {
|
||||||
if (client
|
if (client
|
||||||
.post(&format!(
|
.post(format!(
|
||||||
"{}/room/{}",
|
"{}/room/{}",
|
||||||
config.hosts.voso_legacy,
|
config.hosts.voso_legacy,
|
||||||
channel.id()
|
channel.id()
|
||||||
@@ -81,7 +81,7 @@ pub async fn call(
|
|||||||
|
|
||||||
// Then create a user for the room.
|
// Then create a user for the room.
|
||||||
if let Ok(response) = client
|
if let Ok(response) = client
|
||||||
.post(&format!(
|
.post(format!(
|
||||||
"{}/room/{}/user/{}",
|
"{}/room/{}/user/{}",
|
||||||
config.hosts.voso_legacy,
|
config.hosts.voso_legacy,
|
||||||
channel.id(),
|
channel.id(),
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
use revolt_database::{events::client::EventV1, Database, Report, Snapshot, SnapshotContent, User};
|
use revolt_database::{Database, User};
|
||||||
use revolt_models::v0::{ReportStatus, ReportedContent};
|
use revolt_result::Result;
|
||||||
use revolt_result::{create_error, Result};
|
|
||||||
use serde::Deserialize;
|
|
||||||
use ulid::Ulid;
|
|
||||||
use validator::Validate;
|
|
||||||
|
|
||||||
use rocket::{serde::json::Json, State};
|
use rocket::State;
|
||||||
|
|
||||||
/// # Acknowledge Policy Changes
|
/// # Acknowledge Policy Changes
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -136,7 +136,6 @@ pub async fn root() -> Result<Json<RevoltConfig>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
#[cfg(feature = "FIXME: THIS TEST CAUSES cargo test TO SEG FAULT, I HAVE NO CLUE HOW")]
|
|
||||||
mod test {
|
mod test {
|
||||||
use crate::rocket;
|
use crate::rocket;
|
||||||
use rocket::http::Status;
|
use rocket::http::Status;
|
||||||
|
|||||||
@@ -39,13 +39,7 @@ pub async fn edit(
|
|||||||
let permissions = calculate_server_permissions(&mut query).await;
|
let permissions = calculate_server_permissions(&mut query).await;
|
||||||
|
|
||||||
// Check permissions in server
|
// Check permissions in server
|
||||||
if data.nickname.is_some()
|
if data.nickname.is_some() || data.remove.contains(&v0::FieldsMember::Nickname) {
|
||||||
|| data
|
|
||||||
.remove
|
|
||||||
.as_ref()
|
|
||||||
.map(|x| x.contains(&v0::FieldsMember::Nickname))
|
|
||||||
.unwrap_or_default()
|
|
||||||
{
|
|
||||||
if user.id == member.id.user {
|
if user.id == member.id.user {
|
||||||
permissions.throw_if_lacking_channel_permission(ChannelPermission::ChangeNickname)?;
|
permissions.throw_if_lacking_channel_permission(ChannelPermission::ChangeNickname)?;
|
||||||
} else {
|
} else {
|
||||||
@@ -53,13 +47,7 @@ pub async fn edit(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if data.avatar.is_some()
|
if data.avatar.is_some() || data.remove.contains(&v0::FieldsMember::Avatar) {
|
||||||
|| data
|
|
||||||
.remove
|
|
||||||
.as_ref()
|
|
||||||
.map(|x| x.contains(&v0::FieldsMember::Avatar))
|
|
||||||
.unwrap_or_default()
|
|
||||||
{
|
|
||||||
if user.id == member.id.user {
|
if user.id == member.id.user {
|
||||||
permissions.throw_if_lacking_channel_permission(ChannelPermission::ChangeAvatar)?;
|
permissions.throw_if_lacking_channel_permission(ChannelPermission::ChangeAvatar)?;
|
||||||
} else {
|
} else {
|
||||||
@@ -67,23 +55,11 @@ pub async fn edit(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if data.roles.is_some()
|
if data.roles.is_some() || data.remove.contains(&v0::FieldsMember::Roles) {
|
||||||
|| data
|
|
||||||
.remove
|
|
||||||
.as_ref()
|
|
||||||
.map(|x| x.contains(&v0::FieldsMember::Roles))
|
|
||||||
.unwrap_or_default()
|
|
||||||
{
|
|
||||||
permissions.throw_if_lacking_channel_permission(ChannelPermission::AssignRoles)?;
|
permissions.throw_if_lacking_channel_permission(ChannelPermission::AssignRoles)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if data.timeout.is_some()
|
if data.timeout.is_some() || data.remove.contains(&v0::FieldsMember::Timeout) {
|
||||||
|| data
|
|
||||||
.remove
|
|
||||||
.as_ref()
|
|
||||||
.map(|x| x.contains(&v0::FieldsMember::Timeout))
|
|
||||||
.unwrap_or_default()
|
|
||||||
{
|
|
||||||
if data.timeout.is_some() && member.id.user == user.id {
|
if data.timeout.is_some() && member.id.user == user.id {
|
||||||
return Err(create_error!(CannotTimeoutYourself));
|
return Err(create_error!(CannotTimeoutYourself));
|
||||||
}
|
}
|
||||||
@@ -136,11 +112,9 @@ pub async fn edit(
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 1. Remove fields from object
|
// 1. Remove fields from object
|
||||||
if let Some(fields) = &remove {
|
if remove.contains(&v0::FieldsMember::Avatar) {
|
||||||
if fields.contains(&v0::FieldsMember::Avatar) {
|
if let Some(avatar) = &member.avatar {
|
||||||
if let Some(avatar) = &member.avatar {
|
db.mark_attachment_as_deleted(&avatar.id).await?;
|
||||||
db.mark_attachment_as_deleted(&avatar.id).await?;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,13 +124,7 @@ pub async fn edit(
|
|||||||
}
|
}
|
||||||
|
|
||||||
member
|
member
|
||||||
.update(
|
.update(db, partial, remove.into_iter().map(Into::into).collect())
|
||||||
db,
|
|
||||||
partial,
|
|
||||||
remove
|
|
||||||
.map(|v| v.into_iter().map(Into::into).collect())
|
|
||||||
.unwrap_or_default(),
|
|
||||||
)
|
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
Ok(Json(member.into()))
|
Ok(Json(member.into()))
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ mod permissions_set_default;
|
|||||||
mod roles_create;
|
mod roles_create;
|
||||||
mod roles_delete;
|
mod roles_delete;
|
||||||
mod roles_edit;
|
mod roles_edit;
|
||||||
|
mod roles_edit_positions;
|
||||||
mod roles_fetch;
|
mod roles_fetch;
|
||||||
mod server_ack;
|
mod server_ack;
|
||||||
mod server_create;
|
mod server_create;
|
||||||
@@ -46,7 +47,8 @@ pub fn routes() -> (Vec<Route>, OpenApi) {
|
|||||||
roles_fetch::fetch,
|
roles_fetch::fetch,
|
||||||
roles_delete::delete,
|
roles_delete::delete,
|
||||||
permissions_set::set_role_permission,
|
permissions_set::set_role_permission,
|
||||||
permissions_set_default::set_default_permissions,
|
permissions_set_default::set_default_server_permissions,
|
||||||
emoji_list::list_emoji
|
emoji_list::list_emoji,
|
||||||
|
roles_edit_positions::edit_role_ranks
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ use rocket::{serde::json::Json, State};
|
|||||||
/// Sets permissions for the default role in this server.
|
/// Sets permissions for the default role in this server.
|
||||||
#[openapi(tag = "Server Permissions")]
|
#[openapi(tag = "Server Permissions")]
|
||||||
#[put("/<target>/permissions/default", data = "<data>", rank = 1)]
|
#[put("/<target>/permissions/default", data = "<data>", rank = 1)]
|
||||||
pub async fn set_default_permissions(
|
pub async fn set_default_server_permissions(
|
||||||
db: &State<Database>,
|
db: &State<Database>,
|
||||||
user: User,
|
user: User,
|
||||||
target: Reference,
|
target: Reference,
|
||||||
|
|||||||
@@ -40,20 +40,10 @@ pub async fn create(
|
|||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
let member_rank = query.get_member_rank();
|
|
||||||
let rank = if let Some(given_rank) = data.rank {
|
|
||||||
if given_rank <= member_rank.unwrap_or(i64::MIN) {
|
|
||||||
return Err(create_error!(NotElevated));
|
|
||||||
}
|
|
||||||
|
|
||||||
given_rank
|
|
||||||
} else {
|
|
||||||
member_rank.unwrap_or(0).saturating_add(1)
|
|
||||||
};
|
|
||||||
|
|
||||||
let role = Role {
|
let role = Role {
|
||||||
name: data.name,
|
name: data.name,
|
||||||
rank,
|
// Rank of the new role should be below the lowest role
|
||||||
|
rank: server.roles.len() as i64,
|
||||||
colour: None,
|
colour: None,
|
||||||
hoist: false,
|
hoist: false,
|
||||||
permissions: Default::default(),
|
permissions: Default::default(),
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ use validator::Validate;
|
|||||||
///
|
///
|
||||||
/// Edit a role by its id.
|
/// Edit a role by its id.
|
||||||
#[openapi(tag = "Server Permissions")]
|
#[openapi(tag = "Server Permissions")]
|
||||||
#[patch("/<target>/roles/<role_id>", data = "<data>")]
|
#[patch("/<target>/roles/<role_id>", data = "<data>", rank = 1)]
|
||||||
pub async fn edit(
|
pub async fn edit(
|
||||||
db: &State<Database>,
|
db: &State<Database>,
|
||||||
user: User,
|
user: User,
|
||||||
@@ -45,22 +45,14 @@ pub async fn edit(
|
|||||||
name,
|
name,
|
||||||
colour,
|
colour,
|
||||||
hoist,
|
hoist,
|
||||||
rank,
|
|
||||||
remove,
|
remove,
|
||||||
|
..
|
||||||
} = data;
|
} = data;
|
||||||
|
|
||||||
// Prevent us from moving a role above other roles
|
|
||||||
if let Some(rank) = &rank {
|
|
||||||
if rank <= &member_rank {
|
|
||||||
return Err(create_error!(NotElevated));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let partial = PartialRole {
|
let partial = PartialRole {
|
||||||
name,
|
name,
|
||||||
colour,
|
colour,
|
||||||
hoist,
|
hoist,
|
||||||
rank,
|
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -69,9 +61,7 @@ pub async fn edit(
|
|||||||
&server.id,
|
&server.id,
|
||||||
&role_id,
|
&role_id,
|
||||||
partial,
|
partial,
|
||||||
remove
|
remove.into_iter().map(Into::into).collect(),
|
||||||
.map(|v| v.into_iter().map(Into::into).collect())
|
|
||||||
.unwrap_or_default(),
|
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
|||||||
177
crates/delta/src/routes/servers/roles_edit_positions.rs
Normal file
177
crates/delta/src/routes/servers/roles_edit_positions.rs
Normal file
@@ -0,0 +1,177 @@
|
|||||||
|
use revolt_database::{
|
||||||
|
util::{permissions::DatabasePermissionQuery, reference::Reference},
|
||||||
|
Database, User,
|
||||||
|
};
|
||||||
|
use revolt_models::v0;
|
||||||
|
use revolt_permissions::{calculate_server_permissions, ChannelPermission};
|
||||||
|
use revolt_result::{create_error, Result};
|
||||||
|
use rocket::{serde::json::Json, State};
|
||||||
|
|
||||||
|
/// # Edits server roles ranks
|
||||||
|
///
|
||||||
|
/// Edit's server role's ranks.
|
||||||
|
#[openapi(tag = "Server Permissions")]
|
||||||
|
#[patch("/<target>/roles/ranks", data = "<data>")]
|
||||||
|
pub async fn edit_role_ranks(
|
||||||
|
db: &State<Database>,
|
||||||
|
user: User,
|
||||||
|
target: Reference,
|
||||||
|
data: Json<v0::DataEditRoleRanks>,
|
||||||
|
) -> Result<Json<v0::Server>> {
|
||||||
|
let data = data.into_inner();
|
||||||
|
|
||||||
|
let mut server = target.as_server(db).await?;
|
||||||
|
let mut query = DatabasePermissionQuery::new(db, &user).server(&server);
|
||||||
|
calculate_server_permissions(&mut query)
|
||||||
|
.await
|
||||||
|
.throw_if_lacking_channel_permission(ChannelPermission::ManageRole)?;
|
||||||
|
|
||||||
|
let existing_order = server
|
||||||
|
.ordered_roles()
|
||||||
|
.into_iter()
|
||||||
|
.map(|(id, _)| id)
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
|
let new_order = data.ranks.clone().into_iter().collect::<Vec<_>>();
|
||||||
|
|
||||||
|
// Verify all roles are in the new ordering
|
||||||
|
if data.ranks.len() != server.roles.len()
|
||||||
|
|| !server.roles.iter().all(|(id, _)| data.ranks.contains(id))
|
||||||
|
{
|
||||||
|
return Err(create_error!(InvalidOperation));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Don't have to check what the user can't modify if they are the server owner
|
||||||
|
if server.owner != user.id {
|
||||||
|
let member_top_rank = query.get_member_rank();
|
||||||
|
|
||||||
|
if server
|
||||||
|
.roles
|
||||||
|
.iter()
|
||||||
|
// Find all roles above the member which we should not be able to reorder
|
||||||
|
.filter(|(_, role)| {
|
||||||
|
if let Some(top_rank) = member_top_rank {
|
||||||
|
role.rank <= top_rank
|
||||||
|
} else {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
// Check if user is trying to reorder roles they can't reorder (as found previously)
|
||||||
|
.any(|(id, _)| {
|
||||||
|
existing_order
|
||||||
|
.iter()
|
||||||
|
.position(|existing_id| id == existing_id)
|
||||||
|
!= new_order.iter().position(|new_id| id == new_id)
|
||||||
|
})
|
||||||
|
{
|
||||||
|
return Err(create_error!(NotElevated));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
server.set_role_ordering(db, new_order).await?;
|
||||||
|
|
||||||
|
Ok(Json(server.into()))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod test {
|
||||||
|
use revolt_database::fixture;
|
||||||
|
use revolt_models::v0;
|
||||||
|
use rocket::http::{ContentType, Header, Status};
|
||||||
|
|
||||||
|
use crate::util::test::TestHarness;
|
||||||
|
|
||||||
|
#[rocket::async_test]
|
||||||
|
async fn edit_role_rankings() {
|
||||||
|
let harness = TestHarness::new().await;
|
||||||
|
|
||||||
|
fixture!(harness.db, "server_with_many_roles",
|
||||||
|
owner user 0
|
||||||
|
moderator user 1
|
||||||
|
server server 4);
|
||||||
|
|
||||||
|
// Moderator can re-order the roles below them
|
||||||
|
let (_, moderator_session) = harness.account_from_user(moderator.id).await;
|
||||||
|
let mut target_order: Vec<String> = server
|
||||||
|
.ordered_roles()
|
||||||
|
.into_iter()
|
||||||
|
.map(|(id, _)| id)
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
// Swap the two lower ranked roles
|
||||||
|
target_order.swap(2, 3);
|
||||||
|
|
||||||
|
let response = harness
|
||||||
|
.client
|
||||||
|
.patch(format!("/servers/{}/roles/ranks", server.id))
|
||||||
|
.header(ContentType::JSON)
|
||||||
|
.body(
|
||||||
|
json!(v0::DataEditRoleRanks {
|
||||||
|
ranks: target_order.clone()
|
||||||
|
})
|
||||||
|
.to_string(),
|
||||||
|
)
|
||||||
|
.header(Header::new(
|
||||||
|
"x-session-token",
|
||||||
|
moderator_session.token.to_string(),
|
||||||
|
))
|
||||||
|
.dispatch()
|
||||||
|
.await;
|
||||||
|
|
||||||
|
assert_eq!(response.status(), Status::Ok);
|
||||||
|
drop(response);
|
||||||
|
|
||||||
|
// ... but not above them
|
||||||
|
let mut target_order: Vec<String> = server
|
||||||
|
.ordered_roles()
|
||||||
|
.into_iter()
|
||||||
|
.map(|(id, _)| id)
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
// Swap the two lower ranked roles
|
||||||
|
target_order.swap(0, 1);
|
||||||
|
|
||||||
|
let response = harness
|
||||||
|
.client
|
||||||
|
.patch(format!("/servers/{}/roles/ranks", server.id))
|
||||||
|
.header(ContentType::JSON)
|
||||||
|
.body(
|
||||||
|
json!(v0::DataEditRoleRanks {
|
||||||
|
ranks: target_order.clone()
|
||||||
|
})
|
||||||
|
.to_string(),
|
||||||
|
)
|
||||||
|
.header(Header::new(
|
||||||
|
"x-session-token",
|
||||||
|
moderator_session.token.to_string(),
|
||||||
|
))
|
||||||
|
.dispatch()
|
||||||
|
.await;
|
||||||
|
|
||||||
|
assert_eq!(response.status(), Status::Forbidden);
|
||||||
|
drop(response);
|
||||||
|
|
||||||
|
// The owner can set any order they want
|
||||||
|
let (_, owner_session) = harness.account_from_user(owner.id).await;
|
||||||
|
|
||||||
|
let response = harness
|
||||||
|
.client
|
||||||
|
.patch(format!("/servers/{}/roles/ranks", server.id))
|
||||||
|
.header(ContentType::JSON)
|
||||||
|
.body(
|
||||||
|
json!(v0::DataEditRoleRanks {
|
||||||
|
ranks: target_order.clone()
|
||||||
|
})
|
||||||
|
.to_string(),
|
||||||
|
)
|
||||||
|
.header(Header::new(
|
||||||
|
"x-session-token",
|
||||||
|
owner_session.token.to_string(),
|
||||||
|
))
|
||||||
|
.dispatch()
|
||||||
|
.await;
|
||||||
|
|
||||||
|
assert_eq!(response.status(), Status::Ok);
|
||||||
|
drop(response);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -43,7 +43,7 @@ pub async fn edit(
|
|||||||
&& data.flags.is_none()
|
&& data.flags.is_none()
|
||||||
&& data.analytics.is_none()
|
&& data.analytics.is_none()
|
||||||
&& data.discoverable.is_none()
|
&& data.discoverable.is_none()
|
||||||
&& data.remove.is_none()
|
&& data.remove.is_empty()
|
||||||
{
|
{
|
||||||
return Ok(Json(server.into()));
|
return Ok(Json(server.into()));
|
||||||
} else if data.name.is_some()
|
} else if data.name.is_some()
|
||||||
@@ -52,7 +52,7 @@ pub async fn edit(
|
|||||||
|| data.banner.is_some()
|
|| data.banner.is_some()
|
||||||
|| data.system_messages.is_some()
|
|| data.system_messages.is_some()
|
||||||
|| data.analytics.is_some()
|
|| data.analytics.is_some()
|
||||||
|| data.remove.is_some()
|
|| !data.remove.is_empty()
|
||||||
{
|
{
|
||||||
permissions.throw_if_lacking_channel_permission(ChannelPermission::ManageServer)?;
|
permissions.throw_if_lacking_channel_permission(ChannelPermission::ManageServer)?;
|
||||||
}
|
}
|
||||||
@@ -96,17 +96,15 @@ pub async fn edit(
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 1. Remove fields from object
|
// 1. Remove fields from object
|
||||||
if let Some(fields) = &remove {
|
if remove.contains(&v0::FieldsServer::Banner) {
|
||||||
if fields.contains(&v0::FieldsServer::Banner) {
|
if let Some(banner) = &server.banner {
|
||||||
if let Some(banner) = &server.banner {
|
db.mark_attachment_as_deleted(&banner.id).await?;
|
||||||
db.mark_attachment_as_deleted(&banner.id).await?;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if fields.contains(&v0::FieldsServer::Icon) {
|
if remove.contains(&v0::FieldsServer::Icon) {
|
||||||
if let Some(icon) = &server.icon {
|
if let Some(icon) = &server.icon {
|
||||||
db.mark_attachment_as_deleted(&icon.id).await?;
|
db.mark_attachment_as_deleted(&icon.id).await?;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,13 +147,7 @@ pub async fn edit(
|
|||||||
}
|
}
|
||||||
|
|
||||||
server
|
server
|
||||||
.update(
|
.update(db, partial, remove.into_iter().map(Into::into).collect())
|
||||||
db,
|
|
||||||
partial,
|
|
||||||
remove
|
|
||||||
.map(|v| v.into_iter().map(Into::into).collect())
|
|
||||||
.unwrap_or_default(),
|
|
||||||
)
|
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
Ok(Json(server.into()))
|
Ok(Json(server.into()))
|
||||||
|
|||||||
@@ -53,31 +53,29 @@ pub async fn edit(
|
|||||||
&& data.avatar.is_none()
|
&& data.avatar.is_none()
|
||||||
&& data.badges.is_none()
|
&& data.badges.is_none()
|
||||||
&& data.flags.is_none()
|
&& data.flags.is_none()
|
||||||
&& data.remove.is_none()
|
&& data.remove.is_empty()
|
||||||
{
|
{
|
||||||
return Ok(Json(user.into_self(false).await));
|
return Ok(Json(user.into_self(false).await));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1. Remove fields from object
|
// 1. Remove fields from object
|
||||||
if let Some(fields) = &data.remove {
|
if data.remove.contains(&v0::FieldsUser::Avatar) {
|
||||||
if fields.contains(&v0::FieldsUser::Avatar) {
|
if let Some(avatar) = &user.avatar {
|
||||||
if let Some(avatar) = &user.avatar {
|
db.mark_attachment_as_deleted(&avatar.id).await?;
|
||||||
db.mark_attachment_as_deleted(&avatar.id).await?;
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if data.remove.contains(&v0::FieldsUser::ProfileBackground) {
|
||||||
|
if let Some(profile) = &user.profile {
|
||||||
|
if let Some(background) = &profile.background {
|
||||||
|
db.mark_attachment_as_deleted(&background.id).await?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if fields.contains(&v0::FieldsUser::ProfileBackground) {
|
for field in &data.remove {
|
||||||
if let Some(profile) = &user.profile {
|
let field: FieldsUser = field.clone().into();
|
||||||
if let Some(background) = &profile.background {
|
user.remove_field(&field);
|
||||||
db.mark_attachment_as_deleted(&background.id).await?;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for field in fields {
|
|
||||||
let field: FieldsUser = field.clone().into();
|
|
||||||
user.remove_field(&field);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut partial: PartialUser = PartialUser {
|
let mut partial: PartialUser = PartialUser {
|
||||||
@@ -124,9 +122,7 @@ pub async fn edit(
|
|||||||
user.update(
|
user.update(
|
||||||
db,
|
db,
|
||||||
partial,
|
partial,
|
||||||
data.remove
|
data.remove.into_iter().map(Into::into).collect(),
|
||||||
.map(|v| v.into_iter().map(Into::into).collect())
|
|
||||||
.unwrap_or_default(),
|
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
|||||||
@@ -36,11 +36,11 @@ pub async fn webhook_execute(
|
|||||||
let permissions: PermissionValue = webhook.permissions.into();
|
let permissions: PermissionValue = webhook.permissions.into();
|
||||||
permissions.throw_if_lacking_channel_permission(ChannelPermission::SendMessage)?;
|
permissions.throw_if_lacking_channel_permission(ChannelPermission::SendMessage)?;
|
||||||
|
|
||||||
if data.attachments.as_ref().map_or(false, |v| !v.is_empty()) {
|
if data.attachments.as_ref().is_some_and(|v| !v.is_empty()) {
|
||||||
permissions.throw_if_lacking_channel_permission(ChannelPermission::UploadFiles)?;
|
permissions.throw_if_lacking_channel_permission(ChannelPermission::UploadFiles)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if data.embeds.as_ref().map_or(false, |v| !v.is_empty()) {
|
if data.embeds.as_ref().is_some_and(|v| !v.is_empty()) {
|
||||||
permissions.throw_if_lacking_channel_permission(ChannelPermission::SendEmbeds)?;
|
permissions.throw_if_lacking_channel_permission(ChannelPermission::SendEmbeds)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -621,7 +621,7 @@ pub struct Event {
|
|||||||
#[derive(Debug, JsonSchema)]
|
#[derive(Debug, JsonSchema)]
|
||||||
pub struct EventHeader<'r>(pub &'r str);
|
pub struct EventHeader<'r>(pub &'r str);
|
||||||
|
|
||||||
impl<'r> std::ops::Deref for EventHeader<'r> {
|
impl std::ops::Deref for EventHeader<'_> {
|
||||||
type Target = str;
|
type Target = str;
|
||||||
|
|
||||||
fn deref(&self) -> &Self::Target {
|
fn deref(&self) -> &Self::Target {
|
||||||
|
|||||||
@@ -109,8 +109,6 @@ fn resolve_bucket<'r>(request: &'r rocket::Request<'_>) -> (&'r str, Option<&'r
|
|||||||
};
|
};
|
||||||
|
|
||||||
if let Some(segment) = segment {
|
if let Some(segment) = segment {
|
||||||
let resource = resource;
|
|
||||||
|
|
||||||
let method = request.method();
|
let method = request.method();
|
||||||
match (segment, resource, method) {
|
match (segment, resource, method) {
|
||||||
("users", target, Method::Patch) => ("user_edit", target),
|
("users", target, Method::Patch) => ("user_edit", target),
|
||||||
@@ -254,7 +252,7 @@ impl<'r> FromRequest<'r> for Ratelimiter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'r> OpenApiFromRequest<'r> for Ratelimiter {
|
impl OpenApiFromRequest<'_> for Ratelimiter {
|
||||||
fn from_request_input(
|
fn from_request_input(
|
||||||
_gen: &mut OpenApiGenerator,
|
_gen: &mut OpenApiGenerator,
|
||||||
_name: String,
|
_name: String,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use authifier::{
|
use authifier::{
|
||||||
models::{Account, Session},
|
models::{Account, EmailVerification, Session},
|
||||||
Authifier,
|
Authifier,
|
||||||
};
|
};
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
@@ -83,30 +83,41 @@ impl TestHarness {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn new_user(&self) -> (Account, Session, User) {
|
pub async fn new_user(&self) -> (Account, Session, User) {
|
||||||
let account = Account::new(
|
let user = User::create(&self.db, TestHarness::rand_string(), None, None)
|
||||||
&self.authifier,
|
.await
|
||||||
format!("{}@revolt.chat", TestHarness::rand_string()),
|
.expect("`User`");
|
||||||
"password".to_string(),
|
|
||||||
false,
|
let (account, session) = self.account_from_user(user.id.clone()).await;
|
||||||
)
|
|
||||||
.await
|
(account, session, user)
|
||||||
.expect("`Account`");
|
}
|
||||||
|
|
||||||
|
pub async fn account_from_user(&self, id: String) -> (Account, Session) {
|
||||||
|
let account = Account {
|
||||||
|
id,
|
||||||
|
email: format!("{}@revolt.chat", TestHarness::rand_string()),
|
||||||
|
password: Default::default(),
|
||||||
|
email_normalised: Default::default(),
|
||||||
|
deletion: None,
|
||||||
|
disabled: false,
|
||||||
|
lockout: None,
|
||||||
|
mfa: Default::default(),
|
||||||
|
password_reset: None,
|
||||||
|
verification: EmailVerification::Verified,
|
||||||
|
};
|
||||||
|
|
||||||
|
self.authifier
|
||||||
|
.database
|
||||||
|
.save_account(&account)
|
||||||
|
.await
|
||||||
|
.expect("`Account`");
|
||||||
|
|
||||||
let session = account
|
let session = account
|
||||||
.create_session(&self.authifier, String::new())
|
.create_session(&self.authifier, String::new())
|
||||||
.await
|
.await
|
||||||
.expect("`Session`");
|
.expect("`Session`");
|
||||||
|
|
||||||
let user = User::create(
|
(account, session)
|
||||||
&self.db,
|
|
||||||
TestHarness::rand_string(),
|
|
||||||
account.id.to_string(),
|
|
||||||
None,
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.expect("`User`");
|
|
||||||
|
|
||||||
(account, session, user)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn new_server(&self, user: &User) -> (Server, Vec<Channel>) {
|
pub async fn new_server(&self, user: &User) -> (Server, Vec<Channel>) {
|
||||||
@@ -198,10 +209,7 @@ impl TestHarness {
|
|||||||
(channel.clone(), member, message)
|
(channel.clone(), member, message)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn with_session<'c>(
|
pub async fn with_session(session: Session, request: LocalRequest<'_>) -> LocalResponse<'_> {
|
||||||
session: Session,
|
|
||||||
request: LocalRequest<'c>,
|
|
||||||
) -> LocalResponse<'c> {
|
|
||||||
request
|
request
|
||||||
.header(Header::new("x-session-token", session.token.to_string()))
|
.header(Header::new("x-session-token", session.token.to_string()))
|
||||||
.dispatch()
|
.dispatch()
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-autumn"
|
name = "revolt-autumn"
|
||||||
version = "0.8.7"
|
version = "0.8.8"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "AGPL-3.0-or-later"
|
license = "AGPL-3.0-or-later"
|
||||||
|
|
||||||
@@ -43,12 +43,12 @@ tracing = "0.1"
|
|||||||
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
|
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
|
||||||
|
|
||||||
# Core crates
|
# Core crates
|
||||||
revolt-files = { version = "0.8.7", path = "../../core/files" }
|
revolt-files = { version = "0.8.8", path = "../../core/files" }
|
||||||
revolt-config = { version = "0.8.7", path = "../../core/config" }
|
revolt-config = { version = "0.8.8", path = "../../core/config" }
|
||||||
revolt-database = { version = "0.8.7", path = "../../core/database", features = [
|
revolt-database = { version = "0.8.8", path = "../../core/database", features = [
|
||||||
"axum-impl",
|
"axum-impl",
|
||||||
] }
|
] }
|
||||||
revolt-result = { version = "0.8.7", path = "../../core/result", features = [
|
revolt-result = { version = "0.8.8", path = "../../core/result", features = [
|
||||||
"utoipa",
|
"utoipa",
|
||||||
"axum",
|
"axum",
|
||||||
] }
|
] }
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-january"
|
name = "revolt-january"
|
||||||
version = "0.8.7"
|
version = "0.8.8"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "AGPL-3.0-or-later"
|
license = "AGPL-3.0-or-later"
|
||||||
|
|
||||||
@@ -32,13 +32,13 @@ tracing = "0.1"
|
|||||||
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
|
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
|
||||||
|
|
||||||
# Core crates
|
# Core crates
|
||||||
revolt-config = { version = "0.8.7", path = "../../core/config" }
|
revolt-config = { version = "0.8.8", path = "../../core/config" }
|
||||||
revolt-models = { version = "0.8.7", path = "../../core/models" }
|
revolt-models = { version = "0.8.8", path = "../../core/models" }
|
||||||
revolt-result = { version = "0.8.7", path = "../../core/result", features = [
|
revolt-result = { version = "0.8.8", path = "../../core/result", features = [
|
||||||
"utoipa",
|
"utoipa",
|
||||||
"axum",
|
"axum",
|
||||||
] }
|
] }
|
||||||
revolt-files = { version = "0.8.7", path = "../../core/files" }
|
revolt-files = { version = "0.8.8", path = "../../core/files" }
|
||||||
|
|
||||||
# Axum / web server
|
# Axum / web server
|
||||||
axum = { version = "0.7.5" }
|
axum = { version = "0.7.5" }
|
||||||
|
|||||||
@@ -327,7 +327,7 @@ pub async fn populate_special(original_url: String, metadata: &mut WebsiteMetada
|
|||||||
Special::Twitch { .. } => metadata.colour = Some("#7B68EE".to_string()),
|
Special::Twitch { .. } => metadata.colour = Some("#7B68EE".to_string()),
|
||||||
Special::Lightspeed { .. } => metadata.colour = Some("#7445D9".to_string()),
|
Special::Lightspeed { .. } => metadata.colour = Some("#7445D9".to_string()),
|
||||||
Special::Spotify { .. } => metadata.colour = Some("#1ABC9C".to_string()),
|
Special::Spotify { .. } => metadata.colour = Some("#1ABC9C".to_string()),
|
||||||
Special::Soundcloud { .. } => metadata.colour = Some("#FF7F50".to_string()),
|
Special::Soundcloud => metadata.colour = Some("#FF7F50".to_string()),
|
||||||
Special::AppleMusic { .. } => metadata.colour = Some("#FA233B".to_string()),
|
Special::AppleMusic { .. } => metadata.colour = Some("#FA233B".to_string()),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
{ pkgs ? import <nixpkgs> {} }:
|
{
|
||||||
|
pkgs ? import <nixpkgs> { },
|
||||||
|
}:
|
||||||
|
|
||||||
pkgs.mkShell rec {
|
pkgs.mkShell rec {
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
# Tools
|
# Tools
|
||||||
pkgs.git
|
pkgs.git
|
||||||
|
pkgs.just
|
||||||
|
|
||||||
# Cargo
|
# Cargo
|
||||||
pkgs.cargo
|
pkgs.cargo
|
||||||
|
|||||||
2
justfile
2
justfile
@@ -1,7 +1,7 @@
|
|||||||
publish:
|
publish:
|
||||||
cargo publish --package revolt-parser
|
cargo publish --package revolt-parser
|
||||||
cargo publish --package revolt-config
|
|
||||||
cargo publish --package revolt-result
|
cargo publish --package revolt-result
|
||||||
|
cargo publish --package revolt-config
|
||||||
cargo publish --package revolt-files
|
cargo publish --package revolt-files
|
||||||
cargo publish --package revolt-permissions
|
cargo publish --package revolt-permissions
|
||||||
cargo publish --package revolt-models
|
cargo publish --package revolt-models
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
date=$(date +'%Y%m%d')
|
date=$(date +'%Y%m%d')
|
||||||
incr=1
|
incr=1
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user