Fix bot logon, should do nested match.
Add comment to migrations. Fix attachment deletes on messages.
This commit is contained in:
@@ -467,7 +467,7 @@ impl Message {
|
|||||||
let attachment_ids: Vec<String> =
|
let attachment_ids: Vec<String> =
|
||||||
attachments.iter().map(|f| f.id.to_string()).collect();
|
attachments.iter().map(|f| f.id.to_string()).collect();
|
||||||
get_collection("attachments")
|
get_collection("attachments")
|
||||||
.update_one(
|
.update_many(
|
||||||
doc! {
|
doc! {
|
||||||
"_id": {
|
"_id": {
|
||||||
"$in": attachment_ids
|
"$in": attachment_ids
|
||||||
@@ -482,7 +482,7 @@ impl Message {
|
|||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.map_err(|_| Error::DatabaseError {
|
.map_err(|_| Error::DatabaseError {
|
||||||
operation: "update_one",
|
operation: "update_many",
|
||||||
with: "attachment",
|
with: "attachment",
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -284,6 +284,8 @@ pub async fn run_migrations(revision: i32) -> i32 {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Need to migrate fields on attachments, change `user_id`, `object_id`, etc to `parent`.
|
||||||
|
|
||||||
// Reminder to update LATEST_REVISION when adding new migrations.
|
// Reminder to update LATEST_REVISION when adding new migrations.
|
||||||
LATEST_REVISION
|
LATEST_REVISION
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -169,23 +169,15 @@ async fn accept(stream: TcpStream) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let id = if let Ok(result) =
|
let id = if let Ok(Some(session)) =
|
||||||
Session::find_one(&get_db(), doc! { "token": &auth.token }, None).await
|
Session::find_one(&get_db(), doc! { "token": &auth.token }, None).await
|
||||||
{
|
{
|
||||||
if let Some(session) = result {
|
Some(session.user_id)
|
||||||
Some(session.user_id)
|
} else if let Ok(Some(bot)) = get_collection("bots")
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
} else if let Ok(result) = get_collection("bots")
|
|
||||||
.find_one(doc! { "token": auth.token }, None)
|
.find_one(doc! { "token": auth.token }, None)
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
if let Some(bot) = result {
|
Some(bot.get_str("_id").unwrap().to_string())
|
||||||
Some(bot.get_str("_id").unwrap().to_string())
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user