Fix some iso timestamps being strings, not DateTime<Utc> (#499)
* fix: some iso timestamps being strings * fix: register uses dates, not datetimes
This commit is contained in:
parent
d4377c5280
commit
eb087938ed
|
@ -160,10 +160,10 @@ pub struct PermissionOverwrite {
|
||||||
pub struct ThreadMetadata {
|
pub struct ThreadMetadata {
|
||||||
pub archived: bool,
|
pub archived: bool,
|
||||||
pub auto_archive_duration: i32,
|
pub auto_archive_duration: i32,
|
||||||
pub archive_timestamp: String,
|
pub archive_timestamp: DateTime<Utc>,
|
||||||
pub locked: bool,
|
pub locked: bool,
|
||||||
pub invitable: Option<bool>,
|
pub invitable: Option<bool>,
|
||||||
pub create_timestamp: Option<String>,
|
pub create_timestamp: Option<DateTime<Utc>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, Debug, Deserialize, Serialize, Clone)]
|
#[derive(Default, Debug, Deserialize, Serialize, Clone)]
|
||||||
|
@ -172,7 +172,7 @@ pub struct ThreadMetadata {
|
||||||
pub struct ThreadMember {
|
pub struct ThreadMember {
|
||||||
pub id: Option<Snowflake>,
|
pub id: Option<Snowflake>,
|
||||||
pub user_id: Option<Snowflake>,
|
pub user_id: Option<Snowflake>,
|
||||||
pub join_timestamp: Option<String>,
|
pub join_timestamp: Option<DateTime<Utc>>,
|
||||||
pub flags: Option<u64>,
|
pub flags: Option<u64>,
|
||||||
pub member: Option<Shared<GuildMember>>,
|
pub member: Option<Shared<GuildMember>>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ pub struct Guild {
|
||||||
#[cfg_attr(feature = "sqlx", sqlx(skip))]
|
#[cfg_attr(feature = "sqlx", sqlx(skip))]
|
||||||
pub invites: Option<Vec<GuildInvite>>,
|
pub invites: Option<Vec<GuildInvite>>,
|
||||||
#[cfg_attr(feature = "sqlx", sqlx(skip))]
|
#[cfg_attr(feature = "sqlx", sqlx(skip))]
|
||||||
pub joined_at: Option<String>,
|
pub joined_at: Option<DateTime<Utc>>,
|
||||||
pub large: Option<bool>,
|
pub large: Option<bool>,
|
||||||
pub max_members: Option<i32>,
|
pub max_members: Option<i32>,
|
||||||
pub max_presences: Option<i32>,
|
pub max_presences: Option<i32>,
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
use chrono::{DateTime, Utc};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::types::Shared;
|
use crate::types::Shared;
|
||||||
|
@ -17,12 +18,12 @@ pub struct GuildMember {
|
||||||
pub nick: Option<String>,
|
pub nick: Option<String>,
|
||||||
pub avatar: Option<String>,
|
pub avatar: Option<String>,
|
||||||
pub roles: Vec<Snowflake>,
|
pub roles: Vec<Snowflake>,
|
||||||
pub joined_at: String,
|
pub joined_at: DateTime<Utc>,
|
||||||
pub premium_since: Option<String>,
|
pub premium_since: Option<DateTime<Utc>>,
|
||||||
pub deaf: bool,
|
pub deaf: bool,
|
||||||
pub mute: bool,
|
pub mute: bool,
|
||||||
pub flags: Option<i32>,
|
pub flags: Option<i32>,
|
||||||
pub pending: Option<bool>,
|
pub pending: Option<bool>,
|
||||||
pub permissions: Option<String>,
|
pub permissions: Option<String>,
|
||||||
pub communication_disabled_until: Option<String>,
|
pub communication_disabled_until: Option<DateTime<Utc>>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
use chrono::{DateTime, Utc};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::types::{
|
use crate::types::{
|
||||||
|
@ -25,8 +26,8 @@ pub struct Message {
|
||||||
#[cfg_attr(feature = "sqlx", sqlx(skip))]
|
#[cfg_attr(feature = "sqlx", sqlx(skip))]
|
||||||
pub author: Option<PublicUser>,
|
pub author: Option<PublicUser>,
|
||||||
pub content: Option<String>,
|
pub content: Option<String>,
|
||||||
pub timestamp: String,
|
pub timestamp: DateTime<Utc>,
|
||||||
pub edited_timestamp: Option<String>,
|
pub edited_timestamp: Option<DateTime<Utc>>,
|
||||||
pub tts: Option<bool>,
|
pub tts: Option<bool>,
|
||||||
pub mention_everyone: bool,
|
pub mention_everyone: bool,
|
||||||
#[cfg_attr(feature = "sqlx", sqlx(skip))]
|
#[cfg_attr(feature = "sqlx", sqlx(skip))]
|
||||||
|
|
|
@ -96,7 +96,7 @@ pub struct ChannelUnreadUpdate {
|
||||||
pub struct ChannelUnreadUpdateObject {
|
pub struct ChannelUnreadUpdateObject {
|
||||||
pub id: Snowflake,
|
pub id: Snowflake,
|
||||||
pub last_message_id: Snowflake,
|
pub last_message_id: Snowflake,
|
||||||
pub last_pin_timestamp: Option<String>,
|
pub last_pin_timestamp: Option<DateTime<Utc>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Default, Deserialize, Serialize, Clone, JsonField, SourceUrlField, WebSocketEvent)]
|
#[derive(Debug, Default, Deserialize, Serialize, Clone, JsonField, SourceUrlField, WebSocketEvent)]
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
use chrono::NaiveDate;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||||
|
@ -13,7 +14,8 @@ pub struct RegisterSchema {
|
||||||
pub email: Option<String>,
|
pub email: Option<String>,
|
||||||
pub fingerprint: Option<String>,
|
pub fingerprint: Option<String>,
|
||||||
pub invite: Option<String>,
|
pub invite: Option<String>,
|
||||||
pub date_of_birth: Option<String>,
|
/// The user's date of birth, serialized as an ISO8601 date
|
||||||
|
pub date_of_birth: Option<NaiveDate>,
|
||||||
pub gift_code_sku_id: Option<String>,
|
pub gift_code_sku_id: Option<String>,
|
||||||
pub captcha_key: Option<String>,
|
pub captcha_key: Option<String>,
|
||||||
pub promotional_email_opt_in: Option<bool>,
|
pub promotional_email_opt_in: Option<bool>,
|
||||||
|
|
|
@ -2,12 +2,16 @@
|
||||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
use std::str::FromStr;
|
||||||
|
|
||||||
use chorus::types::{LoginSchema, RegisterSchema};
|
use chorus::types::{LoginSchema, RegisterSchema};
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_arch = "wasm32")]
|
||||||
use wasm_bindgen_test::*;
|
use wasm_bindgen_test::*;
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_arch = "wasm32")]
|
||||||
wasm_bindgen_test_configure!(run_in_browser);
|
wasm_bindgen_test_configure!(run_in_browser);
|
||||||
|
|
||||||
|
use chrono::NaiveDate;
|
||||||
|
|
||||||
mod common;
|
mod common;
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
||||||
|
@ -16,7 +20,7 @@ async fn test_registration() {
|
||||||
let mut bundle = common::setup().await;
|
let mut bundle = common::setup().await;
|
||||||
let reg = RegisterSchema {
|
let reg = RegisterSchema {
|
||||||
username: "Hiiii".into(),
|
username: "Hiiii".into(),
|
||||||
date_of_birth: Some("2000-01-01".to_string()),
|
date_of_birth: Some(NaiveDate::from_str("2000-01-01").unwrap()),
|
||||||
consent: true,
|
consent: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
@ -32,7 +36,7 @@ async fn test_login() {
|
||||||
username: "Hiiii".into(),
|
username: "Hiiii".into(),
|
||||||
email: Some("testuser1@integrationtesting.xyz".into()),
|
email: Some("testuser1@integrationtesting.xyz".into()),
|
||||||
password: Some("Correct-Horse-Battery-Staple1".into()),
|
password: Some("Correct-Horse-Battery-Staple1".into()),
|
||||||
date_of_birth: Some("2000-01-01".to_string()),
|
date_of_birth: Some(NaiveDate::from_str("2000-01-01").unwrap()),
|
||||||
consent: true,
|
consent: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
@ -54,7 +58,7 @@ async fn test_wrong_login() {
|
||||||
username: "Hiiii".into(),
|
username: "Hiiii".into(),
|
||||||
email: Some("testuser2@integrationtesting.xyz".into()),
|
email: Some("testuser2@integrationtesting.xyz".into()),
|
||||||
password: Some("Correct-Horse-Battery-Staple1".into()),
|
password: Some("Correct-Horse-Battery-Staple1".into()),
|
||||||
date_of_birth: Some("2000-01-01".to_string()),
|
date_of_birth: Some(NaiveDate::from_str("2000-01-01").unwrap()),
|
||||||
consent: true,
|
consent: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
use std::str::FromStr;
|
||||||
|
|
||||||
use chorus::gateway::Gateway;
|
use chorus::gateway::Gateway;
|
||||||
use chorus::types::IntoShared;
|
use chorus::types::IntoShared;
|
||||||
use chorus::{
|
use chorus::{
|
||||||
|
@ -13,6 +15,8 @@ use chorus::{
|
||||||
UrlBundle,
|
UrlBundle,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use chrono::NaiveDate;
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub(crate) struct TestBundle {
|
pub(crate) struct TestBundle {
|
||||||
|
@ -30,7 +34,7 @@ impl TestBundle {
|
||||||
let register_schema = RegisterSchema {
|
let register_schema = RegisterSchema {
|
||||||
username: username.to_string(),
|
username: username.to_string(),
|
||||||
consent: true,
|
consent: true,
|
||||||
date_of_birth: Some("2000-01-01".to_string()),
|
date_of_birth: Some(NaiveDate::from_str("2000-01-01").unwrap()),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
self.instance
|
self.instance
|
||||||
|
@ -60,7 +64,7 @@ pub(crate) async fn setup() -> TestBundle {
|
||||||
let reg = RegisterSchema {
|
let reg = RegisterSchema {
|
||||||
username: "integrationtestuser".into(),
|
username: "integrationtestuser".into(),
|
||||||
consent: true,
|
consent: true,
|
||||||
date_of_birth: Some("2000-01-01".to_string()),
|
date_of_birth: Some(NaiveDate::from_str("2000-01-01").unwrap()),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
let guild_create_schema = GuildCreateSchema {
|
let guild_create_schema = GuildCreateSchema {
|
||||||
|
|
Loading…
Reference in New Issue