forked from jmug/stoatchat
@@ -33,8 +33,6 @@ pub enum Channel {
|
||||
Group {
|
||||
#[serde(rename = "_id")]
|
||||
id: String,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
nonce: Option<String>,
|
||||
|
||||
name: String,
|
||||
owner: String,
|
||||
@@ -57,8 +55,6 @@ pub enum Channel {
|
||||
#[serde(rename = "_id")]
|
||||
id: String,
|
||||
server: String,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
nonce: Option<String>,
|
||||
|
||||
name: String,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
@@ -81,8 +77,6 @@ pub enum Channel {
|
||||
#[serde(rename = "_id")]
|
||||
id: String,
|
||||
server: String,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
nonce: Option<String>,
|
||||
|
||||
name: String,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
|
||||
@@ -181,6 +181,20 @@ impl Message {
|
||||
}
|
||||
|
||||
pub async fn publish(self, channel: &Channel, process_embeds: bool) -> Result<()> {
|
||||
// construct message and publish
|
||||
// commit message to database
|
||||
|
||||
// spawn task_queue ( update last_message_id )
|
||||
// spawn task_queue ( process embeds )
|
||||
|
||||
// if mentions {
|
||||
// spawn task_queue ( update channel_unreads )
|
||||
// }
|
||||
|
||||
// if (channel => DM | Group) | mentions {
|
||||
// spawn task_queue ( web push )
|
||||
// }
|
||||
|
||||
get_collection("messages")
|
||||
.insert_one(to_bson(&self).unwrap().as_document().unwrap().clone(), None)
|
||||
.await
|
||||
|
||||
@@ -85,8 +85,6 @@ pub enum RemoveMember {
|
||||
pub struct Server {
|
||||
#[serde(rename = "_id")]
|
||||
pub id: String,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub nonce: Option<String>,
|
||||
pub owner: String,
|
||||
|
||||
pub name: String,
|
||||
|
||||
@@ -342,6 +342,36 @@ pub async fn run_migrations(revision: i32) -> i32 {
|
||||
}
|
||||
}
|
||||
|
||||
if revision <= 10 {
|
||||
info!("Running migration [revision 10 / 2021-11-01]: Remove nonce values on channels and servers.");
|
||||
|
||||
get_collection("servers")
|
||||
.update_many(
|
||||
doc! {},
|
||||
doc! {
|
||||
"$unset": {
|
||||
"nonce": 1,
|
||||
}
|
||||
},
|
||||
None
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
get_collection("channels")
|
||||
.update_many(
|
||||
doc! {},
|
||||
doc! {
|
||||
"$unset": {
|
||||
"nonce": 1,
|
||||
}
|
||||
},
|
||||
None
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
// Need to migrate fields on attachments, change `user_id`, `object_id`, etc to `parent`.
|
||||
|
||||
// Reminder to update LATEST_REVISION when adding new migrations.
|
||||
|
||||
Reference in New Issue
Block a user