Restyle to work on most screen sizes

This commit is contained in:
jude
2023-09-17 18:03:57 +01:00
parent 5ee9094bac
commit 06165c1b36
5 changed files with 89 additions and 60 deletions

View File

@ -12,8 +12,7 @@ use sqlx::{MySql, Pool};
use crate::routes::{
dashboard::{
create_reminder, generate_uid, ImportBody, Reminder, ReminderCsv, ReminderTemplateCsv,
TodoCsv,
create_reminder, ImportBody, ReminderCreate, ReminderCsv, ReminderTemplateCsv, TodoCsv,
},
JsonResult,
};
@ -141,11 +140,11 @@ pub async fn import_reminders(
match channel_id.parse::<u64>() {
Ok(channel_id) => {
let reminder = Reminder {
let reminder = ReminderCreate {
attachment: record.attachment,
attachment_name: record.attachment_name,
avatar: record.avatar,
channel: Some(channel_id),
channel: channel_id,
content: record.content,
embed_author: record.embed_author,
embed_author_url: record.embed_author_url,
@ -168,12 +167,8 @@ pub async fn import_reminders(
name: record.name,
restartable: record.restartable,
tts: record.tts,
uid: generate_uid(),
username: record.username,
utc_time: record.utc_time,
status: "pending".to_string(),
status_change_time: None,
status_message: None,
};
create_reminder(

View File

@ -26,7 +26,7 @@ use crate::{
routes::{
dashboard::{
create_database_channel, create_reminder, template_name_default, DeleteReminder,
DeleteReminderTemplate, PatchReminder, Reminder, ReminderTemplate,
DeleteReminderTemplate, PatchReminder, Reminder, ReminderCreate, ReminderTemplate,
},
JsonResult,
},
@ -298,7 +298,7 @@ pub async fn delete_reminder_template(
#[post("/api/guild/<id>/reminders", data = "<reminder>")]
pub async fn create_guild_reminder(
id: u64,
reminder: Json<Reminder>,
reminder: Json<ReminderCreate>,
cookies: &CookieJar<'_>,
serenity_context: &State<Context>,
pool: &State<Pool<MySql>>,

View File

@ -118,6 +118,37 @@ pub struct EmbedField {
inline: bool,
}
#[derive(Deserialize)]
pub struct ReminderCreate {
#[serde(with = "base64s")]
attachment: Option<Vec<u8>>,
attachment_name: Option<String>,
avatar: Option<String>,
channel: u64,
content: String,
embed_author: String,
embed_author_url: Option<String>,
embed_color: u32,
embed_description: String,
embed_footer: String,
embed_footer_url: Option<String>,
embed_image_url: Option<String>,
embed_thumbnail_url: Option<String>,
embed_title: String,
embed_fields: Option<Json<Vec<EmbedField>>>,
enabled: bool,
expires: Option<NaiveDateTime>,
interval_seconds: Option<u32>,
interval_days: Option<u32>,
interval_months: Option<u32>,
#[serde(default = "name_default")]
name: String,
restartable: bool,
tts: bool,
username: Option<String>,
utc_time: NaiveDateTime,
}
#[derive(Serialize, Deserialize)]
pub struct Reminder {
#[serde(with = "base64s")]
@ -383,7 +414,7 @@ pub async fn create_reminder(
pool: impl sqlx::Executor<'_, Database = Database> + Copy,
guild_id: GuildId,
user_id: UserId,
reminder: Reminder,
reminder: ReminderCreate,
) -> JsonResult {
// check guild in db
match sqlx::query!("SELECT 1 as A FROM guilds WHERE guild = ?", guild_id.0)
@ -403,7 +434,7 @@ pub async fn create_reminder(
}
// validate channel
let channel = reminder.channel.map(|c| ChannelId(c).to_channel_cached(&ctx)).flatten();
let channel = ChannelId(reminder.channel).to_channel_cached(&ctx);
let channel_exists = channel.is_some();
let channel_matches_guild =
@ -418,7 +449,7 @@ pub async fn create_reminder(
return Err(json!({"error": "Channel not found"}));
}
let channel = create_database_channel(&ctx, ChannelId(reminder.channel.unwrap()), pool).await;
let channel = create_database_channel(&ctx, ChannelId(reminder.channel), pool).await;
if let Err(e) = channel {
warn!("`create_database_channel` returned an error code: {:?}", e);