mirror of
https://github.com/teloxide/teloxide.git
synced 2025-03-13 19:27:52 +01:00
Update sqlite dialog after all serializations
This commit is contained in:
parent
16b0b47ecf
commit
f8a00e64d8
1 changed files with 9 additions and 10 deletions
|
@ -105,9 +105,14 @@ where
|
|||
dialogue: D,
|
||||
) -> BoxFuture<'static, Result<Option<D>, Self::Error>> {
|
||||
Box::pin(async move {
|
||||
let serialized_dialogue =
|
||||
let prev_dialogue = match get_dialogue(&self.pool, chat_id).await? {
|
||||
Some(d) => {
|
||||
Some(self.serializer.deserialize(&d).map_err(SqliteStorageError::SerdeError)?)
|
||||
}
|
||||
None => None,
|
||||
};
|
||||
let upd_dialogue =
|
||||
self.serializer.serialize(&dialogue).map_err(SqliteStorageError::SerdeError)?;
|
||||
let prev_dialogue = get_dialogue(&self.pool, chat_id).await?;
|
||||
|
||||
self.pool
|
||||
.acquire()
|
||||
|
@ -120,16 +125,10 @@ where
|
|||
"#,
|
||||
)
|
||||
.bind(chat_id)
|
||||
.bind(serialized_dialogue),
|
||||
.bind(upd_dialogue),
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(match prev_dialogue {
|
||||
None => None,
|
||||
Some(d) => {
|
||||
Some(self.serializer.deserialize(&d).map_err(SqliteStorageError::SerdeError)?)
|
||||
}
|
||||
})
|
||||
Ok(prev_dialogue)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue