Commit 99fe647b95

99fe647b95e31ce0e101020217de6b0b345ed0c5

parent: 1272f4576c

Unsigned

Darafei Praliaskouski <me@komzpa.net> · 2026-07-10 14:27 UTC
committer: <strk@kbt.io>

fix: run moderation requests asynchronously

Layout: unified · split

src/commands/moderation.rs +15 −14
@@ -111,8 +111,8 @@ impl ModerationCommand {
111 let room = room.room().clone(); 111 let room = room.room().clone();
112 let action = self.action; 112 let action = self.action;
113 let error_user_id = user_id.clone(); 113 let error_user_id = user_id.clone();
114 let result = self.servers.runtime().block_on(async move { 114 Weechat::spawn(async move {
115 match action { 115 let result = match action {
116 ModerationAction::Ban => { 116 ModerationAction::Ban => {
117 room.ban_user(&user_id, reason.as_deref()).await 117 room.ban_user(&user_id, reason.as_deref()).await
118 } 118 }
@@ -122,19 +122,20 @@ impl ModerationCommand {
122 ModerationAction::Unban => { 122 ModerationAction::Unban => {
123 room.unban_user(&user_id, reason.as_deref()).await 123 room.unban_user(&user_id, reason.as_deref()).await
124 } 124 }
125 };
126
127 if let Err(error) = result {
128 Weechat::print(&format!(
129 "{}{}: Failed to {} {}: {}",
130 Weechat::prefix(Prefix::Error),
131 PLUGIN_NAME,
132 action.verb(),
133 error_user_id,
134 error
135 ));
125 } 136 }
126 }); 137 })
127 138 .detach();
128 if let Err(error) = result {
129 Weechat::print(&format!(
130 "{}{}: Failed to {} {}: {}",
131 Weechat::prefix(Prefix::Error),
132 PLUGIN_NAME,
133 self.action.verb(),
134 error_user_id,
135 error
136 ));
137 }
138 } 139 }
139} 140}
140 141