more stuff
This commit is contained in:
@@ -19,7 +19,7 @@ struct MigrationInfo {
|
||||
revision: i32,
|
||||
}
|
||||
|
||||
pub const LATEST_REVISION: i32 = 26;
|
||||
pub const LATEST_REVISION: i32 = 27;
|
||||
|
||||
pub async fn migrate_database(db: &MongoDb) {
|
||||
let migrations = db.col::<Document>("migrations");
|
||||
@@ -983,6 +983,24 @@ pub async fn run_migrations(db: &MongoDb, revision: i32) -> i32 {
|
||||
.expect("Failed to create ratelimit_events index.");
|
||||
}
|
||||
|
||||
if revision <= 26 {
|
||||
info!("Running migration [revision 26 / 17-04-2024]: Add `can_publish` and `can_receive` to members");
|
||||
|
||||
db.col::<Document>("server_members")
|
||||
.update_many(
|
||||
doc! {},
|
||||
doc! {
|
||||
"$set": {
|
||||
"can_publish": true,
|
||||
"can_receive": true
|
||||
}
|
||||
},
|
||||
None
|
||||
)
|
||||
.await
|
||||
.expect("Failed to update members");
|
||||
}
|
||||
|
||||
// Need to migrate fields on attachments, change `user_id`, `object_id`, etc to `parent`.
|
||||
|
||||
// Reminder to update LATEST_REVISION when adding new migrations.
|
||||
|
||||
@@ -3,8 +3,8 @@ use revolt_permissions::{calculate_channel_permissions, ChannelPermission};
|
||||
use revolt_result::{create_error, Result};
|
||||
|
||||
use crate::{
|
||||
events::client::EventV1, util::permissions::DatabasePermissionQuery, Channel, Database, File,
|
||||
Server, SystemMessage, User,
|
||||
events::client::EventV1, if_false, util::permissions::DatabasePermissionQuery, Channel,
|
||||
Database, File, Server, SystemMessage, User,
|
||||
};
|
||||
|
||||
auto_derived_partial!(
|
||||
@@ -30,6 +30,13 @@ auto_derived_partial!(
|
||||
/// Timestamp this member is timed out until
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub timeout: Option<Timestamp>,
|
||||
|
||||
/// Whether the member is server-wide voice muted
|
||||
#[serde(skip_serializing_if = "if_false")]
|
||||
pub can_publish: bool,
|
||||
/// Whether the member is server-wide voice deafened
|
||||
#[serde(skip_serializing_if = "if_false")]
|
||||
pub can_receive: bool,
|
||||
},
|
||||
"PartialMember"
|
||||
);
|
||||
@@ -69,6 +76,8 @@ impl Default for Member {
|
||||
avatar: None,
|
||||
roles: vec![],
|
||||
timeout: None,
|
||||
can_publish: false,
|
||||
can_receive: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ impl From<crate::Channel> for Channel {
|
||||
default_permissions,
|
||||
role_permissions,
|
||||
nsfw,
|
||||
voice
|
||||
voice,
|
||||
} => Channel::TextChannel {
|
||||
id,
|
||||
server,
|
||||
@@ -197,7 +197,7 @@ impl From<crate::Channel> for Channel {
|
||||
default_permissions,
|
||||
role_permissions,
|
||||
nsfw,
|
||||
voice
|
||||
voice,
|
||||
},
|
||||
crate::Channel::VoiceChannel {
|
||||
id,
|
||||
@@ -268,7 +268,7 @@ impl From<Channel> for crate::Channel {
|
||||
default_permissions,
|
||||
role_permissions,
|
||||
nsfw,
|
||||
voice
|
||||
voice,
|
||||
} => crate::Channel::TextChannel {
|
||||
id,
|
||||
server,
|
||||
@@ -279,7 +279,7 @@ impl From<Channel> for crate::Channel {
|
||||
default_permissions,
|
||||
role_permissions,
|
||||
nsfw,
|
||||
voice
|
||||
voice,
|
||||
},
|
||||
Channel::VoiceChannel {
|
||||
id,
|
||||
@@ -614,6 +614,8 @@ impl From<crate::Member> for Member {
|
||||
avatar: value.avatar.map(|f| f.into()),
|
||||
roles: value.roles,
|
||||
timeout: value.timeout,
|
||||
can_publish: value.can_publish,
|
||||
can_receive: value.can_receive,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -627,6 +629,8 @@ impl From<Member> for crate::Member {
|
||||
avatar: value.avatar.map(|f| f.into()),
|
||||
roles: value.roles,
|
||||
timeout: value.timeout,
|
||||
can_publish: value.can_publish,
|
||||
can_receive: value.can_receive,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -640,6 +644,8 @@ impl From<crate::PartialMember> for PartialMember {
|
||||
avatar: value.avatar.map(|f| f.into()),
|
||||
roles: value.roles,
|
||||
timeout: value.timeout,
|
||||
can_publish: value.can_publish,
|
||||
can_receive: value.can_receive,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -653,6 +659,8 @@ impl From<PartialMember> for crate::PartialMember {
|
||||
avatar: value.avatar.map(|f| f.into()),
|
||||
roles: value.roles,
|
||||
timeout: value.timeout,
|
||||
can_publish: value.can_publish,
|
||||
can_receive: value.can_receive,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user