Add status update time to sender
This commit is contained in:
@ -124,8 +124,8 @@ pub struct Reminder {
|
||||
attachment: Option<Vec<u8>>,
|
||||
attachment_name: Option<String>,
|
||||
avatar: Option<String>,
|
||||
#[serde(with = "string")]
|
||||
channel: u64,
|
||||
#[serde(with = "string_opt")]
|
||||
channel: Option<u64>,
|
||||
content: String,
|
||||
embed_author: String,
|
||||
embed_author_url: Option<String>,
|
||||
@ -310,6 +310,34 @@ mod string {
|
||||
}
|
||||
}
|
||||
|
||||
mod string_opt {
|
||||
use std::{fmt::Display, str::FromStr};
|
||||
|
||||
use serde::{de, Deserialize, Deserializer, Serializer};
|
||||
|
||||
pub fn serialize<T, S>(value: &Option<T>, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
T: Display,
|
||||
S: Serializer,
|
||||
{
|
||||
match value {
|
||||
Some(value) => serializer.collect_str(value),
|
||||
None => serializer.serialize_none(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn deserialize<'de, T, D>(deserializer: D) -> Result<Option<T>, D::Error>
|
||||
where
|
||||
T: FromStr,
|
||||
T::Err: Display,
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
Option::deserialize(deserializer)?
|
||||
.map(|d: String| d.parse().map_err(de::Error::custom))
|
||||
.transpose()
|
||||
}
|
||||
}
|
||||
|
||||
mod base64s {
|
||||
use serde::{de, Deserialize, Deserializer, Serializer};
|
||||
|
||||
@ -374,7 +402,7 @@ pub async fn create_reminder(
|
||||
}
|
||||
|
||||
// validate channel
|
||||
let channel = ChannelId(reminder.channel).to_channel_cached(&ctx);
|
||||
let channel = reminder.channel.map(|c| ChannelId(c).to_channel_cached(&ctx)).flatten();
|
||||
let channel_exists = channel.is_some();
|
||||
|
||||
let channel_matches_guild =
|
||||
@ -382,14 +410,14 @@ pub async fn create_reminder(
|
||||
|
||||
if !channel_matches_guild || !channel_exists {
|
||||
warn!(
|
||||
"Error in `create_reminder`: channel {} not found for guild {} (channel exists: {})",
|
||||
"Error in `create_reminder`: channel {:?} not found for guild {} (channel exists: {})",
|
||||
reminder.channel, guild_id, channel_exists
|
||||
);
|
||||
|
||||
return Err(json!({"error": "Channel not found"}));
|
||||
}
|
||||
|
||||
let channel = create_database_channel(&ctx, ChannelId(reminder.channel), pool).await;
|
||||
let channel = create_database_channel(&ctx, ChannelId(reminder.channel.unwrap()), pool).await;
|
||||
|
||||
if let Err(e) = channel {
|
||||
warn!("`create_database_channel` returned an error code: {:?}", e);
|
||||
|
Reference in New Issue
Block a user