Merge remote-tracking branch 'origin/main' into livekit
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "revolt-delta"
|
||||
version = "0.7.1"
|
||||
version = "0.8.1"
|
||||
license = "AGPL-3.0-or-later"
|
||||
authors = ["Paul Makles <paulmakles@gmail.com>"]
|
||||
edition = "2018"
|
||||
@@ -16,7 +16,6 @@ redis-kiss = "0.1.4"
|
||||
lru = "0.7.0"
|
||||
url = "2.2.2"
|
||||
log = "0.4.11"
|
||||
dotenv = "0.15.0"
|
||||
dashmap = "5.2.0"
|
||||
linkify = "0.6.0"
|
||||
once_cell = "1.17.1"
|
||||
@@ -53,20 +52,21 @@ async-std = { version = "1.8.0", features = [
|
||||
lettre = "0.10.0-alpha.4"
|
||||
|
||||
# web
|
||||
rocket = { version = "0.5.0-rc.2", default-features = false, features = [
|
||||
"json",
|
||||
] }
|
||||
rocket_cors = { git = "https://github.com/lawliet89/rocket_cors", rev = "c17e8145baa4790319fdb6a473e465b960f55e7c" }
|
||||
rocket = { version = "0.5.1", default-features = false, features = ["json"] }
|
||||
rocket_cors = { git = "https://github.com/lawliet89/rocket_cors", rev = "072d90359b23e9b291df6b672c07c93de9c46011" }
|
||||
rocket_empty = { version = "0.1.1", features = ["schema"] }
|
||||
rocket_authifier = { version = "1.0.8" }
|
||||
rocket_authifier = { version = "1.0.9" }
|
||||
rocket_prometheus = "0.10.0-rc.3"
|
||||
|
||||
# spec generation
|
||||
schemars = "0.8.8"
|
||||
revolt_rocket_okapi = { version = "0.9.1", features = ["swagger"] }
|
||||
revolt_rocket_okapi = { version = "0.10.0", features = ["swagger"] }
|
||||
|
||||
# rabbit
|
||||
amqprs = { version = "1.7.0" }
|
||||
|
||||
# core
|
||||
authifier = "1.0.8"
|
||||
authifier = "1.0.9"
|
||||
revolt-config = { path = "../core/config" }
|
||||
revolt-database = { path = "../core/database", features = [
|
||||
"rocket-impl",
|
||||
@@ -77,13 +77,14 @@ revolt-models = { path = "../core/models", features = [
|
||||
"validator",
|
||||
"rocket",
|
||||
] }
|
||||
revolt-presence = { path = "../core/presence" }
|
||||
revolt-result = { path = "../core/result", features = ["rocket", "okapi"] }
|
||||
revolt-permissions = { path = "../core/permissions", features = ["schemas"] }
|
||||
revolt-voice = { path = "../core/voice" }
|
||||
|
||||
# voice
|
||||
livekit-api = "0.3.2"
|
||||
livekit-protocol = "0.3.2"
|
||||
livekit-api = "0.4.1"
|
||||
livekit-protocol = "0.3.6"
|
||||
|
||||
[build-dependencies]
|
||||
vergen = "7.5.0"
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
# Build Stage
|
||||
FROM ghcr.io/revoltchat/base:latest AS builder
|
||||
FROM debian:12 AS debian
|
||||
|
||||
# Bundle Stage
|
||||
FROM debian:bullseye-slim
|
||||
RUN apt-get update && \
|
||||
apt-get install -y ca-certificates && \
|
||||
apt-get clean
|
||||
FROM gcr.io/distroless/cc-debian12:nonroot
|
||||
COPY --from=builder /home/rust/src/target/release/revolt-delta ./
|
||||
COPY --from=debian /usr/bin/uname /usr/bin/uname
|
||||
|
||||
EXPOSE 8000
|
||||
ENV ROCKET_ADDRESS 0.0.0.0
|
||||
ENV ROCKET_PORT 8000
|
||||
EXPOSE 14702
|
||||
ENV ROCKET_ADDRESS=0.0.0.0
|
||||
USER nonroot
|
||||
CMD ["./revolt-delta"]
|
||||
|
||||
@@ -10,19 +10,19 @@ pub mod util;
|
||||
|
||||
use revolt_config::config;
|
||||
use revolt_database::events::client::EventV1;
|
||||
use revolt_database::{Database, MongoDb};
|
||||
use revolt_database::AMQP;
|
||||
use rocket::{Build, Rocket};
|
||||
use rocket_cors::{AllowedOrigins, CorsOptions};
|
||||
use rocket_prometheus::PrometheusMetrics;
|
||||
use std::net::Ipv4Addr;
|
||||
use std::str::FromStr;
|
||||
|
||||
use async_std::channel::unbounded;
|
||||
use authifier::config::{
|
||||
Captcha, Config as AuthifierConfig, EmailVerificationConfig, ResolveIp, SMTPSettings, Shield,
|
||||
Template, Templates,
|
||||
use amqprs::{
|
||||
channel::ExchangeDeclareArguments,
|
||||
connection::{Connection, OpenConnectionArguments},
|
||||
};
|
||||
use authifier::{Authifier, AuthifierEvent};
|
||||
use async_std::channel::unbounded;
|
||||
use authifier::AuthifierEvent;
|
||||
use rocket::data::ToByteUnit;
|
||||
use livekit_api::services::room::RoomClient;
|
||||
|
||||
@@ -39,20 +39,10 @@ pub async fn web() -> Rocket<Build> {
|
||||
db.migrate_database().await.unwrap();
|
||||
|
||||
// Setup Authifier event channel
|
||||
let (sender, receiver) = unbounded();
|
||||
let (_, receiver) = unbounded();
|
||||
|
||||
// Setup Authifier
|
||||
let authifier = Authifier {
|
||||
database: match db.clone() {
|
||||
Database::Reference(_) => Default::default(),
|
||||
Database::MongoDb(MongoDb(client, _)) => authifier::Database::MongoDb(
|
||||
authifier::database::MongoDb(client.database("revolt")),
|
||||
),
|
||||
},
|
||||
config: Default::default(),
|
||||
// config: authifier_config().await,
|
||||
event_channel: Some(sender),
|
||||
};
|
||||
let authifier = db.clone().to_authifier().await;
|
||||
|
||||
// Launch a listener for Authifier events
|
||||
async_std::task::spawn(async move {
|
||||
@@ -70,12 +60,6 @@ pub async fn web() -> Rocket<Build> {
|
||||
}
|
||||
});
|
||||
|
||||
// Launch background task workers
|
||||
async_std::task::spawn(revolt_database::tasks::start_workers(
|
||||
db.clone(),
|
||||
authifier.database.clone(),
|
||||
));
|
||||
|
||||
// Configure CORS
|
||||
let cors = CorsOptions {
|
||||
allowed_origins: AllowedOrigins::All,
|
||||
@@ -101,6 +85,30 @@ pub async fn web() -> Rocket<Build> {
|
||||
|
||||
// Voice handler
|
||||
let voice_client = revolt_voice::VoiceClient::new(config.api.livekit.url.clone(), config.api.livekit.key.clone(), config.api.livekit.secret.clone());
|
||||
// Configure Rabbit
|
||||
let connection = Connection::open(&OpenConnectionArguments::new(
|
||||
&config.rabbit.host,
|
||||
config.rabbit.port,
|
||||
&config.rabbit.username,
|
||||
&config.rabbit.password,
|
||||
))
|
||||
.await
|
||||
.unwrap();
|
||||
let channel = connection.open_channel(None).await.unwrap();
|
||||
|
||||
channel
|
||||
.exchange_declare(
|
||||
ExchangeDeclareArguments::new(&config.pushd.exchange, "direct")
|
||||
.durable(true)
|
||||
.finish(),
|
||||
)
|
||||
.await
|
||||
.expect("Failed to declare exchange");
|
||||
|
||||
let amqp = AMQP::new(connection, channel);
|
||||
|
||||
// Launch background task workers
|
||||
revolt_database::tasks::start_workers(db.clone(), amqp.clone());
|
||||
|
||||
// Configure Rocket
|
||||
let rocket = rocket::build();
|
||||
@@ -114,6 +122,7 @@ pub async fn web() -> Rocket<Build> {
|
||||
.mount("/swagger/", swagger)
|
||||
.manage(authifier)
|
||||
.manage(db)
|
||||
.manage(amqp)
|
||||
.manage(cors.clone())
|
||||
.manage(voice_client)
|
||||
.attach(util::ratelimiter::RatelimitFairing)
|
||||
@@ -121,82 +130,11 @@ pub async fn web() -> Rocket<Build> {
|
||||
.configure(rocket::Config {
|
||||
limits: rocket::data::Limits::default().limit("string", 5.megabytes()),
|
||||
address: Ipv4Addr::new(0, 0, 0, 0).into(),
|
||||
port: 14702,
|
||||
..Default::default()
|
||||
})
|
||||
}
|
||||
|
||||
pub async fn authifier_config() -> AuthifierConfig {
|
||||
let config = config().await;
|
||||
|
||||
let mut auth_config = AuthifierConfig {
|
||||
email_verification: if !config.api.smtp.host.is_empty() {
|
||||
EmailVerificationConfig::Enabled {
|
||||
smtp: SMTPSettings {
|
||||
from: config.api.smtp.from_address,
|
||||
host: config.api.smtp.host,
|
||||
username: config.api.smtp.username,
|
||||
password: config.api.smtp.password,
|
||||
reply_to: Some(
|
||||
config
|
||||
.api
|
||||
.smtp
|
||||
.reply_to
|
||||
.unwrap_or("support@revolt.chat".into()),
|
||||
),
|
||||
port: config.api.smtp.port,
|
||||
use_tls: config.api.smtp.use_tls,
|
||||
},
|
||||
expiry: Default::default(),
|
||||
templates: Templates {
|
||||
verify: Template {
|
||||
title: "Verify your Revolt account.".into(),
|
||||
text: include_str!("templates/verify.txt").into(),
|
||||
url: format!("{}/login/verify/", config.hosts.app),
|
||||
html: Some(include_str!("templates/verify.html").into()),
|
||||
},
|
||||
reset: Template {
|
||||
title: "Reset your Revolt password.".into(),
|
||||
text: include_str!("templates/reset.txt").into(),
|
||||
url: format!("{}/login/reset/", config.hosts.app),
|
||||
html: Some(include_str!("templates/reset.html").into()),
|
||||
},
|
||||
deletion: Template {
|
||||
title: "Confirm account deletion.".into(),
|
||||
text: include_str!("templates/deletion.txt").into(),
|
||||
url: format!("{}/delete/", config.hosts.app),
|
||||
html: Some(include_str!("templates/deletion.html").into()),
|
||||
},
|
||||
welcome: None,
|
||||
},
|
||||
}
|
||||
} else {
|
||||
EmailVerificationConfig::Disabled
|
||||
},
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
auth_config.invite_only = config.api.registration.invite_only;
|
||||
|
||||
if !config.api.security.captcha.hcaptcha_key.is_empty() {
|
||||
auth_config.captcha = Captcha::HCaptcha {
|
||||
secret: config.api.security.captcha.hcaptcha_key,
|
||||
};
|
||||
}
|
||||
|
||||
if !config.api.security.authifier_shield_key.is_empty() {
|
||||
auth_config.shield = Shield::Enabled {
|
||||
api_key: config.api.security.authifier_shield_key,
|
||||
strict: false,
|
||||
};
|
||||
}
|
||||
|
||||
if config.api.security.trust_cloudflare {
|
||||
auth_config.resolve_ip = ResolveIp::Cloudflare;
|
||||
}
|
||||
|
||||
auth_config
|
||||
}
|
||||
|
||||
#[launch]
|
||||
async fn rocket() -> _ {
|
||||
// Configure logging and environment
|
||||
|
||||
@@ -14,7 +14,7 @@ pub async fn create_bot(
|
||||
db: &State<Database>,
|
||||
user: User,
|
||||
info: Json<v0::DataCreateBot>,
|
||||
) -> Result<Json<v0::Bot>> {
|
||||
) -> Result<Json<v0::BotWithUserResponse>> {
|
||||
let info = info.into_inner();
|
||||
info.validate().map_err(|error| {
|
||||
create_error!(FailedValidation {
|
||||
@@ -22,8 +22,11 @@ pub async fn create_bot(
|
||||
})
|
||||
})?;
|
||||
|
||||
let bot = Bot::create(db, info.name, &user, None).await?;
|
||||
Ok(Json(bot.into()))
|
||||
let (bot, user) = Bot::create(db, info.name, &user, None).await?;
|
||||
Ok(Json(v0::BotWithUserResponse {
|
||||
bot: bot.into(),
|
||||
user: user.into_self(false).await,
|
||||
}))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -32,7 +32,7 @@ mod test {
|
||||
let mut harness = TestHarness::new().await;
|
||||
let (_, session, user) = harness.new_user().await;
|
||||
|
||||
let bot = Bot::create(&harness.db, TestHarness::rand_string(), &user, None)
|
||||
let (bot, _) = Bot::create(&harness.db, TestHarness::rand_string(), &user, None)
|
||||
.await
|
||||
.expect("`Bot`");
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ pub async fn edit_bot(
|
||||
user: User,
|
||||
target: Reference,
|
||||
data: Json<DataEditBot>,
|
||||
) -> Result<Json<v0::Bot>> {
|
||||
) -> Result<Json<v0::BotWithUserResponse>> {
|
||||
let data = data.into_inner();
|
||||
data.validate().map_err(|error| {
|
||||
create_error!(FailedValidation {
|
||||
@@ -29,8 +29,8 @@ pub async fn edit_bot(
|
||||
return Err(create_error!(NotFound));
|
||||
}
|
||||
|
||||
let mut user = db.fetch_user(&bot.id).await?;
|
||||
if let Some(name) = data.name {
|
||||
let mut user = db.fetch_user(&bot.id).await?;
|
||||
user.update_username(db, name).await?;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,10 @@ pub async fn edit_bot(
|
||||
&& data.interactions_url.is_none()
|
||||
&& data.remove.is_none()
|
||||
{
|
||||
return Ok(Json(bot.into()));
|
||||
return Ok(Json(v0::BotWithUserResponse {
|
||||
bot: bot.into(),
|
||||
user: user.into_self(false).await,
|
||||
}));
|
||||
}
|
||||
|
||||
let DataEditBot {
|
||||
@@ -68,7 +71,10 @@ pub async fn edit_bot(
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(Json(bot.into()))
|
||||
Ok(Json(v0::BotWithUserResponse {
|
||||
bot: bot.into(),
|
||||
user: user.into_self(false).await,
|
||||
}))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -83,7 +89,7 @@ mod test {
|
||||
let harness = TestHarness::new().await;
|
||||
let (_, session, user) = harness.new_user().await;
|
||||
|
||||
let bot = Bot::create(&harness.db, TestHarness::rand_string(), &user, None)
|
||||
let (bot, _) = Bot::create(&harness.db, TestHarness::rand_string(), &user, None)
|
||||
.await
|
||||
.expect("`Bot`");
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ mod test {
|
||||
let harness = TestHarness::new().await;
|
||||
let (_, session, user) = harness.new_user().await;
|
||||
|
||||
let bot = Bot::create(&harness.db, TestHarness::rand_string(), &user, None)
|
||||
let (bot, _) = Bot::create(&harness.db, TestHarness::rand_string(), &user, None)
|
||||
.await
|
||||
.expect("`Bot`");
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ pub async fn fetch_owned_bots(db: &State<Database>, user: User) -> Result<Json<O
|
||||
users.sort_by(|a, b| a.id.cmp(&b.id));
|
||||
|
||||
Ok(Json(OwnedBotsResponse {
|
||||
users: join_all(users.into_iter().map(|user| user.into_self())).await,
|
||||
users: join_all(users.into_iter().map(|user| user.into_self(false))).await,
|
||||
bots: bots.into_iter().map(|bot| bot.into()).collect(),
|
||||
}))
|
||||
}
|
||||
@@ -41,7 +41,7 @@ mod test {
|
||||
let harness = TestHarness::new().await;
|
||||
let (_, session, user) = harness.new_user().await;
|
||||
|
||||
let bot = Bot::create(&harness.db, TestHarness::rand_string(), &user, None)
|
||||
let (bot, _) = Bot::create(&harness.db, TestHarness::rand_string(), &user, None)
|
||||
.await
|
||||
.expect("`Bot`");
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ mod test {
|
||||
let harness = TestHarness::new().await;
|
||||
let (_, _, user) = harness.new_user().await;
|
||||
|
||||
let mut bot = Bot::create(&harness.db, TestHarness::rand_string(), &user, None)
|
||||
let (mut bot, _) = Bot::create(&harness.db, TestHarness::rand_string(), &user, None)
|
||||
.await
|
||||
.expect("`Bot`");
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use revolt_database::util::permissions::DatabasePermissionQuery;
|
||||
use revolt_database::Member;
|
||||
use revolt_database::{util::reference::Reference, Database, User};
|
||||
use revolt_database::{Member, AMQP};
|
||||
use revolt_models::v0;
|
||||
use revolt_permissions::{
|
||||
calculate_channel_permissions, calculate_server_permissions, ChannelPermission,
|
||||
@@ -18,6 +18,7 @@ use rocket_empty::EmptyResponse;
|
||||
#[post("/<target>/invite", data = "<dest>")]
|
||||
pub async fn invite_bot(
|
||||
db: &State<Database>,
|
||||
amqp: &State<AMQP>,
|
||||
user: User,
|
||||
target: Reference,
|
||||
dest: Json<v0::InviteBotDestination>,
|
||||
@@ -55,7 +56,7 @@ pub async fn invite_bot(
|
||||
.throw_if_lacking_channel_permission(ChannelPermission::InviteOthers)?;
|
||||
|
||||
channel
|
||||
.add_user_to_group(db, &bot_user, &user.id)
|
||||
.add_user_to_group(db, amqp, &bot_user, &user.id)
|
||||
.await
|
||||
.map(|_| EmptyResponse)
|
||||
}
|
||||
@@ -74,7 +75,7 @@ mod test {
|
||||
let mut harness = TestHarness::new().await;
|
||||
let (_, session, user) = harness.new_user().await;
|
||||
|
||||
let bot = Bot::create(&harness.db, TestHarness::rand_string(), &user, None)
|
||||
let (bot, _) = Bot::create(&harness.db, TestHarness::rand_string(), &user, None)
|
||||
.await
|
||||
.expect("`Bot`");
|
||||
|
||||
@@ -93,7 +94,12 @@ mod test {
|
||||
.client
|
||||
.post(format!("/bots/{}/invite", bot.id))
|
||||
.header(ContentType::JSON)
|
||||
.body(json!(v0::InviteBotDestination::Group { group: group.id() }).to_string())
|
||||
.body(
|
||||
json!(v0::InviteBotDestination::Group {
|
||||
group: group.id().to_string()
|
||||
})
|
||||
.to_string(),
|
||||
)
|
||||
.header(Header::new("x-session-token", session.token.to_string()))
|
||||
.dispatch()
|
||||
.await;
|
||||
@@ -102,8 +108,8 @@ mod test {
|
||||
drop(response);
|
||||
|
||||
let event = harness
|
||||
.wait_for_event(&group.id(), |event| match event {
|
||||
EventV1::ChannelGroupJoin { id, .. } => id == &group.id(),
|
||||
.wait_for_event(group.id(), |event| match event {
|
||||
EventV1::ChannelGroupJoin { id, .. } => id == group.id(),
|
||||
_ => false,
|
||||
})
|
||||
.await;
|
||||
@@ -121,7 +127,7 @@ mod test {
|
||||
let mut harness = TestHarness::new().await;
|
||||
let (_, session, user) = harness.new_user().await;
|
||||
|
||||
let bot = Bot::create(&harness.db, TestHarness::rand_string(), &user, None)
|
||||
let (bot, _) = Bot::create(&harness.db, TestHarness::rand_string(), &user, None)
|
||||
.await
|
||||
.expect("`Bot`");
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ mod test {
|
||||
|
||||
let event = harness
|
||||
.wait_for_event(&format!("{}!", user.id), |event| match event {
|
||||
EventV1::ChannelAck { id, .. } => id == &group.id(),
|
||||
EventV1::ChannelAck { id, .. } => id == group.id(),
|
||||
_ => false,
|
||||
})
|
||||
.await;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use revolt_database::{
|
||||
util::{permissions::DatabasePermissionQuery, reference::Reference},
|
||||
Channel, Database, PartialChannel, User,
|
||||
Channel, Database, PartialChannel, User, AMQP,
|
||||
};
|
||||
use revolt_models::v0;
|
||||
use revolt_permissions::{calculate_channel_permissions, ChannelPermission};
|
||||
@@ -15,6 +15,7 @@ use rocket_empty::EmptyResponse;
|
||||
#[delete("/<target>?<options..>")]
|
||||
pub async fn delete(
|
||||
db: &State<Database>,
|
||||
amqp: &State<AMQP>,
|
||||
user: User,
|
||||
target: Reference,
|
||||
options: v0::OptionsChannelDelete,
|
||||
@@ -39,7 +40,13 @@ pub async fn delete(
|
||||
.await
|
||||
.map(|_| EmptyResponse),
|
||||
Channel::Group { .. } => channel
|
||||
.remove_user_from_group(db, &user, None, options.leave_silently.unwrap_or_default())
|
||||
.remove_user_from_group(
|
||||
db,
|
||||
amqp,
|
||||
&user,
|
||||
None,
|
||||
options.leave_silently.unwrap_or_default(),
|
||||
)
|
||||
.await
|
||||
.map(|_| EmptyResponse),
|
||||
Channel::TextChannel { .. } | Channel::VoiceChannel { .. } => {
|
||||
@@ -82,8 +89,8 @@ mod test {
|
||||
drop(response);
|
||||
|
||||
harness
|
||||
.wait_for_event(&group.id(), |event| match event {
|
||||
EventV1::ChannelDelete { id, .. } => id == &group.id(),
|
||||
.wait_for_event(group.id(), |event| match event {
|
||||
EventV1::ChannelDelete { id, .. } => id == group.id(),
|
||||
_ => false,
|
||||
})
|
||||
.await;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use revolt_database::{
|
||||
util::{permissions::DatabasePermissionQuery, reference::Reference},
|
||||
Channel, Database, File, PartialChannel, SystemMessage, User,
|
||||
Channel, Database, File, PartialChannel, SystemMessage, User, AMQP,
|
||||
};
|
||||
use revolt_models::v0;
|
||||
use revolt_permissions::{calculate_channel_permissions, ChannelPermission};
|
||||
@@ -15,6 +15,7 @@ use validator::Validate;
|
||||
#[patch("/<target>", data = "<data>")]
|
||||
pub async fn edit(
|
||||
db: &State<Database>,
|
||||
amqp: &State<AMQP>,
|
||||
user: User,
|
||||
target: Reference,
|
||||
data: Json<v0::DataEditChannel>,
|
||||
@@ -73,7 +74,15 @@ pub async fn edit(
|
||||
return Err(create_error!(InvalidOperation));
|
||||
}
|
||||
.into_message(channel.id().to_string())
|
||||
.send(db, user.as_author_for_system(), &channel, false)
|
||||
.send(
|
||||
db,
|
||||
Some(amqp),
|
||||
user.as_author_for_system(),
|
||||
None,
|
||||
None,
|
||||
&channel,
|
||||
false,
|
||||
)
|
||||
.await
|
||||
.ok();
|
||||
}
|
||||
@@ -124,7 +133,7 @@ pub async fn edit(
|
||||
}
|
||||
|
||||
if let Some(icon_id) = data.icon {
|
||||
partial.icon = Some(File::use_icon(db, &icon_id, id).await?);
|
||||
partial.icon = Some(File::use_channel_icon(db, &icon_id, id, &user.id).await?);
|
||||
*icon = partial.icon.clone();
|
||||
}
|
||||
|
||||
@@ -151,7 +160,15 @@ pub async fn edit(
|
||||
by: user.id.clone(),
|
||||
}
|
||||
.into_message(channel.id().to_string())
|
||||
.send(db, user.as_author_for_system(), &channel, false)
|
||||
.send(
|
||||
db,
|
||||
Some(amqp),
|
||||
user.as_author_for_system(),
|
||||
None,
|
||||
None,
|
||||
&channel,
|
||||
false,
|
||||
)
|
||||
.await
|
||||
.ok();
|
||||
}
|
||||
@@ -161,7 +178,15 @@ pub async fn edit(
|
||||
by: user.id.clone(),
|
||||
}
|
||||
.into_message(channel.id().to_string())
|
||||
.send(db, user.as_author_for_system(), &channel, false)
|
||||
.send(
|
||||
db,
|
||||
Some(amqp),
|
||||
user.as_author_for_system(),
|
||||
None,
|
||||
None,
|
||||
&channel,
|
||||
false,
|
||||
)
|
||||
.await
|
||||
.ok();
|
||||
}
|
||||
@@ -171,7 +196,15 @@ pub async fn edit(
|
||||
by: user.id.clone(),
|
||||
}
|
||||
.into_message(channel.id().to_string())
|
||||
.send(db, user.as_author_for_system(), &channel, false)
|
||||
.send(
|
||||
db,
|
||||
Some(amqp),
|
||||
user.as_author_for_system(),
|
||||
None,
|
||||
None,
|
||||
&channel,
|
||||
false,
|
||||
)
|
||||
.await
|
||||
.ok();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use revolt_database::{
|
||||
util::{permissions::DatabasePermissionQuery, reference::Reference},
|
||||
Channel, Database, User,
|
||||
Channel, Database, User, AMQP,
|
||||
};
|
||||
use revolt_permissions::{calculate_channel_permissions, ChannelPermission};
|
||||
use revolt_result::{create_error, Result};
|
||||
@@ -15,6 +15,7 @@ use rocket_empty::EmptyResponse;
|
||||
#[put("/<group_id>/recipients/<member_id>")]
|
||||
pub async fn add_member(
|
||||
db: &State<Database>,
|
||||
amqp: &State<AMQP>,
|
||||
user: User,
|
||||
group_id: Reference,
|
||||
member_id: Reference,
|
||||
@@ -38,7 +39,7 @@ pub async fn add_member(
|
||||
}
|
||||
|
||||
channel
|
||||
.add_user_to_group(db, &member, &user.id)
|
||||
.add_user_to_group(db, amqp, &member, &user.id)
|
||||
.await
|
||||
.map(|_| EmptyResponse)
|
||||
}
|
||||
@@ -102,8 +103,8 @@ mod test {
|
||||
.await;
|
||||
|
||||
let event = harness
|
||||
.wait_for_event(&group.id(), |event| match event {
|
||||
EventV1::ChannelGroupJoin { id, .. } => id == &group.id(),
|
||||
.wait_for_event(group.id(), |event| match event {
|
||||
EventV1::ChannelGroupJoin { id, .. } => id == group.id(),
|
||||
_ => false,
|
||||
})
|
||||
.await;
|
||||
@@ -113,7 +114,7 @@ mod test {
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
let message = harness.wait_for_message(&group.id()).await;
|
||||
let message = harness.wait_for_message(group.id()).await;
|
||||
|
||||
assert_eq!(
|
||||
message.system,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use revolt_database::{util::reference::Reference, Channel, Database, User};
|
||||
use revolt_database::{util::reference::Reference, Channel, Database, User, AMQP};
|
||||
use revolt_permissions::ChannelPermission;
|
||||
use revolt_result::{create_error, Result};
|
||||
|
||||
@@ -12,6 +12,7 @@ use rocket_empty::EmptyResponse;
|
||||
#[delete("/<target>/recipients/<member>")]
|
||||
pub async fn remove_member(
|
||||
db: &State<Database>,
|
||||
amqp: &State<AMQP>,
|
||||
user: User,
|
||||
target: Reference,
|
||||
member: Reference,
|
||||
@@ -42,7 +43,7 @@ pub async fn remove_member(
|
||||
}
|
||||
|
||||
channel
|
||||
.remove_user_from_group(db, &member, Some(&user.id), false)
|
||||
.remove_user_from_group(db, amqp, &member, Some(&user.id), false)
|
||||
.await
|
||||
.map(|_| EmptyResponse)
|
||||
}
|
||||
@@ -106,8 +107,8 @@ mod test {
|
||||
.await;
|
||||
|
||||
let event = harness
|
||||
.wait_for_event(&group.id(), |event| match event {
|
||||
EventV1::ChannelGroupJoin { id, .. } => id == &group.id(),
|
||||
.wait_for_event(group.id(), |event| match event {
|
||||
EventV1::ChannelGroupJoin { id, .. } => id == group.id(),
|
||||
_ => false,
|
||||
})
|
||||
.await;
|
||||
@@ -117,7 +118,7 @@ mod test {
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
let message = harness.wait_for_message(&group.id()).await;
|
||||
let message = harness.wait_for_message(group.id()).await;
|
||||
|
||||
assert_eq!(
|
||||
message.system,
|
||||
|
||||
@@ -27,7 +27,7 @@ pub async fn clear_reactions(
|
||||
.throw_if_lacking_channel_permission(ChannelPermission::ManageMessages)?;
|
||||
|
||||
// Fetch relevant message
|
||||
let mut message = msg.as_message_in_channel(db, &channel.id()).await?;
|
||||
let mut message = msg.as_message_in_channel(db, channel.id()).await?;
|
||||
|
||||
// Clear reactions
|
||||
message
|
||||
@@ -37,6 +37,7 @@ pub async fn clear_reactions(
|
||||
reactions: Some(Default::default()),
|
||||
..Default::default()
|
||||
},
|
||||
vec![]
|
||||
)
|
||||
.await
|
||||
.map(|_| EmptyResponse)
|
||||
|
||||
@@ -30,11 +30,10 @@ pub async fn edit(
|
||||
})
|
||||
})?;
|
||||
|
||||
let config = config().await;
|
||||
Message::validate_sum(
|
||||
&edit.content,
|
||||
edit.embeds.as_deref().unwrap_or_default(),
|
||||
config.features.limits.default.message_length,
|
||||
user.limits().await.message_length,
|
||||
)?;
|
||||
|
||||
// Ensure we have permissions to send a message
|
||||
@@ -44,7 +43,7 @@ pub async fn edit(
|
||||
|
||||
permissions.throw_if_lacking_channel_permission(ChannelPermission::SendMessage)?;
|
||||
|
||||
let mut message = msg.as_message_in_channel(db, &channel.id()).await?;
|
||||
let mut message = msg.as_message_in_channel(db, channel.id()).await?;
|
||||
if message.author != user.id {
|
||||
return Err(create_error!(CannotEditMessage));
|
||||
}
|
||||
@@ -84,7 +83,7 @@ pub async fn edit(
|
||||
|
||||
partial.embeds = Some(new_embeds);
|
||||
|
||||
message.update(db, partial).await?;
|
||||
message.update(db, partial, vec![]).await?;
|
||||
|
||||
// Queue up a task for processing embeds if the we have sufficient permissions
|
||||
if permissions.has_channel_permission(ChannelPermission::SendEmbeds) {
|
||||
@@ -98,5 +97,5 @@ pub async fn edit(
|
||||
}
|
||||
}
|
||||
|
||||
Ok(Json(message.into()))
|
||||
Ok(Json(message.into_model(None, None)))
|
||||
}
|
||||
|
||||
@@ -29,5 +29,5 @@ pub async fn fetch(
|
||||
return Err(create_error!(NotFound));
|
||||
}
|
||||
|
||||
Ok(Json(message.into()))
|
||||
Ok(Json(message.into_model(None, None)))
|
||||
}
|
||||
|
||||
180
crates/delta/src/routes/channels/message_pin.rs
Normal file
180
crates/delta/src/routes/channels/message_pin.rs
Normal file
@@ -0,0 +1,180 @@
|
||||
use revolt_database::{
|
||||
util::{permissions::DatabasePermissionQuery, reference::Reference},
|
||||
Database, PartialMessage, SystemMessage, User, AMQP,
|
||||
};
|
||||
use revolt_models::v0::MessageAuthor;
|
||||
use revolt_permissions::{calculate_channel_permissions, ChannelPermission};
|
||||
use revolt_result::{create_error, Result};
|
||||
use rocket::State;
|
||||
use rocket_empty::EmptyResponse;
|
||||
|
||||
/// # Pins a message
|
||||
///
|
||||
/// Pins a message by its id.
|
||||
#[openapi(tag = "Messaging")]
|
||||
#[post("/<target>/messages/<msg>/pin")]
|
||||
pub async fn message_pin(
|
||||
db: &State<Database>,
|
||||
amqp: &State<AMQP>,
|
||||
user: User,
|
||||
target: Reference,
|
||||
msg: Reference,
|
||||
) -> Result<EmptyResponse> {
|
||||
let channel = target.as_channel(db).await?;
|
||||
|
||||
let mut query = DatabasePermissionQuery::new(db, &user).channel(&channel);
|
||||
calculate_channel_permissions(&mut query)
|
||||
.await
|
||||
.throw_if_lacking_channel_permission(ChannelPermission::ManageMessages)?;
|
||||
|
||||
let mut message = msg.as_message_in_channel(db, channel.id()).await?;
|
||||
|
||||
if message.pinned.unwrap_or_default() {
|
||||
return Err(create_error!(AlreadyPinned));
|
||||
}
|
||||
|
||||
message
|
||||
.update(
|
||||
db,
|
||||
PartialMessage {
|
||||
pinned: Some(true),
|
||||
..Default::default()
|
||||
},
|
||||
vec![],
|
||||
)
|
||||
.await?;
|
||||
|
||||
SystemMessage::MessagePinned {
|
||||
id: message.id.clone(),
|
||||
by: user.id.clone(),
|
||||
}
|
||||
.into_message(channel.id().to_string())
|
||||
.send(
|
||||
db,
|
||||
Some(amqp),
|
||||
MessageAuthor::System {
|
||||
username: &user.username,
|
||||
avatar: user.avatar.as_ref().map(|file| file.id.as_ref()),
|
||||
},
|
||||
None,
|
||||
None,
|
||||
&channel,
|
||||
false,
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(EmptyResponse)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use crate::{rocket, util::test::TestHarness};
|
||||
use revolt_database::{
|
||||
events::client::EventV1,
|
||||
util::{idempotency::IdempotencyKey, reference::Reference},
|
||||
Member, Message, Server,
|
||||
};
|
||||
use revolt_models::v0::{self, SystemMessage};
|
||||
use rocket::http::{Header, Status};
|
||||
|
||||
#[rocket::async_test]
|
||||
async fn pin_message() {
|
||||
let mut harness = TestHarness::new().await;
|
||||
let (_, session, user) = harness.new_user().await;
|
||||
|
||||
let (server, channels) = Server::create(
|
||||
&harness.db,
|
||||
v0::DataCreateServer {
|
||||
name: "Test Server".to_string(),
|
||||
..Default::default()
|
||||
},
|
||||
&user,
|
||||
true,
|
||||
)
|
||||
.await
|
||||
.expect("Failed to create test server");
|
||||
|
||||
let (member, channels) = Member::create(&harness.db, &server, &user, Some(channels))
|
||||
.await
|
||||
.expect("Failed to create member");
|
||||
let channel = &channels[0];
|
||||
|
||||
let message = Message::create_from_api(
|
||||
&harness.db,
|
||||
None,
|
||||
channel.clone(),
|
||||
v0::DataMessageSend {
|
||||
content: Some("Test message".to_string()),
|
||||
nonce: None,
|
||||
attachments: None,
|
||||
replies: None,
|
||||
embeds: None,
|
||||
masquerade: None,
|
||||
interactions: None,
|
||||
flags: None,
|
||||
},
|
||||
v0::MessageAuthor::User(&user.clone().into(&harness.db, Some(&user)).await),
|
||||
Some(user.clone().into(&harness.db, Some(&user)).await),
|
||||
Some(member.into()),
|
||||
user.limits().await,
|
||||
IdempotencyKey::unchecked_from_string("0".to_string()),
|
||||
false,
|
||||
false,
|
||||
)
|
||||
.await
|
||||
.expect("Failed to create message");
|
||||
|
||||
let response = harness
|
||||
.client
|
||||
.post(format!(
|
||||
"/channels/{}/messages/{}/pin",
|
||||
channel.id(),
|
||||
&message.id
|
||||
))
|
||||
.header(Header::new("x-session-token", session.token.to_string()))
|
||||
.dispatch()
|
||||
.await;
|
||||
|
||||
assert_eq!(response.status(), Status::NoContent);
|
||||
drop(response);
|
||||
|
||||
harness
|
||||
.wait_for_event(channel.id(), |event| match event {
|
||||
EventV1::Message(message) => match &message.system {
|
||||
Some(SystemMessage::MessagePinned { by, .. }) => {
|
||||
assert_eq!(by, &user.id);
|
||||
|
||||
true
|
||||
}
|
||||
_ => false,
|
||||
},
|
||||
_ => false,
|
||||
})
|
||||
.await;
|
||||
|
||||
harness
|
||||
.wait_for_event(channel.id(), |event| match event {
|
||||
EventV1::MessageUpdate {
|
||||
id,
|
||||
channel: channel_id,
|
||||
data,
|
||||
..
|
||||
} => {
|
||||
assert_eq!(id, &message.id);
|
||||
assert_eq!(channel_id, channel.id());
|
||||
assert_eq!(data.pinned, Some(true));
|
||||
|
||||
true
|
||||
}
|
||||
_ => false,
|
||||
})
|
||||
.await;
|
||||
|
||||
let updated_message = Reference::from_unchecked(message.id)
|
||||
.as_message(&harness.db)
|
||||
.await
|
||||
.expect("Failed to find updated message");
|
||||
|
||||
assert_eq!(updated_message.pinned, Some(true));
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@ pub async fn react_message(
|
||||
.throw_if_lacking_channel_permission(ChannelPermission::React)?;
|
||||
|
||||
// Fetch relevant message
|
||||
let message = msg.as_message_in_channel(db, &channel.id()).await?;
|
||||
let message = msg.as_message_in_channel(db, channel.id()).await?;
|
||||
|
||||
// Add the reaction
|
||||
message
|
||||
|
||||
@@ -30,6 +30,10 @@ pub async fn search(
|
||||
})
|
||||
})?;
|
||||
|
||||
if options.query.is_some() && options.pinned.is_some() {
|
||||
return Err(create_error!(InvalidOperation))
|
||||
}
|
||||
|
||||
let channel = target.as_channel(db).await?;
|
||||
|
||||
let mut query = DatabasePermissionQuery::new(db, &user).channel(&channel);
|
||||
@@ -39,6 +43,7 @@ pub async fn search(
|
||||
|
||||
let v0::DataMessageSearch {
|
||||
query,
|
||||
pinned,
|
||||
limit,
|
||||
before,
|
||||
after,
|
||||
@@ -51,7 +56,8 @@ pub async fn search(
|
||||
MessageQuery {
|
||||
filter: MessageFilter {
|
||||
channel: Some(channel.id().to_string()),
|
||||
query: Some(query),
|
||||
query,
|
||||
pinned,
|
||||
..Default::default()
|
||||
},
|
||||
time_period: MessageTimePeriod::Absolute {
|
||||
|
||||
@@ -3,8 +3,9 @@ use revolt_database::util::permissions::DatabasePermissionQuery;
|
||||
use revolt_database::{
|
||||
util::idempotency::IdempotencyKey, util::reference::Reference, Database, User,
|
||||
};
|
||||
use revolt_database::{Interactions, Message};
|
||||
use revolt_database::{Interactions, Message, AMQP};
|
||||
use revolt_models::v0;
|
||||
use revolt_permissions::PermissionQuery;
|
||||
use revolt_permissions::{calculate_channel_permissions, ChannelPermission};
|
||||
use revolt_result::{create_error, Result};
|
||||
use rocket::serde::json::Json;
|
||||
@@ -18,6 +19,7 @@ use validator::Validate;
|
||||
#[post("/<target>/messages", data = "<data>")]
|
||||
pub async fn message_send(
|
||||
db: &State<Database>,
|
||||
amqp: &State<AMQP>,
|
||||
user: User,
|
||||
target: Reference,
|
||||
data: Json<v0::DataMessageSend>,
|
||||
@@ -75,17 +77,253 @@ pub async fn message_send(
|
||||
|
||||
// Create the message
|
||||
let author: v0::User = user.clone().into(db, Some(&user)).await;
|
||||
|
||||
// Make sure we have server member (edge case if server owner)
|
||||
query.are_we_a_member().await;
|
||||
|
||||
// Create model user / members
|
||||
let model_user = user
|
||||
.clone()
|
||||
.into_known_static(revolt_presence::is_online(&user.id).await);
|
||||
|
||||
let model_member: Option<v0::Member> = query
|
||||
.member_ref()
|
||||
.as_ref()
|
||||
.map(|member| member.clone().into_owned().into());
|
||||
|
||||
Ok(Json(
|
||||
Message::create_from_api(
|
||||
db,
|
||||
Some(amqp),
|
||||
channel,
|
||||
data,
|
||||
v0::MessageAuthor::User(&author),
|
||||
Some(model_user.clone()),
|
||||
model_member.clone(),
|
||||
user.limits().await,
|
||||
idempotency,
|
||||
permissions.has_channel_permission(ChannelPermission::SendEmbeds),
|
||||
allow_mentions,
|
||||
)
|
||||
.await?
|
||||
.into(),
|
||||
.into_model(Some(model_user), model_member),
|
||||
))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use std::collections::HashMap;
|
||||
|
||||
use crate::{rocket, util::test::TestHarness};
|
||||
use revolt_database::{
|
||||
util::{idempotency::IdempotencyKey, reference::Reference},
|
||||
Channel, Member, Message, PartialChannel, PartialMember, Role, Server,
|
||||
};
|
||||
use revolt_models::v0::{self, DataCreateServerChannel};
|
||||
use revolt_permissions::{ChannelPermission, OverrideField};
|
||||
|
||||
#[rocket::async_test]
|
||||
async fn message_mention_constraints() {
|
||||
let harness = TestHarness::new().await;
|
||||
let (_, _, user) = harness.new_user().await;
|
||||
let (_, _, second_user) = harness.new_user().await;
|
||||
|
||||
let (server, channels) = Server::create(
|
||||
&harness.db,
|
||||
v0::DataCreateServer {
|
||||
name: "Test Server".to_string(),
|
||||
..Default::default()
|
||||
},
|
||||
&user,
|
||||
true,
|
||||
)
|
||||
.await
|
||||
.expect("Failed to create test server");
|
||||
|
||||
let server_mut: &mut Server = &mut server.clone();
|
||||
let mut locked_channel = Channel::create_server_channel(
|
||||
&harness.db,
|
||||
server_mut,
|
||||
DataCreateServerChannel {
|
||||
channel_type: v0::LegacyServerChannelType::Text,
|
||||
name: "Hidden Channel".to_string(),
|
||||
description: None,
|
||||
nsfw: Some(false),
|
||||
voice: None
|
||||
},
|
||||
true,
|
||||
)
|
||||
.await
|
||||
.expect("Failed to make new channel");
|
||||
|
||||
let role = Role {
|
||||
name: "Show Hidden Channel".to_string(),
|
||||
permissions: OverrideField { a: 0, d: 0 },
|
||||
colour: None,
|
||||
hoist: false,
|
||||
rank: 5,
|
||||
};
|
||||
|
||||
let role_id = role
|
||||
.create(&harness.db, &server.id)
|
||||
.await
|
||||
.expect("Failed to create the role");
|
||||
|
||||
let mut overrides = HashMap::new();
|
||||
overrides.insert(
|
||||
role_id.clone(),
|
||||
OverrideField {
|
||||
a: (ChannelPermission::ViewChannel) as i64,
|
||||
d: 0,
|
||||
},
|
||||
);
|
||||
|
||||
let partial = PartialChannel {
|
||||
name: None,
|
||||
owner: None,
|
||||
description: None,
|
||||
icon: None,
|
||||
nsfw: None,
|
||||
active: None,
|
||||
permissions: None,
|
||||
role_permissions: Some(overrides),
|
||||
default_permissions: Some(OverrideField {
|
||||
a: 0,
|
||||
d: ChannelPermission::ViewChannel as i64,
|
||||
}),
|
||||
last_message_id: None,
|
||||
};
|
||||
locked_channel
|
||||
.update(&harness.db, partial, vec![])
|
||||
.await
|
||||
.expect("Failed to update the channel permissions for special role");
|
||||
|
||||
Member::create(&harness.db, &server, &user, Some(channels.clone()))
|
||||
.await
|
||||
.expect("Failed to create member");
|
||||
let member = Reference::from_unchecked(user.id.clone())
|
||||
.as_member(&harness.db, &server.id)
|
||||
.await
|
||||
.expect("Failed to get member");
|
||||
|
||||
// Second user is not part of the server
|
||||
let message = Message::create_from_api(
|
||||
&harness.db,
|
||||
Some(&harness.amqp),
|
||||
locked_channel.clone(),
|
||||
v0::DataMessageSend {
|
||||
content: Some(format!("<@{}>", second_user.id)),
|
||||
nonce: None,
|
||||
attachments: None,
|
||||
replies: None,
|
||||
embeds: None,
|
||||
masquerade: None,
|
||||
interactions: None,
|
||||
flags: None,
|
||||
},
|
||||
v0::MessageAuthor::User(&user.clone().into(&harness.db, Some(&user)).await),
|
||||
Some(user.clone().into(&harness.db, Some(&user)).await),
|
||||
Some(member.clone().into()),
|
||||
user.limits().await,
|
||||
IdempotencyKey::unchecked_from_string("0".to_string()),
|
||||
false,
|
||||
true,
|
||||
)
|
||||
.await
|
||||
.expect("Failed to create message");
|
||||
|
||||
// The mention should not go through here
|
||||
assert!(
|
||||
message.mentions.is_none() || message.mentions.unwrap().is_empty(),
|
||||
"Mention failed to be scrubbed when the user is not part of the server"
|
||||
);
|
||||
|
||||
Member::create(&harness.db, &server, &second_user, Some(channels.clone()))
|
||||
.await
|
||||
.expect("Failed to create second member");
|
||||
let mut second_member = Reference::from_unchecked(second_user.id.clone())
|
||||
.as_member(&harness.db, &server.id)
|
||||
.await
|
||||
.expect("Failed to get second member");
|
||||
|
||||
// Second user cannot see the channel
|
||||
let message = Message::create_from_api(
|
||||
&harness.db,
|
||||
Some(&harness.amqp),
|
||||
locked_channel.clone(),
|
||||
v0::DataMessageSend {
|
||||
content: Some(format!("<@{}>", second_user.id)),
|
||||
nonce: None,
|
||||
attachments: None,
|
||||
replies: None,
|
||||
embeds: None,
|
||||
masquerade: None,
|
||||
interactions: None,
|
||||
flags: None,
|
||||
},
|
||||
v0::MessageAuthor::User(&user.clone().into(&harness.db, Some(&user)).await),
|
||||
Some(user.clone().into(&harness.db, Some(&user)).await),
|
||||
Some(member.clone().into()),
|
||||
user.limits().await,
|
||||
IdempotencyKey::unchecked_from_string("1".to_string()),
|
||||
false,
|
||||
true,
|
||||
)
|
||||
.await
|
||||
.expect("Failed to create message");
|
||||
|
||||
// The mention should not go through here
|
||||
assert!(
|
||||
message.mentions.is_none() || message.mentions.unwrap().is_empty(),
|
||||
"Mention failed to be scrubbed when the user cannot see the channel"
|
||||
);
|
||||
|
||||
let second_member_roles = vec![role_id.clone()];
|
||||
let partial = PartialMember {
|
||||
id: None,
|
||||
joined_at: None,
|
||||
nickname: None,
|
||||
avatar: None,
|
||||
timeout: None,
|
||||
roles: Some(second_member_roles),
|
||||
can_publish: None,
|
||||
can_receive: None
|
||||
};
|
||||
second_member
|
||||
.update(&harness.db, partial, vec![])
|
||||
.await
|
||||
.expect("Failed to update the second user's roles");
|
||||
|
||||
// This time the mention SHOULD go through
|
||||
let message = Message::create_from_api(
|
||||
&harness.db,
|
||||
Some(&harness.amqp),
|
||||
locked_channel.clone(),
|
||||
v0::DataMessageSend {
|
||||
content: Some(format!("<@{}>", second_user.id)),
|
||||
nonce: None,
|
||||
attachments: None,
|
||||
replies: None,
|
||||
embeds: None,
|
||||
masquerade: None,
|
||||
interactions: None,
|
||||
flags: None,
|
||||
},
|
||||
v0::MessageAuthor::User(&user.clone().into(&harness.db, Some(&user)).await),
|
||||
Some(user.clone().into(&harness.db, Some(&user)).await),
|
||||
Some(member.clone().into()),
|
||||
user.limits().await,
|
||||
IdempotencyKey::unchecked_from_string("2".to_string()),
|
||||
false,
|
||||
true,
|
||||
)
|
||||
.await
|
||||
.expect("Failed to create message");
|
||||
|
||||
// The mention SHOULD go through here
|
||||
assert!(
|
||||
message.mentions.is_some() && !message.mentions.unwrap().is_empty(),
|
||||
"Mention was scrubbed when the user can see the channel"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
185
crates/delta/src/routes/channels/message_unpin.rs
Normal file
185
crates/delta/src/routes/channels/message_unpin.rs
Normal file
@@ -0,0 +1,185 @@
|
||||
use revolt_database::{
|
||||
util::{permissions::DatabasePermissionQuery, reference::Reference},
|
||||
Database, FieldsMessage, PartialMessage, SystemMessage, User, AMQP,
|
||||
};
|
||||
use revolt_models::v0::MessageAuthor;
|
||||
use revolt_permissions::{calculate_channel_permissions, ChannelPermission};
|
||||
use revolt_result::{create_error, Result};
|
||||
use rocket::State;
|
||||
use rocket_empty::EmptyResponse;
|
||||
|
||||
/// # Unpins a message
|
||||
///
|
||||
/// Unpins a message by its id.
|
||||
#[openapi(tag = "Messaging")]
|
||||
#[delete("/<target>/messages/<msg>/pin")]
|
||||
pub async fn message_unpin(
|
||||
db: &State<Database>,
|
||||
amqp: &State<AMQP>,
|
||||
user: User,
|
||||
target: Reference,
|
||||
msg: Reference,
|
||||
) -> Result<EmptyResponse> {
|
||||
let channel = target.as_channel(db).await?;
|
||||
|
||||
let mut query = DatabasePermissionQuery::new(db, &user).channel(&channel);
|
||||
calculate_channel_permissions(&mut query)
|
||||
.await
|
||||
.throw_if_lacking_channel_permission(ChannelPermission::ManageMessages)?;
|
||||
|
||||
let mut message = msg.as_message_in_channel(db, channel.id()).await?;
|
||||
|
||||
if !message.pinned.unwrap_or_default() {
|
||||
return Err(create_error!(NotPinned));
|
||||
}
|
||||
|
||||
message
|
||||
.update(db, PartialMessage::default(), vec![FieldsMessage::Pinned])
|
||||
.await?;
|
||||
|
||||
SystemMessage::MessageUnpinned {
|
||||
id: message.id.clone(),
|
||||
by: user.id.clone(),
|
||||
}
|
||||
.into_message(channel.id().to_string())
|
||||
.send(
|
||||
db,
|
||||
Some(amqp),
|
||||
MessageAuthor::System {
|
||||
username: &user.username,
|
||||
avatar: user.avatar.as_ref().map(|file| file.id.as_ref()),
|
||||
},
|
||||
None,
|
||||
None,
|
||||
&channel,
|
||||
false,
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(EmptyResponse)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use crate::{rocket, util::test::TestHarness};
|
||||
use revolt_database::{
|
||||
events::client::EventV1,
|
||||
util::{idempotency::IdempotencyKey, reference::Reference},
|
||||
Member, Message, PartialMessage, Server,
|
||||
};
|
||||
use revolt_models::v0::{self, FieldsMessage, SystemMessage};
|
||||
use rocket::http::{Header, Status};
|
||||
|
||||
#[rocket::async_test]
|
||||
async fn unpin_message() {
|
||||
let mut harness = TestHarness::new().await;
|
||||
let (_, session, user) = harness.new_user().await;
|
||||
|
||||
let (server, channels) = Server::create(
|
||||
&harness.db,
|
||||
v0::DataCreateServer {
|
||||
name: "Test Server".to_string(),
|
||||
..Default::default()
|
||||
},
|
||||
&user,
|
||||
true,
|
||||
)
|
||||
.await
|
||||
.expect("Failed to create test server");
|
||||
|
||||
let channel = &channels[0];
|
||||
|
||||
Member::create(&harness.db, &server, &user, Some(channels.clone()))
|
||||
.await
|
||||
.expect("Failed to create member");
|
||||
let member = Reference::from_unchecked(user.id.clone())
|
||||
.as_member(&harness.db, &server.id)
|
||||
.await
|
||||
.expect("Failed to get member");
|
||||
|
||||
let message = Message::create_from_api(
|
||||
&harness.db,
|
||||
None,
|
||||
channel.clone(),
|
||||
v0::DataMessageSend {
|
||||
content: Some("Test message".to_string()),
|
||||
nonce: None,
|
||||
attachments: None,
|
||||
replies: None,
|
||||
embeds: None,
|
||||
masquerade: None,
|
||||
interactions: None,
|
||||
flags: None,
|
||||
},
|
||||
v0::MessageAuthor::User(&user.clone().into(&harness.db, Some(&user)).await),
|
||||
Some(user.clone().into(&harness.db, Some(&user)).await),
|
||||
Some(member.into()),
|
||||
user.limits().await,
|
||||
IdempotencyKey::unchecked_from_string("0".to_string()),
|
||||
false,
|
||||
false,
|
||||
)
|
||||
.await
|
||||
.expect("Failed to create message");
|
||||
|
||||
harness
|
||||
.db
|
||||
.update_message(
|
||||
&message.id,
|
||||
&PartialMessage {
|
||||
pinned: Some(true),
|
||||
..Default::default()
|
||||
},
|
||||
vec![],
|
||||
)
|
||||
.await
|
||||
.expect("Failed to update message");
|
||||
|
||||
let response = harness
|
||||
.client
|
||||
.delete(format!(
|
||||
"/channels/{}/messages/{}/pin",
|
||||
channel.id(),
|
||||
&message.id
|
||||
))
|
||||
.header(Header::new("x-session-token", session.token.to_string()))
|
||||
.dispatch()
|
||||
.await;
|
||||
|
||||
assert_eq!(response.status(), Status::NoContent);
|
||||
drop(response);
|
||||
|
||||
harness
|
||||
.wait_for_event(channel.id(), |event| match event {
|
||||
EventV1::Message(message) => match &message.system {
|
||||
Some(SystemMessage::MessageUnpinned { by, .. }) => {
|
||||
assert_eq!(by, &user.id);
|
||||
|
||||
true
|
||||
}
|
||||
_ => false,
|
||||
},
|
||||
_ => false,
|
||||
})
|
||||
.await;
|
||||
|
||||
harness
|
||||
.wait_for_event(channel.id(), |event| match event {
|
||||
EventV1::MessageUpdate { id, clear, .. } => {
|
||||
assert_eq!(&message.id, id);
|
||||
assert_eq!(clear, &[FieldsMessage::Pinned]);
|
||||
|
||||
true
|
||||
}
|
||||
_ => false,
|
||||
})
|
||||
.await;
|
||||
|
||||
let updated_message = Reference::from_unchecked(message.id)
|
||||
.as_message(&harness.db)
|
||||
.await
|
||||
.expect("Failed to find updated message");
|
||||
|
||||
assert_eq!(updated_message.pinned, None);
|
||||
}
|
||||
}
|
||||
@@ -36,7 +36,7 @@ pub async fn unreact_message(
|
||||
}
|
||||
|
||||
// Fetch relevant message
|
||||
let message = msg.as_message_in_channel(db, &channel.id()).await?;
|
||||
let message = msg.as_message_in_channel(db, channel.id()).await?;
|
||||
|
||||
// Check if we should wipe all of this reaction
|
||||
if remove_all {
|
||||
|
||||
@@ -15,10 +15,12 @@ mod message_clear_reactions;
|
||||
mod message_delete;
|
||||
mod message_edit;
|
||||
mod message_fetch;
|
||||
mod message_pin;
|
||||
mod message_query;
|
||||
mod message_react;
|
||||
mod message_search;
|
||||
mod message_send;
|
||||
mod message_unpin;
|
||||
mod message_unreact;
|
||||
mod permissions_set;
|
||||
mod permissions_set_default;
|
||||
@@ -37,10 +39,12 @@ pub fn routes() -> (Vec<Route>, OpenApi) {
|
||||
message_send::message_send,
|
||||
message_query::query,
|
||||
message_search::search,
|
||||
message_pin::message_pin,
|
||||
message_fetch::fetch,
|
||||
message_edit::edit,
|
||||
message_bulk_delete::bulk_delete_messages,
|
||||
message_delete::delete,
|
||||
message_unpin::message_unpin,
|
||||
group_create::create_group,
|
||||
group_add_member::add_member,
|
||||
group_remove_member::remove_member,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use revolt_database::{
|
||||
util::{permissions::DatabasePermissionQuery, reference::Reference},
|
||||
Channel, Database, User, Webhook,
|
||||
Channel, Database, File, User, Webhook,
|
||||
};
|
||||
use revolt_models::v0;
|
||||
use revolt_permissions::{
|
||||
@@ -43,10 +43,7 @@ pub async fn create_webhook(
|
||||
let webhook_id = Ulid::new().to_string();
|
||||
|
||||
let avatar = match &data.avatar {
|
||||
Some(id) => Some(
|
||||
db.find_and_use_attachment(id, "avatars", "user", &webhook_id)
|
||||
.await?,
|
||||
),
|
||||
Some(id) => Some(File::use_webhook_avatar(db, id, &webhook_id, &user.id).await?),
|
||||
None => None,
|
||||
};
|
||||
|
||||
@@ -54,7 +51,8 @@ pub async fn create_webhook(
|
||||
id: webhook_id,
|
||||
name: data.name,
|
||||
avatar,
|
||||
channel_id: channel.id(),
|
||||
creator_id: user.id,
|
||||
channel_id: channel.id().to_string(),
|
||||
permissions: *DEFAULT_WEBHOOK_PERMISSIONS,
|
||||
token: Some(nanoid::nanoid!(64)),
|
||||
};
|
||||
|
||||
@@ -25,7 +25,7 @@ pub async fn fetch_webhooks(
|
||||
.throw_if_lacking_channel_permission(ChannelPermission::ViewChannel)?;
|
||||
|
||||
Ok(Json(
|
||||
db.fetch_webhooks_for_channel(&channel.id())
|
||||
db.fetch_webhooks_for_channel(channel.id())
|
||||
.await?
|
||||
.into_iter()
|
||||
.map(|v| v.into())
|
||||
|
||||
@@ -45,9 +45,9 @@ pub async fn create_emoji(
|
||||
|
||||
// Check that we haven't hit the emoji limit
|
||||
let emojis = db.fetch_emoji_by_parent_id(&server.id).await?;
|
||||
if emojis.len() >= config.features.limits.default.server_emoji {
|
||||
if emojis.len() >= config.features.limits.global.server_emoji {
|
||||
return Err(create_error!(TooManyEmoji {
|
||||
max: config.features.limits.default.server_emoji,
|
||||
max: config.features.limits.global.server_emoji,
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -55,7 +55,7 @@ pub async fn create_emoji(
|
||||
};
|
||||
|
||||
// Find the relevant attachment
|
||||
let attachment = File::use_emoji(db, &id, &id).await?;
|
||||
let attachment = File::use_emoji(db, &id, &id, &user.id).await?;
|
||||
|
||||
// Create the emoji object
|
||||
let emoji = Emoji {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use revolt_database::{util::reference::Reference, Channel, Database, Invite, Member, User};
|
||||
use revolt_database::{util::reference::Reference, Channel, Database, Invite, Member, User, AMQP};
|
||||
use revolt_models::v0::{self, InviteJoinResponse};
|
||||
use revolt_result::{create_error, Result};
|
||||
use rocket::{serde::json::Json, State};
|
||||
@@ -10,6 +10,7 @@ use rocket::{serde::json::Json, State};
|
||||
#[post("/<target>")]
|
||||
pub async fn join(
|
||||
db: &State<Database>,
|
||||
amqp: &State<AMQP>,
|
||||
user: User,
|
||||
target: Reference,
|
||||
) -> Result<Json<v0::InviteJoinResponse>> {
|
||||
@@ -23,7 +24,8 @@ pub async fn join(
|
||||
match &invite {
|
||||
Invite::Server { server, .. } => {
|
||||
let server = db.fetch_server(server).await?;
|
||||
let channels = Member::create(db, &server, &user, None).await?;
|
||||
let (_, channels) = Member::create(db, &server, &user, None).await?;
|
||||
|
||||
Ok(Json(InviteJoinResponse::Server {
|
||||
channels: channels.into_iter().map(|c| c.into()).collect(),
|
||||
server: server.into(),
|
||||
@@ -33,7 +35,7 @@ pub async fn join(
|
||||
channel, creator, ..
|
||||
} => {
|
||||
let mut channel = db.fetch_channel(channel).await?;
|
||||
channel.add_user_to_group(db, &user, creator).await?;
|
||||
channel.add_user_to_group(db, amqp, &user, creator).await?;
|
||||
if let Channel::Group { recipients, .. } = &channel {
|
||||
Ok(Json(InviteJoinResponse::Group {
|
||||
users: User::fetch_many_ids_as_mutuals(db, &user, recipients).await?,
|
||||
|
||||
@@ -48,7 +48,7 @@ pub async fn complete(
|
||||
Ok(Json(
|
||||
User::create(db, data.username, session.user_id, None)
|
||||
.await?
|
||||
.into_self()
|
||||
.into_self(false)
|
||||
.await,
|
||||
))
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ pub async fn root() -> Result<Json<RevoltConfig>> {
|
||||
},
|
||||
ws: config.hosts.events,
|
||||
app: config.hosts.app,
|
||||
vapid: config.api.vapid.public_key,
|
||||
vapid: config.pushd.vapid.public_key,
|
||||
build: BuildInformation {
|
||||
commit_sha: option_env!("VERGEN_GIT_SHA")
|
||||
.unwrap_or_else(|| "<failed to generate>")
|
||||
|
||||
@@ -36,7 +36,7 @@ pub async fn list(
|
||||
)
|
||||
.await?
|
||||
.into_iter()
|
||||
.map(|u| u.into_self()),
|
||||
.map(|u| u.into_self(false)),
|
||||
)
|
||||
.await;
|
||||
|
||||
|
||||
@@ -5,7 +5,9 @@ use livekit_api::services::room::{RoomClient, UpdateParticipantOptions};
|
||||
use livekit_protocol::ParticipantPermission;
|
||||
use redis_kiss::{get_connection, redis::Pipeline, AsyncCommands};
|
||||
use revolt_database::{
|
||||
events::client::EventV1, util::{permissions::DatabasePermissionQuery, reference::Reference}, Database, File, PartialMember, User
|
||||
events::client::EventV1,
|
||||
util::{permissions::DatabasePermissionQuery, reference::Reference},
|
||||
Database, File, PartialMember, User,
|
||||
};
|
||||
use revolt_models::v0::{self, FieldsMember, PartialUserVoiceState};
|
||||
|
||||
@@ -35,13 +37,13 @@ pub async fn edit(
|
||||
})
|
||||
})?;
|
||||
|
||||
// Fetch server, target member and current permissions
|
||||
// Fetch server and target member
|
||||
let mut server = server.as_server(db).await?;
|
||||
let mut member = target.as_member(db, &server.id).await?;
|
||||
let target_user = target.as_user(db).await?;
|
||||
let mut query = DatabasePermissionQuery::new(db, &user)
|
||||
.server(&server)
|
||||
.member(&member);
|
||||
let target_user = target.as_user(&db).await?;
|
||||
|
||||
// Fetch our currrent permissions
|
||||
let mut query = DatabasePermissionQuery::new(db, &user).server(&server);
|
||||
let permissions = calculate_server_permissions(&mut query).await;
|
||||
|
||||
// Check permissions in server
|
||||
@@ -157,7 +159,7 @@ pub async fn edit(
|
||||
remove,
|
||||
mut can_publish,
|
||||
mut can_receive,
|
||||
voice_channel
|
||||
voice_channel,
|
||||
} = data;
|
||||
|
||||
let mut partial = PartialMember {
|
||||
@@ -180,12 +182,13 @@ pub async fn edit(
|
||||
|
||||
// 2. Apply new avatar
|
||||
if let Some(avatar) = avatar {
|
||||
partial.avatar = Some(File::use_avatar(db, &avatar, &user.id).await?);
|
||||
partial.avatar = Some(File::use_user_avatar(db, &avatar, &user.id, &user.id).await?);
|
||||
}
|
||||
|
||||
let remove_contains_voice = remove
|
||||
.as_ref()
|
||||
.map(|r| r.contains(FieldsMember::CanPublish) || r.contains(FieldsMember::CanReceive)).unwrap_or_default();
|
||||
.map(|r| r.contains(FieldsMember::CanPublish) || r.contains(FieldsMember::CanReceive))
|
||||
.unwrap_or_default();
|
||||
|
||||
member
|
||||
.update(
|
||||
@@ -197,10 +200,10 @@ pub async fn edit(
|
||||
)
|
||||
.await?;
|
||||
|
||||
if can_publish.is_some() ||
|
||||
can_receive.is_some() ||
|
||||
voice_channel.is_some() ||
|
||||
remove_contains_voice
|
||||
if can_publish.is_some()
|
||||
|| can_receive.is_some()
|
||||
|| voice_channel.is_some()
|
||||
|| remove_contains_voice
|
||||
{
|
||||
let mut conn = get_connection().await.to_internal_error()?;
|
||||
|
||||
@@ -228,32 +231,25 @@ pub async fn edit(
|
||||
}
|
||||
|
||||
if !permissions.has_channel_permission(ChannelPermission::Listen) {
|
||||
can_receive = Some(false)
|
||||
can_publish = Some(false)
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(can_publish) = can_publish {
|
||||
pipeline.set(
|
||||
format!("can_publish-{}", unique_key),
|
||||
can_publish,
|
||||
);
|
||||
|
||||
new_perms.can_publish = can_publish;
|
||||
new_perms.can_publish_data = can_publish;
|
||||
};
|
||||
|
||||
if let Some(can_receive) = can_receive {
|
||||
pipeline.set(
|
||||
format!("can_receive-{}", unique_key),
|
||||
can_receive,
|
||||
);
|
||||
|
||||
new_perms.can_subscribe = can_receive;
|
||||
};
|
||||
|
||||
if let Some(new_channel) = voice_channel {
|
||||
pipeline
|
||||
.smove(format!("vc-members-{channel}"), format!("vc-members-{new_channel}"), &member.id.user);
|
||||
pipeline.smove(
|
||||
format!("vc-members-{channel}"),
|
||||
format!("vc-members-{new_channel}"),
|
||||
&member.id.user,
|
||||
);
|
||||
};
|
||||
|
||||
pipeline
|
||||
@@ -261,19 +257,9 @@ pub async fn edit(
|
||||
.await
|
||||
.to_internal_error()?;
|
||||
|
||||
voice_client.update_permissions(&user, &channel, new_perms).await?;
|
||||
|
||||
EventV1::UserVoiceStateUpdate {
|
||||
id: member.id.user.clone(),
|
||||
channel_id: channel.clone(),
|
||||
data: PartialUserVoiceState {
|
||||
can_publish,
|
||||
can_receive,
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
.p(channel)
|
||||
.await;
|
||||
voice_client
|
||||
.update_permissions(&user, &channel, new_perms)
|
||||
.await?;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -34,9 +34,9 @@ pub async fn create(
|
||||
.throw_if_lacking_channel_permission(ChannelPermission::ManageRole)?;
|
||||
|
||||
let config = config().await;
|
||||
if server.roles.len() >= config.features.limits.default.server_roles {
|
||||
if server.roles.len() >= config.features.limits.global.server_roles {
|
||||
return Err(create_error!(TooManyRoles {
|
||||
max: config.features.limits.default.server_roles,
|
||||
max: config.features.limits.global.server_roles,
|
||||
}));
|
||||
};
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
use livekit_protocol::ParticipantPermission;
|
||||
use revolt_database::{
|
||||
util::{permissions::DatabasePermissionQuery, reference::Reference}, Channel, Database, User
|
||||
};
|
||||
use revolt_models::v0::PartialUserVoiceState;
|
||||
use revolt_permissions::{calculate_channel_permissions, calculate_server_permissions, ChannelPermission};
|
||||
use revolt_result::{create_error, Result};
|
||||
use revolt_voice::{get_allowed_sources, get_voice_channel_members, get_voice_state};
|
||||
use revolt_voice::{get_allowed_sources, get_voice_channel_members, get_voice_state, update_voice_state, VoiceClient};
|
||||
use rocket::State;
|
||||
use rocket_empty::EmptyResponse;
|
||||
|
||||
@@ -18,6 +19,7 @@ pub async fn delete(
|
||||
user: User,
|
||||
target: Reference,
|
||||
role_id: String,
|
||||
voice_client: &State<VoiceClient>
|
||||
) -> Result<EmptyResponse> {
|
||||
let mut server = target.as_server(db).await?;
|
||||
let mut query = DatabasePermissionQuery::new(db, &user).server(&server);
|
||||
@@ -50,22 +52,27 @@ pub async fn delete(
|
||||
|
||||
let permissions = calculate_channel_permissions(&mut query).await;
|
||||
|
||||
let sources = get_allowed_sources(permissions);
|
||||
|
||||
let mut update_event = PartialUserVoiceState {
|
||||
id: Some(user.id.clone()),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
if !sources.contains(&"CAMERA".to_string()) {
|
||||
update_event.camera =
|
||||
update_event
|
||||
}
|
||||
let can_video = permissions.has_channel_permission(ChannelPermission::Video);
|
||||
let can_speak = permissions.has_channel_permission(ChannelPermission::Speak);
|
||||
let can_listen = permissions.has_channel_permission(ChannelPermission::Listen);
|
||||
|
||||
if voice_state.camera && !sources.contains(&"MICROPHONE".to_string()) {
|
||||
update_event. = Some(false);
|
||||
}
|
||||
update_event.camera = voice_state.camera.then_some(can_video);
|
||||
update_event.screensharing = voice_state.screensharing.then_some(can_video);
|
||||
update_event.is_publishing = voice_state.is_publishing.then_some(can_speak);
|
||||
|
||||
update_voice_state(channel_id, Some(&server.id), &user.id, &update_event).await?;
|
||||
|
||||
voice_client.update_permissions(&user, channel_id, ParticipantPermission {
|
||||
can_subscribe: can_listen,
|
||||
can_publish: can_speak,
|
||||
can_publish_data: can_speak,
|
||||
..Default::default()
|
||||
}).await?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
use livekit_protocol::ParticipantPermission;
|
||||
use revolt_database::{
|
||||
util::{permissions::DatabasePermissionQuery, reference::Reference}, Channel, Database, PartialRole, User
|
||||
};
|
||||
use revolt_models::v0::{self, PartialUserVoiceState};
|
||||
use revolt_permissions::{calculate_channel_permissions, calculate_server_permissions, ChannelPermission, PermissionQuery};
|
||||
use revolt_result::{create_error, Result};
|
||||
use revolt_voice::{get_allowed_sources, get_voice_channel_members, get_voice_state, update_voice_state_tracks, VoiceClient};
|
||||
use revolt_voice::{get_allowed_sources, get_voice_channel_members, get_voice_state, update_voice_state, update_voice_state_tracks, VoiceClient};
|
||||
use rocket::{serde::json::Json, State};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use validator::Validate;
|
||||
@@ -21,6 +22,7 @@ pub async fn edit(
|
||||
target: Reference,
|
||||
role_id: String,
|
||||
data: Json<v0::DataEditRole>,
|
||||
voice_client: &State<VoiceClient>
|
||||
) -> Result<Json<v0::Role>> {
|
||||
let data = data.into_inner();
|
||||
data.validate().map_err(|error| {
|
||||
@@ -95,16 +97,27 @@ pub async fn edit(
|
||||
|
||||
let permissions = calculate_channel_permissions(&mut query).await;
|
||||
|
||||
let sources = get_allowed_sources(permissions);
|
||||
|
||||
let mut update_event = PartialUserVoiceState {
|
||||
id: Some(user.id.clone()),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
if voice_state.camera && !sources.contains(&"CAMERA".to_string()) {
|
||||
update_event.camera = Some(false);
|
||||
}
|
||||
let can_video = permissions.has_channel_permission(ChannelPermission::Video);
|
||||
let can_speak = permissions.has_channel_permission(ChannelPermission::Speak);
|
||||
let can_listen = permissions.has_channel_permission(ChannelPermission::Listen);
|
||||
|
||||
update_event.camera = voice_state.camera.then_some(can_video);
|
||||
update_event.screensharing = voice_state.screensharing.then_some(can_video);
|
||||
update_event.is_publishing = voice_state.is_publishing.then_some(can_speak);
|
||||
|
||||
update_voice_state(channel_id, Some(&server.id), &user.id, &update_event).await?;
|
||||
|
||||
voice_client.update_permissions(&user, channel_id, ParticipantPermission {
|
||||
can_subscribe: can_listen,
|
||||
can_publish: can_speak,
|
||||
can_publish_data: can_speak,
|
||||
..Default::default()
|
||||
}).await?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
use revolt_database::{util::reference::Reference, Database};
|
||||
use revolt_database::{
|
||||
util::{permissions::DatabasePermissionQuery, reference::Reference},
|
||||
Database, User,
|
||||
};
|
||||
use revolt_models::v0;
|
||||
use revolt_permissions::PermissionQuery;
|
||||
use revolt_result::{create_error, Result};
|
||||
use rocket::{serde::json::Json, State};
|
||||
|
||||
@@ -10,10 +14,16 @@ use rocket::{serde::json::Json, State};
|
||||
#[get("/<target>/roles/<role_id>")]
|
||||
pub async fn fetch(
|
||||
db: &State<Database>,
|
||||
user: User,
|
||||
target: Reference,
|
||||
role_id: String,
|
||||
) -> Result<Json<v0::Role>> {
|
||||
let mut server = target.as_server(db).await?;
|
||||
let mut query = DatabasePermissionQuery::new(db, &user).server(&server);
|
||||
if !query.are_we_a_member().await {
|
||||
return Err(create_error!(NotFound));
|
||||
}
|
||||
|
||||
let role = server.roles.remove(&role_id);
|
||||
|
||||
if let Some(role) = role {
|
||||
|
||||
@@ -30,7 +30,7 @@ pub async fn create_server(
|
||||
user.can_acquire_server(db).await?;
|
||||
|
||||
let (server, channels) = Server::create(db, data, &user, true).await?;
|
||||
let channels = Member::create(db, &server, &user, Some(channels)).await?;
|
||||
let (_, channels) = Member::create(db, &server, &user, Some(channels)).await?;
|
||||
|
||||
Ok(Json(v0::CreateServerLegacyResponse {
|
||||
server: server.into(),
|
||||
|
||||
@@ -138,13 +138,13 @@ pub async fn edit(
|
||||
|
||||
// 3. Apply new icon
|
||||
if let Some(icon) = icon {
|
||||
partial.icon = Some(File::use_server_icon(db, &icon, &server.id).await?);
|
||||
partial.icon = Some(File::use_server_icon(db, &icon, &server.id, &user.id).await?);
|
||||
server.icon = partial.icon.clone();
|
||||
}
|
||||
|
||||
// 4. Apply new banner
|
||||
if let Some(banner) = banner {
|
||||
partial.banner = Some(File::use_banner(db, &banner, &server.id).await?);
|
||||
partial.banner = Some(File::use_server_banner(db, &banner, &server.id, &user.id).await?);
|
||||
server.banner = partial.banner.clone();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use revolt_database::util::reference::Reference;
|
||||
use revolt_database::{Database, User};
|
||||
use revolt_database::{Database, User, AMQP};
|
||||
use revolt_models::v0;
|
||||
use revolt_result::{create_error, Result};
|
||||
use rocket::serde::json::Json;
|
||||
@@ -12,6 +12,7 @@ use rocket::State;
|
||||
#[put("/<target>/friend")]
|
||||
pub async fn add(
|
||||
db: &State<Database>,
|
||||
amqp: &State<AMQP>,
|
||||
mut user: User,
|
||||
target: Reference,
|
||||
) -> Result<Json<v0::User>> {
|
||||
@@ -21,6 +22,6 @@ pub async fn add(
|
||||
return Err(create_error!(IsBot));
|
||||
}
|
||||
|
||||
user.add_friend(db, &mut target).await?;
|
||||
user.add_friend(db, amqp, &mut target).await?;
|
||||
Ok(Json(target.into(db, &user).await))
|
||||
}
|
||||
|
||||
@@ -24,23 +24,26 @@ pub async fn edit(
|
||||
})
|
||||
})?;
|
||||
|
||||
// Filter out invalid edit fields
|
||||
if !user.privileged && (data.badges.is_some() || data.flags.is_some()) {
|
||||
return Err(create_error!(NotPrivileged));
|
||||
}
|
||||
|
||||
// If we want to edit a different user than self, ensure we have
|
||||
// permissions and subsequently replace the user in question
|
||||
if target.id != "@me" && target.id != user.id {
|
||||
let target_user = target.as_user(db).await?;
|
||||
let is_bot_owner = target_user
|
||||
.bot
|
||||
.as_ref()
|
||||
.map(|bot| bot.owner == user.id)
|
||||
.unwrap_or_default();
|
||||
|
||||
if !is_bot_owner && !user.privileged {
|
||||
return Err(create_error!(NotPrivileged));
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise, filter out invalid edit fields
|
||||
if !user.privileged && (data.badges.is_some() || data.flags.is_some()) {
|
||||
return Err(create_error!(NotPrivileged));
|
||||
user = target_user;
|
||||
}
|
||||
|
||||
// Exit out early if nothing is changed
|
||||
@@ -52,7 +55,7 @@ pub async fn edit(
|
||||
&& data.flags.is_none()
|
||||
&& data.remove.is_none()
|
||||
{
|
||||
return Ok(Json(user.into_self().await));
|
||||
return Ok(Json(user.into_self(false).await));
|
||||
}
|
||||
|
||||
// 1. Remove fields from object
|
||||
@@ -86,7 +89,7 @@ pub async fn edit(
|
||||
|
||||
// 2. Apply new avatar
|
||||
if let Some(avatar) = data.avatar {
|
||||
partial.avatar = Some(File::use_avatar(db, &avatar, &user.id).await?);
|
||||
partial.avatar = Some(File::use_user_avatar(db, &avatar, &user.id, &user.id).await?);
|
||||
}
|
||||
|
||||
// 3. Apply new status
|
||||
@@ -111,7 +114,8 @@ pub async fn edit(
|
||||
}
|
||||
|
||||
if let Some(background) = profile.background {
|
||||
new_profile.background = Some(File::use_background(db, &background, &user.id).await?);
|
||||
new_profile.background =
|
||||
Some(File::use_background(db, &background, &user.id, &user.id).await?);
|
||||
}
|
||||
|
||||
partial.profile = Some(new_profile);
|
||||
@@ -126,5 +130,5 @@ pub async fn edit(
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(Json(user.into_self().await))
|
||||
Ok(Json(user.into_self(false).await))
|
||||
}
|
||||
|
||||
@@ -9,5 +9,5 @@ use rocket::serde::json::Json;
|
||||
#[openapi(tag = "User Information")]
|
||||
#[get("/@me")]
|
||||
pub async fn fetch(user: User) -> Result<Json<v0::User>> {
|
||||
Ok(Json(user.into_self().await))
|
||||
Ok(Json(user.into_self(false).await))
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ use rocket::{serde::json::Json, State};
|
||||
#[get("/<target>")]
|
||||
pub async fn fetch(db: &State<Database>, user: User, target: Reference) -> Result<Json<v0::User>> {
|
||||
if user.id == target.id {
|
||||
return Ok(Json(user.into_self().await));
|
||||
return Ok(Json(user.into_self(false).await));
|
||||
}
|
||||
|
||||
let target = target.as_user(db).await?;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use revolt_database::util::reference::Reference;
|
||||
use revolt_database::{Database, User};
|
||||
// use revolt_database::util::reference::Reference;
|
||||
use revolt_database::{Database, User, AMQP};
|
||||
use revolt_models::v0;
|
||||
use revolt_result::{create_error, Result};
|
||||
use rocket::serde::json::Json;
|
||||
@@ -12,6 +12,7 @@ use rocket::State;
|
||||
#[post("/friend", data = "<data>")]
|
||||
pub async fn send_friend_request(
|
||||
db: &State<Database>,
|
||||
amqp: &State<AMQP>,
|
||||
mut user: User,
|
||||
data: Json<v0::DataSendFriendRequest>,
|
||||
) -> Result<Json<v0::User>> {
|
||||
@@ -22,7 +23,7 @@ pub async fn send_friend_request(
|
||||
return Err(create_error!(IsBot));
|
||||
}
|
||||
|
||||
user.add_friend(db, &mut target).await?;
|
||||
user.add_friend(db, amqp, &mut target).await?;
|
||||
Ok(Json(target.into(db, &user).await))
|
||||
} else {
|
||||
Err(create_error!(InvalidProperty))
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use revolt_database::{
|
||||
util::{permissions::DatabasePermissionQuery, reference::Reference},
|
||||
Database, PartialWebhook, User,
|
||||
Database, File, PartialWebhook, User,
|
||||
};
|
||||
use revolt_models::v0::{DataEditWebhook, Webhook};
|
||||
use revolt_permissions::{calculate_channel_permissions, ChannelPermission};
|
||||
@@ -52,10 +52,7 @@ pub async fn webhook_edit(
|
||||
};
|
||||
|
||||
if let Some(avatar) = avatar {
|
||||
let file = db
|
||||
.find_and_use_attachment(&avatar, "avatars", "user", &webhook.id)
|
||||
.await?;
|
||||
|
||||
let file = File::use_webhook_avatar(db, &avatar, &webhook.id, &webhook.creator_id).await?;
|
||||
partial.avatar = Some(file)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use revolt_database::util::reference::Reference;
|
||||
use revolt_database::{Database, PartialWebhook};
|
||||
use revolt_database::{Database, File, PartialWebhook};
|
||||
use revolt_models::v0::{DataEditWebhook, Webhook};
|
||||
use revolt_models::validator::Validate;
|
||||
use revolt_result::{create_error, Result};
|
||||
@@ -34,7 +34,7 @@ pub async fn webhook_edit_token(
|
||||
name,
|
||||
avatar,
|
||||
permissions,
|
||||
remove
|
||||
remove,
|
||||
} = data;
|
||||
|
||||
let mut partial = PartialWebhook {
|
||||
@@ -44,10 +44,7 @@ pub async fn webhook_edit_token(
|
||||
};
|
||||
|
||||
if let Some(avatar) = avatar {
|
||||
let file = db
|
||||
.find_and_use_attachment(&avatar, "avatars", "user", &webhook.id)
|
||||
.await?;
|
||||
|
||||
let file = File::use_webhook_avatar(db, &avatar, &webhook.id, &webhook.creator_id).await?;
|
||||
partial.avatar = Some(file)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use revolt_config::config;
|
||||
use revolt_database::{
|
||||
util::{idempotency::IdempotencyKey, reference::Reference},
|
||||
Database, Message,
|
||||
Database, Message, AMQP,
|
||||
};
|
||||
use revolt_models::v0;
|
||||
use revolt_permissions::{ChannelPermission, PermissionValue};
|
||||
@@ -16,6 +17,7 @@ use validator::Validate;
|
||||
#[post("/<webhook_id>/<token>", data = "<data>")]
|
||||
pub async fn webhook_execute(
|
||||
db: &State<Database>,
|
||||
amqp: &State<AMQP>,
|
||||
webhook_id: Reference,
|
||||
token: String,
|
||||
data: Json<v0::DataMessageSend>,
|
||||
@@ -55,14 +57,18 @@ pub async fn webhook_execute(
|
||||
Ok(Json(
|
||||
Message::create_from_api(
|
||||
db,
|
||||
Some(amqp),
|
||||
channel,
|
||||
data,
|
||||
v0::MessageAuthor::Webhook(&webhook.into()),
|
||||
None,
|
||||
None,
|
||||
config().await.features.limits.default,
|
||||
idempotency,
|
||||
true,
|
||||
true,
|
||||
)
|
||||
.await?
|
||||
.into(),
|
||||
.into_model(None, None),
|
||||
))
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use revolt_database::{util::reference::Reference, Database, Message};
|
||||
use revolt_database::{util::reference::Reference, Database, Message, AMQP};
|
||||
use revolt_models::v0::{MessageAuthor, SendableEmbed, Webhook};
|
||||
use revolt_result::{create_error, Error, Result};
|
||||
use revolt_rocket_okapi::{
|
||||
@@ -635,7 +635,10 @@ impl<'r> FromRequest<'r> for EventHeader<'r> {
|
||||
async fn from_request(request: &'r Request<'_>) -> rocket::request::Outcome<Self, Self::Error> {
|
||||
let headers = request.headers();
|
||||
let Some(event) = headers.get_one("X-GitHub-Event") else {
|
||||
return rocket::request::Outcome::Failure((Status::BadRequest, create_error!(InvalidOperation)))
|
||||
return rocket::request::Outcome::Error((
|
||||
Status::BadRequest,
|
||||
create_error!(InvalidOperation),
|
||||
));
|
||||
};
|
||||
|
||||
rocket::request::Outcome::Success(Self(event))
|
||||
@@ -747,6 +750,7 @@ fn convert_event(data: &str, event_name: &str) -> Result<Event> {
|
||||
#[post("/<webhook_id>/<token>/github", data = "<data>")]
|
||||
pub async fn webhook_execute_github(
|
||||
db: &State<Database>,
|
||||
amqp: &State<AMQP>,
|
||||
webhook_id: Reference,
|
||||
token: String,
|
||||
event: EventHeader<'_>,
|
||||
@@ -784,7 +788,9 @@ pub async fn webhook_execute_github(
|
||||
r#ref,
|
||||
..
|
||||
}) => {
|
||||
let Some(branch) = r#ref.split('/').nth(2) else { return Ok(()) };
|
||||
let Some(branch) = r#ref.split('/').nth(2) else {
|
||||
return Ok(());
|
||||
};
|
||||
|
||||
if forced {
|
||||
let description = format!(
|
||||
@@ -1072,6 +1078,14 @@ pub async fn webhook_execute_github(
|
||||
#[allow(clippy::disallowed_methods)]
|
||||
message.attach_sendable_embed(db, sendable_embed).await?;
|
||||
message
|
||||
.send(db, MessageAuthor::Webhook(&webhook.into()), &channel, false)
|
||||
.send(
|
||||
db,
|
||||
Some(amqp),
|
||||
MessageAuthor::Webhook(&webhook.into()),
|
||||
None,
|
||||
None,
|
||||
&channel,
|
||||
false,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
@@ -1,138 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<!-- Compiled with Bootstrap Email version: 1.3.1 --><meta http-equiv="x-ua-compatible" content="ie=edge">
|
||||
<meta name="x-apple-disable-message-reformatting">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="format-detection" content="telephone=no, date=no, address=no, email=no">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<style type="text/css">
|
||||
body,table,td{font-family:Helvetica,Arial,sans-serif !important}.ExternalClass{width:100%}.ExternalClass,.ExternalClass p,.ExternalClass span,.ExternalClass font,.ExternalClass td,.ExternalClass div{line-height:150%}a{text-decoration:none}*{color:inherit}a[x-apple-data-detectors],u+#body a,#MessageViewBody a{color:inherit;text-decoration:none;font-size:inherit;font-family:inherit;font-weight:inherit;line-height:inherit}img{-ms-interpolation-mode:bicubic}table:not([class^=s-]){font-family:Helvetica,Arial,sans-serif;mso-table-lspace:0pt;mso-table-rspace:0pt;border-spacing:0px;border-collapse:collapse}table:not([class^=s-]) td{border-spacing:0px;border-collapse:collapse}@media screen and (max-width: 600px){.w-full,.w-full>tbody>tr>td{width:100% !important}.w-24,.w-24>tbody>tr>td{width:96px !important}.p-lg-10:not(table),.p-lg-10:not(.btn)>tbody>tr>td,.p-lg-10.btn td a{padding:0 !important}.p-3:not(table),.p-3:not(.btn)>tbody>tr>td,.p-3.btn td a{padding:12px !important}.p-6:not(table),.p-6:not(.btn)>tbody>tr>td,.p-6.btn td a{padding:24px !important}*[class*=s-lg-]>tbody>tr>td{font-size:0 !important;line-height:0 !important;height:0 !important}.s-4>tbody>tr>td{font-size:16px !important;line-height:16px !important;height:16px !important}.s-6>tbody>tr>td{font-size:24px !important;line-height:24px !important;height:24px !important}.s-10>tbody>tr>td{font-size:40px !important;line-height:40px !important;height:40px !important}}
|
||||
</style>
|
||||
</head>
|
||||
<body class="bg-light" style="outline: 0; width: 100%; min-width: 100%; height: 100%; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; font-family: Helvetica, Arial, sans-serif; line-height: 24px; font-weight: normal; font-size: 16px; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; color: #000000; margin: 0; padding: 0; border-width: 0;" bgcolor="#f7fafc">
|
||||
<table class="bg-light body" valign="top" role="presentation" border="0" cellpadding="0" cellspacing="0" style="outline: 0; width: 100%; min-width: 100%; height: 100%; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; font-family: Helvetica, Arial, sans-serif; line-height: 24px; font-weight: normal; font-size: 16px; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; color: #000000; margin: 0; padding: 0; border-width: 0;" bgcolor="#f7fafc">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td valign="top" style="line-height: 24px; font-size: 16px; margin: 0;" align="left" bgcolor="#f7fafc">
|
||||
<table class="container" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td align="center" style="line-height: 24px; font-size: 16px; margin: 0; padding: 0 16px;">
|
||||
<!--[if (gte mso 9)|(IE)]>
|
||||
<table align="center" role="presentation">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td width="600">
|
||||
<![endif]-->
|
||||
<table align="center" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%; max-width: 600px; margin: 0 auto;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="line-height: 24px; font-size: 16px; margin: 0;" align="left">
|
||||
<table class="s-10 w-full" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="line-height: 40px; font-size: 40px; width: 100%; height: 40px; margin: 0;" align="left" width="100%" height="40">
|
||||
 
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="ax-center" role="presentation" align="center" border="0" cellpadding="0" cellspacing="0" style="margin: 0 auto;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="line-height: 24px; font-size: 16px; margin: 0;" align="left">
|
||||
<img alt="Revolt Logo" class="w-24" src="https://app.revolt.chat/assets/logo_round.png" style="height: auto; line-height: 100%; outline: none; text-decoration: none; display: block; width: 96px; border-style: none; border-width: 0;" width="96">
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="s-10 w-full" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="line-height: 40px; font-size: 40px; width: 100%; height: 40px; margin: 0;" align="left" width="100%" height="40">
|
||||
 
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="card p-6 p-lg-10 space-y-4" role="presentation" border="0" cellpadding="0" cellspacing="0" style="border-radius: 6px; border-collapse: separate !important; width: 100%; overflow: hidden; border: 1px solid #e2e8f0;" bgcolor="#ffffff">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="line-height: 24px; font-size: 16px; width: 100%; margin: 0; padding: 40px;" align="left" bgcolor="#ffffff">
|
||||
<h1 class="h3 fw-700" style="padding-top: 0; padding-bottom: 0; font-weight: 700 !important; vertical-align: baseline; font-size: 28px; line-height: 33.6px; margin: 0;" align="left">Account Deletion</h1>
|
||||
<table class="s-4 w-full" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="line-height: 16px; font-size: 16px; width: 100%; height: 16px; margin: 0;" align="left" width="100%" height="16">
|
||||
 
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p class="" style="line-height: 24px; font-size: 16px; width: 100%; margin: 0;" align="left">You requested to have your account deleted, if you did not perform this action please take measures to secure your account immediately.</p>
|
||||
<table class="s-4 w-full" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="line-height: 16px; font-size: 16px; width: 100%; height: 16px; margin: 0;" align="left" width="100%" height="16">
|
||||
 
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="btn btn-primary p-3 fw-700" role="presentation" border="0" cellpadding="0" cellspacing="0" style="border-radius: 6px; border-collapse: separate !important; font-weight: 700 !important;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="line-height: 24px; font-size: 16px; border-radius: 6px; font-weight: 700 !important; margin: 0;" align="center" bgcolor="#0d6efd">
|
||||
<a href="{{url}}" style="color: #ffffff; font-size: 16px; font-family: Helvetica, Arial, sans-serif; text-decoration: none; border-radius: 6px; line-height: 20px; display: block; font-weight: 700 !important; white-space: nowrap; background-color: #0d6efd; padding: 12px; border: 1px solid #0d6efd;">Confirm</a>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="s-6 w-full" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="line-height: 24px; font-size: 24px; width: 100%; height: 24px; margin: 0;" align="left" width="100%" height="24">
|
||||
 
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="text-muted text-center" style="color: #718096;" align="center">
|
||||
This email is intended for {{email}}<br>
|
||||
Sent from Revolt<br>
|
||||
Made in the EU
|
||||
</div>
|
||||
<table class="s-6 w-full" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="line-height: 24px; font-size: 24px; width: 100%; height: 24px; margin: 0;" align="left" width="100%" height="24">
|
||||
 
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<!--[if (gte mso 9)|(IE)]>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<![endif]-->
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,30 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<style>
|
||||
/* Add custom classes and styles that you want inlined here */
|
||||
</style>
|
||||
</head>
|
||||
<body class="bg-light">
|
||||
<div class="container">
|
||||
<img
|
||||
alt="Revolt Logo"
|
||||
class="ax-center my-10 w-24"
|
||||
src="https://app.revolt.chat/assets/logo_round.png"
|
||||
/>
|
||||
<div class="card p-6 p-lg-10 space-y-4">
|
||||
<h1 class="h3 fw-700">Account Deletion</h1>
|
||||
<p>
|
||||
You requested to have your account deleted, if you did not perform
|
||||
this action please take measures to secure your account immediately.
|
||||
</p>
|
||||
<a class="btn btn-primary p-3 fw-700" href="{{url}}">Confirm</a>
|
||||
</div>
|
||||
<div class="text-muted text-center my-6">
|
||||
This email is intended for {{email}}<br />
|
||||
Sent from Revolt<br />
|
||||
Made in the EU
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,7 +0,0 @@
|
||||
You requested to have your account deleted, if you did not perform this action please take measures to secure your account immediately.
|
||||
|
||||
Please navigate to: {{url}}
|
||||
|
||||
This email is intended for {{email}}
|
||||
Sent by Revolt
|
||||
Made in the EU
|
||||
@@ -1,138 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<!-- Compiled with Bootstrap Email version: 1.3.1 --><meta http-equiv="x-ua-compatible" content="ie=edge">
|
||||
<meta name="x-apple-disable-message-reformatting">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="format-detection" content="telephone=no, date=no, address=no, email=no">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<style type="text/css">
|
||||
body,table,td{font-family:Helvetica,Arial,sans-serif !important}.ExternalClass{width:100%}.ExternalClass,.ExternalClass p,.ExternalClass span,.ExternalClass font,.ExternalClass td,.ExternalClass div{line-height:150%}a{text-decoration:none}*{color:inherit}a[x-apple-data-detectors],u+#body a,#MessageViewBody a{color:inherit;text-decoration:none;font-size:inherit;font-family:inherit;font-weight:inherit;line-height:inherit}img{-ms-interpolation-mode:bicubic}table:not([class^=s-]){font-family:Helvetica,Arial,sans-serif;mso-table-lspace:0pt;mso-table-rspace:0pt;border-spacing:0px;border-collapse:collapse}table:not([class^=s-]) td{border-spacing:0px;border-collapse:collapse}@media screen and (max-width: 600px){.w-full,.w-full>tbody>tr>td{width:100% !important}.w-24,.w-24>tbody>tr>td{width:96px !important}.p-lg-10:not(table),.p-lg-10:not(.btn)>tbody>tr>td,.p-lg-10.btn td a{padding:0 !important}.p-3:not(table),.p-3:not(.btn)>tbody>tr>td,.p-3.btn td a{padding:12px !important}.p-6:not(table),.p-6:not(.btn)>tbody>tr>td,.p-6.btn td a{padding:24px !important}*[class*=s-lg-]>tbody>tr>td{font-size:0 !important;line-height:0 !important;height:0 !important}.s-4>tbody>tr>td{font-size:16px !important;line-height:16px !important;height:16px !important}.s-6>tbody>tr>td{font-size:24px !important;line-height:24px !important;height:24px !important}.s-10>tbody>tr>td{font-size:40px !important;line-height:40px !important;height:40px !important}}
|
||||
</style>
|
||||
</head>
|
||||
<body class="bg-light" style="outline: 0; width: 100%; min-width: 100%; height: 100%; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; font-family: Helvetica, Arial, sans-serif; line-height: 24px; font-weight: normal; font-size: 16px; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; color: #000000; margin: 0; padding: 0; border-width: 0;" bgcolor="#f7fafc">
|
||||
<table class="bg-light body" valign="top" role="presentation" border="0" cellpadding="0" cellspacing="0" style="outline: 0; width: 100%; min-width: 100%; height: 100%; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; font-family: Helvetica, Arial, sans-serif; line-height: 24px; font-weight: normal; font-size: 16px; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; color: #000000; margin: 0; padding: 0; border-width: 0;" bgcolor="#f7fafc">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td valign="top" style="line-height: 24px; font-size: 16px; margin: 0;" align="left" bgcolor="#f7fafc">
|
||||
<table class="container" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td align="center" style="line-height: 24px; font-size: 16px; margin: 0; padding: 0 16px;">
|
||||
<!--[if (gte mso 9)|(IE)]>
|
||||
<table align="center" role="presentation">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td width="600">
|
||||
<![endif]-->
|
||||
<table align="center" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%; max-width: 600px; margin: 0 auto;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="line-height: 24px; font-size: 16px; margin: 0;" align="left">
|
||||
<table class="s-10 w-full" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="line-height: 40px; font-size: 40px; width: 100%; height: 40px; margin: 0;" align="left" width="100%" height="40">
|
||||
 
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="ax-center" role="presentation" align="center" border="0" cellpadding="0" cellspacing="0" style="margin: 0 auto;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="line-height: 24px; font-size: 16px; margin: 0;" align="left">
|
||||
<img alt="Revolt Logo" class="w-24" src="https://app.revolt.chat/assets/logo_round.png" style="height: auto; line-height: 100%; outline: none; text-decoration: none; display: block; width: 96px; border-style: none; border-width: 0;" width="96">
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="s-10 w-full" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="line-height: 40px; font-size: 40px; width: 100%; height: 40px; margin: 0;" align="left" width="100%" height="40">
|
||||
 
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="card p-6 p-lg-10 space-y-4" role="presentation" border="0" cellpadding="0" cellspacing="0" style="border-radius: 6px; border-collapse: separate !important; width: 100%; overflow: hidden; border: 1px solid #e2e8f0;" bgcolor="#ffffff">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="line-height: 24px; font-size: 16px; width: 100%; margin: 0; padding: 40px;" align="left" bgcolor="#ffffff">
|
||||
<h1 class="h3 fw-700" style="padding-top: 0; padding-bottom: 0; font-weight: 700 !important; vertical-align: baseline; font-size: 28px; line-height: 33.6px; margin: 0;" align="left">Password Reset</h1>
|
||||
<table class="s-4 w-full" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="line-height: 16px; font-size: 16px; width: 100%; height: 16px; margin: 0;" align="left" width="100%" height="16">
|
||||
 
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p class="" style="line-height: 24px; font-size: 16px; width: 100%; margin: 0;" align="left">You requested a password reset, click below to continue.</p>
|
||||
<table class="s-4 w-full" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="line-height: 16px; font-size: 16px; width: 100%; height: 16px; margin: 0;" align="left" width="100%" height="16">
|
||||
 
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="btn btn-primary p-3 fw-700" role="presentation" border="0" cellpadding="0" cellspacing="0" style="border-radius: 6px; border-collapse: separate !important; font-weight: 700 !important;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="line-height: 24px; font-size: 16px; border-radius: 6px; font-weight: 700 !important; margin: 0;" align="center" bgcolor="#0d6efd">
|
||||
<a href="{{url}}" style="color: #ffffff; font-size: 16px; font-family: Helvetica, Arial, sans-serif; text-decoration: none; border-radius: 6px; line-height: 20px; display: block; font-weight: 700 !important; white-space: nowrap; background-color: #0d6efd; padding: 12px; border: 1px solid #0d6efd;">Reset</a>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="s-6 w-full" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="line-height: 24px; font-size: 24px; width: 100%; height: 24px; margin: 0;" align="left" width="100%" height="24">
|
||||
 
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="text-muted text-center" style="color: #718096;" align="center">
|
||||
This email is intended for {{email}}<br>
|
||||
Sent from Revolt<br>
|
||||
Made in the EU
|
||||
</div>
|
||||
<table class="s-6 w-full" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="line-height: 24px; font-size: 24px; width: 100%; height: 24px; margin: 0;" align="left" width="100%" height="24">
|
||||
 
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<!--[if (gte mso 9)|(IE)]>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<![endif]-->
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,26 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<style>
|
||||
/* Add custom classes and styles that you want inlined here */
|
||||
</style>
|
||||
</head>
|
||||
<body class="bg-light">
|
||||
<div class="container">
|
||||
<img
|
||||
class="ax-center my-10 w-24"
|
||||
src="https://app.revolt.chat/assets/logo_round.png"
|
||||
/>
|
||||
<div class="card p-6 p-lg-10 space-y-4">
|
||||
<h1 class="h3 fw-700">Password Reset</h1>
|
||||
<p>You requested a password reset, click below to continue.</p>
|
||||
<a class="btn btn-primary p-3 fw-700" href="{{url}}">Reset</a>
|
||||
</div>
|
||||
<div class="text-muted text-center my-6">
|
||||
This email is intended for {{email}}<br />
|
||||
Sent from Revolt<br />
|
||||
Made in the EU
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,7 +0,0 @@
|
||||
You requested a password reset, if you did not perform this action you can safely ignore this email.
|
||||
|
||||
Please navigate to: {{url}}
|
||||
|
||||
This email is intended for {{email}}
|
||||
Sent by Revolt
|
||||
Made in the EU
|
||||
@@ -1,138 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<!-- Compiled with Bootstrap Email version: 1.3.1 --><meta http-equiv="x-ua-compatible" content="ie=edge">
|
||||
<meta name="x-apple-disable-message-reformatting">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="format-detection" content="telephone=no, date=no, address=no, email=no">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<style type="text/css">
|
||||
body,table,td{font-family:Helvetica,Arial,sans-serif !important}.ExternalClass{width:100%}.ExternalClass,.ExternalClass p,.ExternalClass span,.ExternalClass font,.ExternalClass td,.ExternalClass div{line-height:150%}a{text-decoration:none}*{color:inherit}a[x-apple-data-detectors],u+#body a,#MessageViewBody a{color:inherit;text-decoration:none;font-size:inherit;font-family:inherit;font-weight:inherit;line-height:inherit}img{-ms-interpolation-mode:bicubic}table:not([class^=s-]){font-family:Helvetica,Arial,sans-serif;mso-table-lspace:0pt;mso-table-rspace:0pt;border-spacing:0px;border-collapse:collapse}table:not([class^=s-]) td{border-spacing:0px;border-collapse:collapse}@media screen and (max-width: 600px){.w-full,.w-full>tbody>tr>td{width:100% !important}.w-24,.w-24>tbody>tr>td{width:96px !important}.p-lg-10:not(table),.p-lg-10:not(.btn)>tbody>tr>td,.p-lg-10.btn td a{padding:0 !important}.p-3:not(table),.p-3:not(.btn)>tbody>tr>td,.p-3.btn td a{padding:12px !important}.p-6:not(table),.p-6:not(.btn)>tbody>tr>td,.p-6.btn td a{padding:24px !important}*[class*=s-lg-]>tbody>tr>td{font-size:0 !important;line-height:0 !important;height:0 !important}.s-4>tbody>tr>td{font-size:16px !important;line-height:16px !important;height:16px !important}.s-6>tbody>tr>td{font-size:24px !important;line-height:24px !important;height:24px !important}.s-10>tbody>tr>td{font-size:40px !important;line-height:40px !important;height:40px !important}}
|
||||
</style>
|
||||
</head>
|
||||
<body class="bg-light" style="outline: 0; width: 100%; min-width: 100%; height: 100%; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; font-family: Helvetica, Arial, sans-serif; line-height: 24px; font-weight: normal; font-size: 16px; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; color: #000000; margin: 0; padding: 0; border-width: 0;" bgcolor="#f7fafc">
|
||||
<table class="bg-light body" valign="top" role="presentation" border="0" cellpadding="0" cellspacing="0" style="outline: 0; width: 100%; min-width: 100%; height: 100%; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; font-family: Helvetica, Arial, sans-serif; line-height: 24px; font-weight: normal; font-size: 16px; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; color: #000000; margin: 0; padding: 0; border-width: 0;" bgcolor="#f7fafc">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td valign="top" style="line-height: 24px; font-size: 16px; margin: 0;" align="left" bgcolor="#f7fafc">
|
||||
<table class="container" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td align="center" style="line-height: 24px; font-size: 16px; margin: 0; padding: 0 16px;">
|
||||
<!--[if (gte mso 9)|(IE)]>
|
||||
<table align="center" role="presentation">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td width="600">
|
||||
<![endif]-->
|
||||
<table align="center" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%; max-width: 600px; margin: 0 auto;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="line-height: 24px; font-size: 16px; margin: 0;" align="left">
|
||||
<table class="s-10 w-full" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="line-height: 40px; font-size: 40px; width: 100%; height: 40px; margin: 0;" align="left" width="100%" height="40">
|
||||
 
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="ax-center" role="presentation" align="center" border="0" cellpadding="0" cellspacing="0" style="margin: 0 auto;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="line-height: 24px; font-size: 16px; margin: 0;" align="left">
|
||||
<img alt="Revolt Logo" class="w-24" src="https://app.revolt.chat/assets/logo_round.png" style="height: auto; line-height: 100%; outline: none; text-decoration: none; display: block; width: 96px; border-style: none; border-width: 0;" width="96">
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="s-10 w-full" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="line-height: 40px; font-size: 40px; width: 100%; height: 40px; margin: 0;" align="left" width="100%" height="40">
|
||||
 
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="card p-6 p-lg-10 space-y-4" role="presentation" border="0" cellpadding="0" cellspacing="0" style="border-radius: 6px; border-collapse: separate !important; width: 100%; overflow: hidden; border: 1px solid #e2e8f0;" bgcolor="#ffffff">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="line-height: 24px; font-size: 16px; width: 100%; margin: 0; padding: 40px;" align="left" bgcolor="#ffffff">
|
||||
<h1 class="h3 fw-700" style="padding-top: 0; padding-bottom: 0; font-weight: 700 !important; vertical-align: baseline; font-size: 28px; line-height: 33.6px; margin: 0;" align="left">Almost there!</h1>
|
||||
<table class="s-4 w-full" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="line-height: 16px; font-size: 16px; width: 100%; height: 16px; margin: 0;" align="left" width="100%" height="16">
|
||||
 
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p class="" style="line-height: 24px; font-size: 16px; width: 100%; margin: 0;" align="left">To complete your sign up, we just need to verify your email.</p>
|
||||
<table class="s-4 w-full" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="line-height: 16px; font-size: 16px; width: 100%; height: 16px; margin: 0;" align="left" width="100%" height="16">
|
||||
 
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="btn btn-primary p-3 fw-700" role="presentation" border="0" cellpadding="0" cellspacing="0" style="border-radius: 6px; border-collapse: separate !important; font-weight: 700 !important;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="line-height: 24px; font-size: 16px; border-radius: 6px; font-weight: 700 !important; margin: 0;" align="center" bgcolor="#0d6efd">
|
||||
<a href="{{url}}" style="color: #ffffff; font-size: 16px; font-family: Helvetica, Arial, sans-serif; text-decoration: none; border-radius: 6px; line-height: 20px; display: block; font-weight: 700 !important; white-space: nowrap; background-color: #0d6efd; padding: 12px; border: 1px solid #0d6efd;">Confirm</a>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="s-6 w-full" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="line-height: 24px; font-size: 24px; width: 100%; height: 24px; margin: 0;" align="left" width="100%" height="24">
|
||||
 
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="text-muted text-center" style="color: #718096;" align="center">
|
||||
This email is intended for {{email}}<br>
|
||||
Sent from Revolt<br>
|
||||
Made in the EU
|
||||
</div>
|
||||
<table class="s-6 w-full" role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="line-height: 24px; font-size: 24px; width: 100%; height: 24px; margin: 0;" align="left" width="100%" height="24">
|
||||
 
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<!--[if (gte mso 9)|(IE)]>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<![endif]-->
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,27 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<style>
|
||||
/* Add custom classes and styles that you want inlined here */
|
||||
</style>
|
||||
</head>
|
||||
<body class="bg-light">
|
||||
<div class="container">
|
||||
<img
|
||||
alt="Revolt Logo"
|
||||
class="ax-center my-10 w-24"
|
||||
src="https://app.revolt.chat/assets/logo_round.png"
|
||||
/>
|
||||
<div class="card p-6 p-lg-10 space-y-4">
|
||||
<h1 class="h3 fw-700">Almost there!</h1>
|
||||
<p>To complete your sign up, we just need to verify your email.</p>
|
||||
<a class="btn btn-primary p-3 fw-700" href="{{url}}">Confirm</a>
|
||||
</div>
|
||||
<div class="text-muted text-center my-6">
|
||||
This email is intended for {{email}}<br />
|
||||
Sent from Revolt<br />
|
||||
Made in the EU
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,8 +0,0 @@
|
||||
Almost there!
|
||||
To complete your sign up, we just need to verify your email.
|
||||
|
||||
Please navigate to: {{url}}
|
||||
|
||||
This email is intended for {{email}}
|
||||
Sent by Revolt
|
||||
Made in the EU
|
||||
@@ -235,7 +235,7 @@ impl<'r> FromRequest<'r> for Ratelimiter {
|
||||
|
||||
match ratelimiter {
|
||||
Ok(ratelimiter) => Outcome::Success(*ratelimiter),
|
||||
Err(ratelimiter) => Outcome::Failure((Status::TooManyRequests, *ratelimiter)),
|
||||
Err(ratelimiter) => Outcome::Error((Status::TooManyRequests, *ratelimiter)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -264,7 +264,7 @@ impl Fairing for RatelimitFairing {
|
||||
|
||||
async fn on_request(&self, request: &mut Request<'_>, _: &mut Data<'_>) {
|
||||
use rocket::outcome::Outcome;
|
||||
if let Outcome::Failure(_) = request.guard::<Ratelimiter>().await {
|
||||
if let Outcome::Error(_) = request.guard::<Ratelimiter>().await {
|
||||
info!(
|
||||
"User rate-limited on route {}! (IP = {:?})",
|
||||
request.uri(),
|
||||
@@ -278,7 +278,7 @@ impl Fairing for RatelimitFairing {
|
||||
|
||||
async fn on_response<'r>(&self, request: &'r Request<'_>, response: &mut Response<'r>) {
|
||||
let guard = request.guard::<Ratelimiter>().await;
|
||||
let (Outcome::Success(ratelimiter) | Outcome::Failure((_, ratelimiter))) = guard else {
|
||||
let (Outcome::Success(ratelimiter) | Outcome::Error((_, ratelimiter))) = guard else {
|
||||
unreachable!()
|
||||
};
|
||||
let Ratelimiter {
|
||||
@@ -293,7 +293,7 @@ impl Fairing for RatelimitFairing {
|
||||
response.set_raw_header("X-RateLimit-Remaining", remaining.to_string());
|
||||
response.set_raw_header("X-RateLimit-Reset-After", reset.to_string());
|
||||
|
||||
if guard.is_failure() {
|
||||
if guard.is_error() {
|
||||
response.set_status(Status::TooManyRequests);
|
||||
}
|
||||
}
|
||||
@@ -313,7 +313,7 @@ impl<'r> FromRequest<'r> for RatelimitInformation {
|
||||
async fn from_request(request: &'r rocket::Request<'_>) -> Outcome<Self, Self::Error> {
|
||||
let info = match request.guard::<Ratelimiter>().await {
|
||||
Outcome::Success(ratelimiter) => RatelimitInformation::Success(ratelimiter),
|
||||
Outcome::Failure((_, ratelimiter)) => RatelimitInformation::Failure {
|
||||
Outcome::Error((_, ratelimiter)) => RatelimitInformation::Failure {
|
||||
retry_after: ratelimiter.reset,
|
||||
},
|
||||
_ => unreachable!(),
|
||||
|
||||
@@ -5,7 +5,7 @@ use authifier::{
|
||||
use futures::StreamExt;
|
||||
use rand::Rng;
|
||||
use redis_kiss::redis::aio::PubSub;
|
||||
use revolt_database::{events::client::EventV1, Database, User};
|
||||
use revolt_database::{events::client::EventV1, Database, User, AMQP};
|
||||
use revolt_models::v0;
|
||||
use rocket::local::asynchronous::Client;
|
||||
|
||||
@@ -13,13 +13,14 @@ pub struct TestHarness {
|
||||
pub client: Client,
|
||||
authifier: Authifier,
|
||||
pub db: Database,
|
||||
pub amqp: AMQP,
|
||||
sub: PubSub,
|
||||
event_buffer: Vec<(String, EventV1)>,
|
||||
}
|
||||
|
||||
impl TestHarness {
|
||||
pub async fn new() -> TestHarness {
|
||||
dotenv::dotenv().ok();
|
||||
let config = revolt_config::config().await;
|
||||
|
||||
let client = Client::tracked(crate::web().await)
|
||||
.await
|
||||
@@ -43,10 +44,25 @@ impl TestHarness {
|
||||
.expect("`Authifier`")
|
||||
.clone();
|
||||
|
||||
let connection = amqprs::connection::Connection::open(
|
||||
&amqprs::connection::OpenConnectionArguments::new(
|
||||
&config.rabbit.host,
|
||||
config.rabbit.port,
|
||||
&config.rabbit.username,
|
||||
&config.rabbit.password,
|
||||
),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
let channel = connection.open_channel(None).await.unwrap();
|
||||
|
||||
let amqp = AMQP::new(connection, channel);
|
||||
|
||||
TestHarness {
|
||||
client,
|
||||
authifier,
|
||||
db,
|
||||
amqp,
|
||||
sub,
|
||||
event_buffer: vec![],
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user