Update web for daily intervals
This commit is contained in:
parent
9b87fd4258
commit
e9bcb1973f
8
Cargo.lock
generated
8
Cargo.lock
generated
@ -685,7 +685,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "a12e6657c4c97ebab115a42dcee77225f7f482cdd841cf7088c657a42e9e00e7"
|
checksum = "a12e6657c4c97ebab115a42dcee77225f7f482cdd841cf7088c657a42e9e00e7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"atty",
|
"atty",
|
||||||
"humantime 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"humantime",
|
||||||
"log",
|
"log",
|
||||||
"regex",
|
"regex",
|
||||||
"termcolor",
|
"termcolor",
|
||||||
@ -1069,11 +1069,6 @@ version = "2.1.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
|
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "humantime"
|
|
||||||
version = "2.1.0"
|
|
||||||
source = "git+https://github.com/reminder-bot/humantime#12ce6f50894a56a410b390e5608ac9db8afe2407"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hyper"
|
name = "hyper"
|
||||||
version = "0.14.23"
|
version = "0.14.23"
|
||||||
@ -2145,7 +2140,6 @@ dependencies = [
|
|||||||
"chrono-tz 0.8.1",
|
"chrono-tz 0.8.1",
|
||||||
"dotenv",
|
"dotenv",
|
||||||
"env_logger",
|
"env_logger",
|
||||||
"humantime 2.1.0 (git+https://github.com/reminder-bot/humantime)",
|
|
||||||
"lazy-regex",
|
"lazy-regex",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"levenshtein",
|
"levenshtein",
|
||||||
|
@ -75,7 +75,7 @@ impl Display for Ended {
|
|||||||
|
|
||||||
impl StdError for Ended {}
|
impl StdError for Ended {}
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main(flavor = "multi_thread")]
|
||||||
async fn main() -> Result<(), Box<dyn StdError + Send + Sync>> {
|
async fn main() -> Result<(), Box<dyn StdError + Send + Sync>> {
|
||||||
let (tx, mut rx) = broadcast::channel(16);
|
let (tx, mut rx) = broadcast::channel(16);
|
||||||
|
|
||||||
|
@ -58,6 +58,7 @@ pub async fn export_reminders(
|
|||||||
reminders.enabled,
|
reminders.enabled,
|
||||||
reminders.expires,
|
reminders.expires,
|
||||||
reminders.interval_seconds,
|
reminders.interval_seconds,
|
||||||
|
reminders.interval_days,
|
||||||
reminders.interval_months,
|
reminders.interval_months,
|
||||||
reminders.name,
|
reminders.name,
|
||||||
reminders.restartable,
|
reminders.restartable,
|
||||||
@ -159,6 +160,7 @@ pub async fn import_reminders(
|
|||||||
enabled: record.enabled,
|
enabled: record.enabled,
|
||||||
expires: record.expires,
|
expires: record.expires,
|
||||||
interval_seconds: record.interval_seconds,
|
interval_seconds: record.interval_seconds,
|
||||||
|
interval_days: record.interval_days,
|
||||||
interval_months: record.interval_months,
|
interval_months: record.interval_months,
|
||||||
name: record.name,
|
name: record.name,
|
||||||
restartable: record.restartable,
|
restartable: record.restartable,
|
||||||
|
@ -339,6 +339,7 @@ pub async fn get_reminders(id: u64, ctx: &State<Context>, pool: &State<Pool<MySq
|
|||||||
reminders.enabled,
|
reminders.enabled,
|
||||||
reminders.expires,
|
reminders.expires,
|
||||||
reminders.interval_seconds,
|
reminders.interval_seconds,
|
||||||
|
reminders.interval_days,
|
||||||
reminders.interval_months,
|
reminders.interval_months,
|
||||||
reminders.name,
|
reminders.name,
|
||||||
reminders.restartable,
|
reminders.restartable,
|
||||||
@ -395,6 +396,7 @@ pub async fn edit_reminder(
|
|||||||
enabled,
|
enabled,
|
||||||
expires,
|
expires,
|
||||||
interval_seconds,
|
interval_seconds,
|
||||||
|
interval_days,
|
||||||
interval_months,
|
interval_months,
|
||||||
name,
|
name,
|
||||||
restartable,
|
restartable,
|
||||||
@ -483,6 +485,7 @@ pub async fn edit_reminder(
|
|||||||
reminders.enabled,
|
reminders.enabled,
|
||||||
reminders.expires,
|
reminders.expires,
|
||||||
reminders.interval_seconds,
|
reminders.interval_seconds,
|
||||||
|
reminders.interval_days,
|
||||||
reminders.interval_months,
|
reminders.interval_months,
|
||||||
reminders.name,
|
reminders.name,
|
||||||
reminders.restartable,
|
reminders.restartable,
|
||||||
|
@ -132,6 +132,7 @@ pub struct Reminder {
|
|||||||
enabled: bool,
|
enabled: bool,
|
||||||
expires: Option<NaiveDateTime>,
|
expires: Option<NaiveDateTime>,
|
||||||
interval_seconds: Option<u32>,
|
interval_seconds: Option<u32>,
|
||||||
|
interval_days: Option<u32>,
|
||||||
interval_months: Option<u32>,
|
interval_months: Option<u32>,
|
||||||
#[serde(default = "name_default")]
|
#[serde(default = "name_default")]
|
||||||
name: String,
|
name: String,
|
||||||
@ -164,6 +165,7 @@ pub struct ReminderCsv {
|
|||||||
enabled: bool,
|
enabled: bool,
|
||||||
expires: Option<NaiveDateTime>,
|
expires: Option<NaiveDateTime>,
|
||||||
interval_seconds: Option<u32>,
|
interval_seconds: Option<u32>,
|
||||||
|
interval_days: Option<u32>,
|
||||||
interval_months: Option<u32>,
|
interval_months: Option<u32>,
|
||||||
#[serde(default = "name_default")]
|
#[serde(default = "name_default")]
|
||||||
name: String,
|
name: String,
|
||||||
@ -214,6 +216,8 @@ pub struct PatchReminder {
|
|||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
interval_seconds: Unset<Option<u32>>,
|
interval_seconds: Unset<Option<u32>>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
|
interval_days: Unset<Option<u32>>,
|
||||||
|
#[serde(default)]
|
||||||
interval_months: Unset<Option<u32>>,
|
interval_months: Unset<Option<u32>>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
name: Unset<String>,
|
name: Unset<String>,
|
||||||
@ -370,8 +374,12 @@ pub async fn create_reminder(
|
|||||||
if reminder.utc_time < Utc::now().naive_utc() {
|
if reminder.utc_time < Utc::now().naive_utc() {
|
||||||
return Err(json!({"error": "Time must be in the future"}));
|
return Err(json!({"error": "Time must be in the future"}));
|
||||||
}
|
}
|
||||||
if reminder.interval_seconds.is_some() || reminder.interval_months.is_some() {
|
if reminder.interval_seconds.is_some()
|
||||||
|
|| reminder.interval_days.is_some()
|
||||||
|
|| reminder.interval_months.is_some()
|
||||||
|
{
|
||||||
if reminder.interval_months.unwrap_or(0) * 30 * DAY as u32
|
if reminder.interval_months.unwrap_or(0) * 30 * DAY as u32
|
||||||
|
+ reminder.interval_days.unwrap_or(0) * DAY as u32
|
||||||
+ reminder.interval_seconds.unwrap_or(0)
|
+ reminder.interval_seconds.unwrap_or(0)
|
||||||
< *MIN_INTERVAL
|
< *MIN_INTERVAL
|
||||||
{
|
{
|
||||||
@ -380,7 +388,10 @@ pub async fn create_reminder(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check patreon if necessary
|
// check patreon if necessary
|
||||||
if reminder.interval_seconds.is_some() || reminder.interval_months.is_some() {
|
if reminder.interval_seconds.is_some()
|
||||||
|
|| reminder.interval_days.is_some()
|
||||||
|
|| reminder.interval_months.is_some()
|
||||||
|
{
|
||||||
if !check_guild_subscription(&ctx, guild_id).await
|
if !check_guild_subscription(&ctx, guild_id).await
|
||||||
&& !check_subscription(&ctx, user_id).await
|
&& !check_subscription(&ctx, user_id).await
|
||||||
{
|
{
|
||||||
@ -416,13 +427,14 @@ pub async fn create_reminder(
|
|||||||
enabled,
|
enabled,
|
||||||
expires,
|
expires,
|
||||||
interval_seconds,
|
interval_seconds,
|
||||||
|
interval_days,
|
||||||
interval_months,
|
interval_months,
|
||||||
name,
|
name,
|
||||||
restartable,
|
restartable,
|
||||||
tts,
|
tts,
|
||||||
username,
|
username,
|
||||||
`utc_time`
|
`utc_time`
|
||||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||||
new_uid,
|
new_uid,
|
||||||
attachment_data,
|
attachment_data,
|
||||||
reminder.attachment_name,
|
reminder.attachment_name,
|
||||||
@ -442,6 +454,7 @@ pub async fn create_reminder(
|
|||||||
reminder.enabled,
|
reminder.enabled,
|
||||||
reminder.expires,
|
reminder.expires,
|
||||||
reminder.interval_seconds,
|
reminder.interval_seconds,
|
||||||
|
reminder.interval_days,
|
||||||
reminder.interval_months,
|
reminder.interval_months,
|
||||||
name,
|
name,
|
||||||
reminder.restartable,
|
reminder.restartable,
|
||||||
@ -473,6 +486,7 @@ pub async fn create_reminder(
|
|||||||
reminders.enabled,
|
reminders.enabled,
|
||||||
reminders.expires,
|
reminders.expires,
|
||||||
reminders.interval_seconds,
|
reminders.interval_seconds,
|
||||||
|
reminders.interval_days,
|
||||||
reminders.interval_months,
|
reminders.interval_months,
|
||||||
reminders.name,
|
reminders.name,
|
||||||
reminders.restartable,
|
reminders.restartable,
|
||||||
|
@ -135,14 +135,14 @@ pub async fn discord_callback(
|
|||||||
Err(Flash::new(
|
Err(Flash::new(
|
||||||
Redirect::to(uri!(super::return_to_same_site(""))),
|
Redirect::to(uri!(super::return_to_same_site(""))),
|
||||||
"warning",
|
"warning",
|
||||||
"Your login request was rejected",
|
"Your login request was rejected. The server may be misconfigured. Please retry or alert us in Discord.",
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Err(Flash::new(Redirect::to(uri!(super::return_to_same_site(""))), "danger", "Your request failed to validate, and so has been rejected (error: CSRF Validation Failure)"))
|
Err(Flash::new(Redirect::to(uri!(super::return_to_same_site(""))), "danger", "Your request failed to validate, and so has been rejected (CSRF Validation Failure)"))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Err(Flash::new(Redirect::to(uri!(super::return_to_same_site(""))), "warning", "Your request was missing information, and so has been rejected (error: CSRF Validation Tokens Missing)"))
|
Err(Flash::new(Redirect::to(uri!(super::return_to_same_site(""))), "warning", "Your request was missing information, and so has been rejected (CSRF Validation Tokens Missing)"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,9 +7,9 @@ function get_interval(element) {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
months: parseInt(months) || null,
|
months: parseInt(months) || null,
|
||||||
|
days: parseInt(days) || null,
|
||||||
seconds:
|
seconds:
|
||||||
(parseInt(days) || 0) * 86400 +
|
(parseInt(hours) || 0) * 3600 +
|
||||||
(parseInt(hours) || 0) * 3600 +
|
|
||||||
(parseInt(minutes) || 0) * 60 +
|
(parseInt(minutes) || 0) * 60 +
|
||||||
(parseInt(seconds) || 0) || null,
|
(parseInt(seconds) || 0) || null,
|
||||||
};
|
};
|
||||||
@ -42,13 +42,6 @@ function update_interval(element) {
|
|||||||
minutes.value = String(remainder).padStart(2, "0");
|
minutes.value = String(remainder).padStart(2, "0");
|
||||||
hours.value = String(Number(hours.value) + Number(quotient)).padStart(2, "0");
|
hours.value = String(Number(hours.value) + Number(quotient)).padStart(2, "0");
|
||||||
}
|
}
|
||||||
if (hours.value >= 24) {
|
|
||||||
let quotient = Math.floor(hours.value / 24);
|
|
||||||
let remainder = hours.value % 24;
|
|
||||||
|
|
||||||
hours.value = String(remainder).padStart(2, "0");
|
|
||||||
days.value = Number(days.value) + Number(quotient);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const $intervalGroup = document.querySelector(".interval-group");
|
const $intervalGroup = document.querySelector(".interval-group");
|
||||||
|
@ -319,6 +319,7 @@ async function serialize_reminder(node, mode) {
|
|||||||
embed_fields: fields,
|
embed_fields: fields,
|
||||||
expires: expiration_time,
|
expires: expiration_time,
|
||||||
interval_seconds: mode !== "template" ? interval.seconds : null,
|
interval_seconds: mode !== "template" ? interval.seconds : null,
|
||||||
|
interval_days: mode !== "template" ? interval.days : null,
|
||||||
interval_months: mode !== "template" ? interval.months : null,
|
interval_months: mode !== "template" ? interval.months : null,
|
||||||
name: node.querySelector('input[name="name"]').value,
|
name: node.querySelector('input[name="name"]').value,
|
||||||
tts: node.querySelector('input[name="tts"]').checked,
|
tts: node.querySelector('input[name="tts"]').checked,
|
||||||
|
@ -49,7 +49,7 @@
|
|||||||
<p class="content">
|
<p class="content">
|
||||||
Monthly or yearly intervals are configured the same as fixed intervals. Instead of a fixed time
|
Monthly or yearly intervals are configured the same as fixed intervals. Instead of a fixed time
|
||||||
interval, these reminders repeat on a certain day each month or each year. This makes them ideal
|
interval, these reminders repeat on a certain day each month or each year. This makes them ideal
|
||||||
for marking certain dates.
|
for marking calendar events.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -61,7 +61,8 @@
|
|||||||
<p class="title">Interval expiration</p>
|
<p class="title">Interval expiration</p>
|
||||||
<p class="content">
|
<p class="content">
|
||||||
An expiration time can also be specified, both via commands and dashboard, for repeating reminders.
|
An expiration time can also be specified, both via commands and dashboard, for repeating reminders.
|
||||||
This is optional, and if omitted, the reminder will repeat indefinitely.
|
This is optional, and if omitted, the reminder will repeat indefinitely. Otherwise, the reminder
|
||||||
|
will be deleted once the expiration date is reached.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user