league logo upload repaired [fixes #25]
This commit is contained in:
parent
41b27f2cc4
commit
436d7b85ab
2 changed files with 10 additions and 12 deletions
|
|
@ -105,7 +105,7 @@ impl LeagueAppState {
|
|||
};
|
||||
|
||||
// setup lobby manager
|
||||
let lobby_mgr = match LobbyMgr::new(shutdown_control.clone(), &config) {
|
||||
let lobby_mgr = match LobbyMgr::new(shutdown_control.clone(), &config, league_logo_local.clone()) {
|
||||
Ok(lobby_mgr) => lobby_mgr,
|
||||
Err(e) => {
|
||||
log::error!("Failed to start lobby manager!");
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ use serde::Serialize;
|
|||
use sslo_lib::error::SsloError;
|
||||
use sslo_lib::parameters::DEFAULT_LOBBY_URL;
|
||||
use crate::app_state::AppState;
|
||||
use crate::app_state::league_logo::LeagueLogo;
|
||||
use crate::app_state::shutdown_control::{ShutdownControl, ShutdownStatus};
|
||||
|
||||
#[derive(Clone)]
|
||||
|
|
@ -14,7 +15,7 @@ pub struct LobbyMgr {
|
|||
}
|
||||
|
||||
impl LobbyMgr {
|
||||
pub fn new(sc: ShutdownControl, config: &crate::app_state::config::Config) -> Result<Self, SsloError> {
|
||||
pub fn new(sc: ShutdownControl, config: &crate::app_state::config::Config, league_logo: Option<LeagueLogo>) -> Result<Self, SsloError> {
|
||||
|
||||
// extract data
|
||||
let lobby_url = config.lobby.url.clone().unwrap_or_else(|| DEFAULT_LOBBY_URL.to_string());
|
||||
|
|
@ -26,7 +27,7 @@ impl LobbyMgr {
|
|||
let thread_handle = Arc::new(Mutex::new(Some( match thread::Builder::new()
|
||||
.name("Lobby Manager".to_owned())
|
||||
.spawn(move || {
|
||||
worker(sc, lobby_url, league_id, league_token, league_url, league_name)
|
||||
worker(sc, lobby_url, league_id, league_token, league_url, league_name, league_logo)
|
||||
}) {
|
||||
Ok(handle) => handle,
|
||||
Err(e) => {
|
||||
|
|
@ -61,6 +62,7 @@ fn worker(sc: ShutdownControl,
|
|||
league_token: String,
|
||||
league_url: String,
|
||||
league_name: String,
|
||||
league_logo: Option<LeagueLogo>,
|
||||
) {
|
||||
log::debug!("Starting lobby reporting");
|
||||
|
||||
|
|
@ -72,14 +74,9 @@ fn worker(sc: ShutdownControl,
|
|||
report_to_lobby(&lobby_url, league_id, &league_token, &league_url, &league_name, true);
|
||||
|
||||
// upload league logo
|
||||
log::error!("Uploading league Logo not implemented, yet [refs #25]!");
|
||||
// if let Some(league_logo) = app_state.substate().league_logo_local() {
|
||||
// upload_league_logo(&app_state.substate().lobby_url(),
|
||||
// app_state.substate().config.lobby.report_league_id,
|
||||
// app_state.substate().config.lobby.report_league_token.clone(),
|
||||
// league_logo.path_ref(),
|
||||
// );
|
||||
// }
|
||||
if let Some(league_logo) = league_logo {
|
||||
upload_league_logo(&lobby_url, league_id, &league_token, league_logo.path_ref());
|
||||
}
|
||||
|
||||
|
||||
// report every minute current state
|
||||
|
|
@ -161,10 +158,11 @@ fn report_to_lobby(
|
|||
fn upload_league_logo(
|
||||
lobby_url: &str,
|
||||
league_id: i64,
|
||||
league_token: String,
|
||||
league_token: &str,
|
||||
league_logo: &Path,
|
||||
) {
|
||||
let api_url = format!("{}/api/v0/league/{}/logo", lobby_url, league_id);
|
||||
let league_token = league_token.to_string();
|
||||
|
||||
// let part_file = match reqwest::blocking::multipart::Part::file(league_logo) {
|
||||
// Ok(part_file) => part_file,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue