Skip to content

Commit

Permalink
fix: continue fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Zomatree committed May 15, 2024
1 parent 471e0f5 commit 878c1a8
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use crate::{
options::FindOptions,
}, Invite, MongoDb, DISCRIMINATOR_SEARCH_SPACE
};
use bson::oid::ObjectId;
use futures::StreamExt;
use rand::seq::SliceRandom;
use revolt_permissions::DEFAULT_WEBHOOK_PERMISSIONS;
Expand Down Expand Up @@ -1003,16 +1004,23 @@ pub async fn run_migrations(db: &MongoDb, revision: i32) -> i32 {
}
);

#[derive(serde::Serialize, serde::Deserialize)]
struct Outer {
_id: ObjectId,
#[serde(flatten)]
invite: OldInvite
}

let mut invites = db.db()
.collection::<OldInvite>("channel_invites")
.collection::<Outer>("channel_invites")
.find(doc! {
"type": { "$exists": false }
}, None)
.await
.expect("failed to find invites");

while let Some(Ok(invite)) = invites.next().await {
let new_invite = match invite {
let new_invite = match invite.invite {
OldInvite::Server { code, server, creator, channel } => Invite::Server { code, server, creator, channel },
OldInvite::Group { code, creator, channel } => Invite::Group { code, creator, channel }
};
Expand Down

0 comments on commit 878c1a8

Please sign in to comment.