Update schemas and resolve some warnings
This commit is contained in:
parent
54ee3594eb
commit
3dd2bb8d95
4
Cargo.lock
generated
4
Cargo.lock
generated
@ -2645,9 +2645,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rocket_dyn_templates"
|
||||
version = "0.1.0"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "04bfc006e547e4f72b760ab861f5943b688aed8a82c4977b5500c98f5d17dbfa"
|
||||
checksum = "5bbab919c9e67df3f7ac6624a32ef897df4cd61c0969f4d66f3ced0534660d7a"
|
||||
dependencies = [
|
||||
"normpath",
|
||||
"notify",
|
||||
|
@ -30,7 +30,7 @@ secrecy = "0.8.0"
|
||||
futures = "0.3.30"
|
||||
prometheus = "0.13.3"
|
||||
rocket = { version = "0.5.0", features = ["tls", "secrets", "json"] }
|
||||
rocket_dyn_templates = { version = "0.1.0", features = ["tera"] }
|
||||
rocket_dyn_templates = { version = "0.2.0", features = ["tera"] }
|
||||
serenity = { version = "0.12", default-features = false, features = ["builder", "cache", "client", "gateway", "http", "model", "utils", "rustls_backend"] }
|
||||
oauth2 = "4"
|
||||
csv = "1.2"
|
||||
|
@ -136,9 +136,9 @@ CREATE TABLE reminders (
|
||||
set_by INT UNSIGNED,
|
||||
|
||||
PRIMARY KEY (id),
|
||||
FOREIGN KEY (message_id) REFERENCES messages(id) ON DELETE RESTRICT,
|
||||
FOREIGN KEY (channel_id) REFERENCES channels(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (set_by) REFERENCES users(id) ON DELETE SET NULL
|
||||
CONSTRAINT `reminder_message_fk` FOREIGN KEY (message_id) REFERENCES messages(id) ON DELETE RESTRICT,
|
||||
CONSTRAINT `reminder_channel_fk` FOREIGN KEY (channel_id) REFERENCES channels(id) ON DELETE CASCADE,
|
||||
CONSTRAINT `reminder_user_fk` FOREIGN KEY (set_by) REFERENCES users(id) ON DELETE SET NULL
|
||||
);
|
||||
|
||||
CREATE TRIGGER message_cleanup AFTER DELETE ON reminders
|
||||
@ -157,9 +157,9 @@ CREATE TABLE todos (
|
||||
value VARCHAR(2000) NOT NULL,
|
||||
|
||||
PRIMARY KEY (id),
|
||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE SET NULL,
|
||||
FOREIGN KEY (guild_id) REFERENCES guilds(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (channel_id) REFERENCES channels(id) ON DELETE SET NULL
|
||||
CONSTRAINT todos_ibfk_5 FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE SET NULL,
|
||||
CONSTRAINT todos_ibfk_4 FOREIGN KEY (guild_id) REFERENCES guilds(id) ON DELETE CASCADE,
|
||||
CONSTRAINT todos_ibfk_3 FOREIGN KEY (channel_id) REFERENCES channels(id) ON DELETE SET NULL
|
||||
);
|
||||
|
||||
CREATE TABLE command_restrictions (
|
||||
|
@ -46,7 +46,7 @@ CREATE TABLE reminders_new (
|
||||
PRIMARY KEY (id),
|
||||
|
||||
FOREIGN KEY (`channel_id`) REFERENCES channels (`id`) ON DELETE CASCADE,
|
||||
FOREIGN KEY (`set_by`) REFERENCES users (`id`) ON DELETE SET NULL
|
||||
CONSTRAINT `reminders_ibfk_2` FOREIGN KEY (`set_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
|
||||
|
||||
# disallow having a reminder as restartable if it has no interval
|
||||
-- , CONSTRAINT restartable_interval_mutex CHECK (`restartable` = 0 OR `interval` IS NULL)
|
||||
|
@ -1,3 +1,7 @@
|
||||
-- Tables no longer needed as old dashboard is decomm.
|
||||
DROP TABLE guild_users;
|
||||
DROP TABLE events;
|
||||
|
||||
ALTER TABLE users ADD COLUMN `reset_inputs_on_create` BOOLEAN NOT NULL DEFAULT 0;
|
||||
ALTER TABLE users ADD COLUMN `use_browser_timezone` BOOLEAN NOT NULL DEFAULT 1;
|
||||
ALTER TABLE users ADD COLUMN `dashboard_color_scheme` ENUM('system', 'light', 'dark') NOT NULL DEFAULT 'system';
|
||||
@ -7,4 +11,14 @@ ALTER TABLE users DROP COLUMN `patreon`;
|
||||
ALTER TABLE users DROP COLUMN `name`;
|
||||
|
||||
ALTER TABLE users DROP PRIMARY KEY, ADD PRIMARY KEY (`user`);
|
||||
|
||||
ALTER TABLE todos DROP CONSTRAINT todos_ibfk_5, MODIFY COLUMN user_id BIGINT UNSIGNED;
|
||||
UPDATE todos SET user_id = (SELECT user FROM users WHERE id = user_id);
|
||||
ALTER TABLE todos ADD CONSTRAINT todos_user_fk FOREIGN KEY (user_id) REFERENCES users(user);
|
||||
|
||||
ALTER TABLE reminders DROP CONSTRAINT reminders_ibfk_2, MODIFY COLUMN set_by BIGINT UNSIGNED;
|
||||
UPDATE reminders SET set_by = (SELECT user FROM users WHERE id = set_by);
|
||||
ALTER TABLE reminders ADD CONSTRAINT reminder_user_fk FOREIGN KEY (set_by) REFERENCES users(user);
|
||||
|
||||
ALTER TABLE users DROP COLUMN `id`;
|
||||
ALTER TABLE users RENAME COLUMN `user` TO `id`;
|
||||
|
@ -1,6 +1,6 @@
|
||||
use poise::{
|
||||
serenity_prelude as serenity,
|
||||
serenity_prelude::{ActivityData, CreateEmbed, CreateMessage, FullEvent},
|
||||
serenity_prelude::{CreateEmbed, CreateMessage, FullEvent},
|
||||
};
|
||||
|
||||
use crate::{
|
||||
|
@ -1,4 +1,4 @@
|
||||
use poise::{serenity_prelude::model::channel::Channel, CommandInteractionType, CreateReply};
|
||||
use poise::{CommandInteractionType, CreateReply};
|
||||
|
||||
use crate::{consts::MACRO_MAX_COMMANDS, models::command_macro::RecordedCommand, Context, Error};
|
||||
|
||||
|
@ -16,17 +16,15 @@ pub async fn get_guild_roles(id: u64, cookies: &CookieJar<'_>, ctx: &State<Conte
|
||||
offline!(Ok(json!(vec![RoleInfo { name: "@everyone".to_string(), id: "1".to_string() }])));
|
||||
check_authorization(cookies, ctx.inner(), id).await?;
|
||||
|
||||
let roles_res = ctx.cache.guild_roles(id);
|
||||
|
||||
match roles_res {
|
||||
Some(roles) => {
|
||||
let roles = roles
|
||||
let roles_res = ctx.cache.guild(id).map(|g| {
|
||||
g.roles
|
||||
.iter()
|
||||
.map(|(_, r)| RoleInfo { id: r.id.to_string(), name: r.name.to_string() })
|
||||
.collect::<Vec<RoleInfo>>();
|
||||
.collect::<Vec<RoleInfo>>()
|
||||
});
|
||||
|
||||
Ok(json!(roles))
|
||||
}
|
||||
match roles_res {
|
||||
Some(roles) => Ok(json!(roles)),
|
||||
None => {
|
||||
warn!("Could not fetch roles from {}", id);
|
||||
|
||||
|
@ -137,7 +137,7 @@ pub async fn update_user_info(
|
||||
}
|
||||
|
||||
if let Some(dashboard_color_scheme) = &preferences.dashboard_color_scheme {
|
||||
if vec!["system", "light", "dark"].contains(dashboard_color_scheme) {
|
||||
if vec!["system", "light", "dark"].contains(&dashboard_color_scheme.as_str()) {
|
||||
let _ = sqlx::query!(
|
||||
"
|
||||
UPDATE users
|
||||
|
@ -593,18 +593,11 @@ pub(crate) async fn create_reminder(
|
||||
}
|
||||
|
||||
fn check_channel_matches_guild(ctx: &Context, channel_id: ChannelId, guild_id: GuildId) -> bool {
|
||||
// validate channel
|
||||
let channel = channel_id.to_channel_cached(&ctx.cache);
|
||||
let channel_exists = channel.is_some();
|
||||
return match ctx.cache.guild(guild_id) {
|
||||
Some(guild) => guild.channels.get(&channel_id).is_some(),
|
||||
|
||||
if !channel_exists {
|
||||
return false;
|
||||
}
|
||||
|
||||
let channel_matches_guild =
|
||||
channel.map_or(false, |c| c.guild(&ctx.cache).map_or(false, |g| g.id == guild_id));
|
||||
|
||||
channel_matches_guild
|
||||
None => false,
|
||||
};
|
||||
}
|
||||
|
||||
async fn create_database_channel(
|
||||
|
Loading…
Reference in New Issue
Block a user