dev #25
@ -26,21 +26,27 @@ pub fn attach_user_application(
|
||||
let user_application =
|
||||
c.create_callback(move |q: OwnedJsObject| -> Result<_, ScriptError> {
|
||||
let bot1 = bot.clone();
|
||||
let bot1 = bot1.read().unwrap();
|
||||
let bot2 = bot.read().unwrap();
|
||||
let bot1 = bot1.read().expect("Can't read bot");
|
||||
let bot2 = bot.read().expect("Can't read bot");
|
||||
let user: teloxide::types::User = match from_js(q.context(), &q) {
|
||||
Ok(q) => q,
|
||||
Err(_) => todo!(),
|
||||
};
|
||||
|
||||
let application = futures::executor::block_on(
|
||||
Application::new(user.clone()).store_db(&mut db.write().unwrap()),
|
||||
Application::new(user.clone())
|
||||
.store_db(&mut db.write().expect("Can't write to db rwlock")),
|
||||
)?;
|
||||
|
||||
let db2 = db.clone();
|
||||
let msg = tokio::task::block_in_place(move || {
|
||||
Handle::current().block_on(async move {
|
||||
send_application_to_chat(&bot1, &mut db2.write().unwrap(), &application).await
|
||||
send_application_to_chat(
|
||||
&bot1,
|
||||
&mut db2.write().expect("Can't write to db rwlock"),
|
||||
&application,
|
||||
)
|
||||
.await
|
||||
})
|
||||
});
|
||||
let msg = match msg {
|
||||
@ -52,13 +58,13 @@ pub fn attach_user_application(
|
||||
};
|
||||
|
||||
let (chat_id, msg_id) = futures::executor::block_on(
|
||||
MessageAnswerer::new(&bot2, &mut db.write().unwrap(), user.id.0 as i64).answer(
|
||||
"left_application_msg",
|
||||
None,
|
||||
None,
|
||||
),
|
||||
)
|
||||
.unwrap();
|
||||
MessageAnswerer::new(
|
||||
&bot2,
|
||||
&mut db.write().expect("Can't write to db rwlock"),
|
||||
user.id.0 as i64,
|
||||
)
|
||||
.answer("left_application_msg", None, None),
|
||||
)?;
|
||||
futures::executor::block_on(
|
||||
MessageForward::new(msg.chat.id.0, msg.id.0, chat_id, msg_id, false)
|
||||
.store_db(&mut db.write().unwrap()),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user