.....
This commit is contained in:
		@@ -1,12 +1,12 @@
 | 
			
		||||
[default]
 | 
			
		||||
address = "0.0.0.0"
 | 
			
		||||
address = "127.0.0.1"
 | 
			
		||||
port = 5000
 | 
			
		||||
template_dir = "web/templates"
 | 
			
		||||
 | 
			
		||||
[debug]
 | 
			
		||||
secret_key = "tR8krio5FXTnnyIZNiJDXPondz0kI1v6X6BXZcBGIRY="
 | 
			
		||||
 | 
			
		||||
[default.tls]
 | 
			
		||||
[debug.tls]
 | 
			
		||||
certs = "web/private/rsa_sha256_cert.pem"
 | 
			
		||||
key = "web/private/rsa_sha256_key.pem"
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										31
									
								
								migration/04-reminder_templates.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								migration/04-reminder_templates.sql
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,31 @@
 | 
			
		||||
USE reminders;
 | 
			
		||||
 | 
			
		||||
CREATE TABLE reminder_template (
 | 
			
		||||
    `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
 | 
			
		||||
 | 
			
		||||
    `name` VARCHAR(24) NOT NULL DEFAULT 'Reminder',
 | 
			
		||||
 | 
			
		||||
    `guild_id` INT UNSIGNED NOT NULL,
 | 
			
		||||
 | 
			
		||||
    `username` VARCHAR(32) DEFAULT NULL,
 | 
			
		||||
    `avatar` VARCHAR(512) DEFAULT NULL,
 | 
			
		||||
 | 
			
		||||
    `content` VARCHAR(2048) NOT NULL DEFAULT '',
 | 
			
		||||
    `tts` BOOL NOT NULL DEFAULT 0,
 | 
			
		||||
    `attachment` MEDIUMBLOB,
 | 
			
		||||
    `attachment_name` VARCHAR(260),
 | 
			
		||||
 | 
			
		||||
    `embed_title` VARCHAR(256) NOT NULL DEFAULT '',
 | 
			
		||||
    `embed_description` VARCHAR(2048) NOT NULL DEFAULT '',
 | 
			
		||||
    `embed_image_url` VARCHAR(512),
 | 
			
		||||
    `embed_thumbnail_url` VARCHAR(512),
 | 
			
		||||
    `embed_footer` VARCHAR(2048) NOT NULL DEFAULT '',
 | 
			
		||||
    `embed_footer_url` VARCHAR(512),
 | 
			
		||||
    `embed_author` VARCHAR(256) NOT NULL DEFAULT '',
 | 
			
		||||
    `embed_author_url` VARCHAR(512),
 | 
			
		||||
    `embed_color` INT UNSIGNED NOT NULL DEFAULT 0x0,
 | 
			
		||||
 | 
			
		||||
    PRIMARY KEY (id),
 | 
			
		||||
 | 
			
		||||
    FOREIGN KEY (`guild_id`) REFERENCES channels (`id`) ON DELETE CASCADE,
 | 
			
		||||
);
 | 
			
		||||
@@ -17,6 +17,7 @@ pub struct Reminder {
 | 
			
		||||
    attachment: Option<Vec<u8>>,
 | 
			
		||||
    attachment_name: Option<String>,
 | 
			
		||||
    avatar: Option<String>,
 | 
			
		||||
    #[serde(with = "string")]
 | 
			
		||||
    channel: u64,
 | 
			
		||||
    content: String,
 | 
			
		||||
    embed_author: String,
 | 
			
		||||
@@ -43,6 +44,31 @@ pub struct Reminder {
 | 
			
		||||
    utc_time: NaiveDateTime,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// https://github.com/serde-rs/json/issues/329#issuecomment-305608405
 | 
			
		||||
mod string {
 | 
			
		||||
    use std::fmt::Display;
 | 
			
		||||
    use std::str::FromStr;
 | 
			
		||||
 | 
			
		||||
    use serde::{de, Deserialize, Deserializer, Serializer};
 | 
			
		||||
 | 
			
		||||
    pub fn serialize<T, S>(value: &T, serializer: S) -> Result<S::Ok, S::Error>
 | 
			
		||||
    where
 | 
			
		||||
        T: Display,
 | 
			
		||||
        S: Serializer,
 | 
			
		||||
    {
 | 
			
		||||
        serializer.collect_str(value)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    pub fn deserialize<'de, T, D>(deserializer: D) -> Result<T, D::Error>
 | 
			
		||||
    where
 | 
			
		||||
        T: FromStr,
 | 
			
		||||
        T::Err: Display,
 | 
			
		||||
        D: Deserializer<'de>,
 | 
			
		||||
    {
 | 
			
		||||
        String::deserialize(deserializer)?.parse().map_err(de::Error::custom)
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#[derive(Deserialize)]
 | 
			
		||||
pub struct DeleteReminder {
 | 
			
		||||
    uid: String,
 | 
			
		||||
 
 | 
			
		||||
@@ -404,11 +404,16 @@
 | 
			
		||||
                    if (data.error) {
 | 
			
		||||
                        show_error(data.error);
 | 
			
		||||
                    } else {
 | 
			
		||||
                        const $template = document.querySelector('template#personalReminder');
 | 
			
		||||
                        console.log(data);
 | 
			
		||||
 | 
			
		||||
                        const $template = document.querySelector('template#guildReminder');
 | 
			
		||||
 | 
			
		||||
                        for (let reminder of data) {
 | 
			
		||||
                            let newFrame = $template.content.cloneNode(true);
 | 
			
		||||
 | 
			
		||||
                            // populate channels
 | 
			
		||||
                            newFrame.querySelector('select.channel-selector');
 | 
			
		||||
 | 
			
		||||
                            for (let prop in reminder) {
 | 
			
		||||
                                if (reminder.hasOwnProperty(prop) && reminder[prop] !== null) {
 | 
			
		||||
                                    let $input = newFrame.querySelector(`*[name="${prop}"]`);
 | 
			
		||||
@@ -642,11 +647,7 @@
 | 
			
		||||
                                        }
 | 
			
		||||
                                    });
 | 
			
		||||
 | 
			
		||||
                                fetch(`/dashboard/api/guild/${$anchor.dataset['guild']}/reminders`)
 | 
			
		||||
                                    .then(response => response.json())
 | 
			
		||||
                                    .then(data => {
 | 
			
		||||
 | 
			
		||||
                                    })
 | 
			
		||||
                                fetch_reminders($anchor.dataset['guild']);
 | 
			
		||||
 | 
			
		||||
                                document.querySelectorAll('p.pageTitle').forEach((el) => {
 | 
			
		||||
                                    el.textContent = $anchor.dataset['name'] + ' Reminders';
 | 
			
		||||
 
 | 
			
		||||
@@ -111,7 +111,7 @@
 | 
			
		||||
        <div class="field">
 | 
			
		||||
            <div class="control">
 | 
			
		||||
                <label class="label sr-only">Reminder Name</label>
 | 
			
		||||
                <input class="input" type="text" placeholder="Reminder Name">
 | 
			
		||||
                <input class="input" type="text" name="name" placeholder="Reminder Name">
 | 
			
		||||
            </div>
 | 
			
		||||
        </div>
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user