fix(core/models): use IndexMap for reactions
This commit is contained in:
@@ -341,11 +341,7 @@ impl From<crate::Message> for Message {
|
|||||||
embeds: value.embeds,
|
embeds: value.embeds,
|
||||||
mentions: value.mentions,
|
mentions: value.mentions,
|
||||||
replies: value.replies,
|
replies: value.replies,
|
||||||
reactions: value
|
reactions: value.reactions,
|
||||||
.reactions
|
|
||||||
.into_iter()
|
|
||||||
.map(|(k, v)| (k, v.into_iter().collect()))
|
|
||||||
.collect(),
|
|
||||||
interactions: value.interactions.into(),
|
interactions: value.interactions.into(),
|
||||||
masquerade: value.masquerade.map(|masq| masq.into()),
|
masquerade: value.masquerade.map(|masq| masq.into()),
|
||||||
}
|
}
|
||||||
@@ -369,12 +365,7 @@ impl From<crate::PartialMessage> for PartialMessage {
|
|||||||
embeds: value.embeds,
|
embeds: value.embeds,
|
||||||
mentions: value.mentions,
|
mentions: value.mentions,
|
||||||
replies: value.replies,
|
replies: value.replies,
|
||||||
reactions: value.reactions.map(|reactions| {
|
reactions: value.reactions,
|
||||||
reactions
|
|
||||||
.into_iter()
|
|
||||||
.map(|(k, v)| (k, v.into_iter().collect()))
|
|
||||||
.collect()
|
|
||||||
}),
|
|
||||||
interactions: value.interactions.map(|interactions| interactions.into()),
|
interactions: value.interactions.map(|interactions| interactions.into()),
|
||||||
masquerade: value.masquerade.map(|masq| masq.into()),
|
masquerade: value.masquerade.map(|masq| masq.into()),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ serde = { version = "1", features = ["derive"], optional = true }
|
|||||||
iso8601-timestamp = { version = "0.2.11", features = ["schema", "bson"] }
|
iso8601-timestamp = { version = "0.2.11", features = ["schema", "bson"] }
|
||||||
|
|
||||||
# Spec Generation
|
# Spec Generation
|
||||||
schemars = { version = "0.8.8", optional = true }
|
schemars = { version = "0.8.8", optional = true, features = ["indexmap1"] }
|
||||||
|
|
||||||
# Validation
|
# Validation
|
||||||
validator = { version = "0.16.0", optional = true, features = ["derive"] }
|
validator = { version = "0.16.0", optional = true, features = ["derive"] }
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
use std::{
|
use std::time::SystemTime;
|
||||||
collections::{HashMap, HashSet},
|
|
||||||
time::SystemTime,
|
|
||||||
};
|
|
||||||
|
|
||||||
|
use indexmap::{IndexMap, IndexSet};
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use revolt_config::config;
|
use revolt_config::config;
|
||||||
@@ -55,8 +53,8 @@ auto_derived_partial!(
|
|||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub replies: Option<Vec<String>>,
|
pub replies: Option<Vec<String>>,
|
||||||
/// Hashmap of emoji IDs to array of user IDs
|
/// Hashmap of emoji IDs to array of user IDs
|
||||||
#[serde(skip_serializing_if = "HashMap::is_empty", default)]
|
#[serde(skip_serializing_if = "IndexMap::is_empty", default)]
|
||||||
pub reactions: HashMap<String, HashSet<String>>,
|
pub reactions: IndexMap<String, IndexSet<String>>,
|
||||||
/// Information about how this message should be interacted with
|
/// Information about how this message should be interacted with
|
||||||
#[serde(skip_serializing_if = "Interactions::is_default", default)]
|
#[serde(skip_serializing_if = "Interactions::is_default", default)]
|
||||||
pub interactions: Interactions,
|
pub interactions: Interactions,
|
||||||
@@ -119,7 +117,7 @@ auto_derived!(
|
|||||||
pub struct Interactions {
|
pub struct Interactions {
|
||||||
/// Reactions which should always appear and be distinct
|
/// Reactions which should always appear and be distinct
|
||||||
#[serde(skip_serializing_if = "Option::is_none", default)]
|
#[serde(skip_serializing_if = "Option::is_none", default)]
|
||||||
pub reactions: Option<HashSet<String>>,
|
pub reactions: Option<IndexSet<String>>,
|
||||||
/// Whether reactions should be restricted to the given list
|
/// Whether reactions should be restricted to the given list
|
||||||
///
|
///
|
||||||
/// Can only be set to true if reactions list is of at least length 1
|
/// Can only be set to true if reactions list is of at least length 1
|
||||||
|
|||||||
Reference in New Issue
Block a user