diff --git a/CHANGELOG.md b/CHANGELOG.md index 16091fa7..bc31a004 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,12 @@ #Changelog +* 1.3.1 + * Fixes + * fixed for possible race contition between checking if a character exists in db and creating it + * Fixed spelling anonymous as anonymouse in crossorigin + * Fix not beeing able to login with a transfered character + * Changes + * Not logging monolith errors to the error log anymore only to debug, these are expected + * Not logging fleet invite errors that are caused by a monolith error at all anymore * 1.3.0 * Fixes * Ban for character banned users did not work when esi was not responding diff --git a/static/js/themes/themes.js b/static/js/themes/themes.js index 0e8e51f7..1490b3fc 100644 --- a/static/js/themes/themes.js +++ b/static/js/themes/themes.js @@ -13,7 +13,7 @@ waitlist.themes = (function() { 'def_type': 'remote', 'def_file': 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css', 'def_integrity': "sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ", - 'def_crossorigin': "anonymouse" + 'def_crossorigin': "anonymous" }; // file_name = null == standard file function setTheme(file_name, type, integrity, crossorigin) { diff --git a/templates/base.html b/templates/base.html index 949821d0..ea80d65c 100644 --- a/templates/base.html +++ b/templates/base.html @@ -24,7 +24,7 @@ 'def_type': 'remote', 'def_file': 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css', 'def_integrity': "sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ", - 'def_crossorigin': "anonymouse" + 'def_crossorigin': "anonymous" }; // file_name = null == standard file function setTheme(file_name, type, integrity, crossorigin) { @@ -294,7 +294,7 @@ + data-crossorigin="anonymous">Generic diff --git a/templates/settings/base.html b/templates/settings/base.html index 0dbba843..31879f0d 100644 --- a/templates/settings/base.html +++ b/templates/settings/base.html @@ -39,7 +39,7 @@ + data-crossorigin="anonymous">Generic {% endblock %} diff --git a/waitlist/blueprints/api/fleet.py b/waitlist/blueprints/api/fleet.py index fe062f21..a5b54c34 100644 --- a/waitlist/blueprints/api/fleet.py +++ b/waitlist/blueprints/api/fleet.py @@ -99,7 +99,9 @@ def invite_to_fleet(): resp.status_code = status['status_code'] if resp.status_code != 204: # invite failed send no notifications - logger.error("Invited %s by %s into %s failed", character.eve_name, current_user.username, squad_type) + if resp.status_code != 520: + logger.error("Invited %s by %s into %s failed", + character.eve_name, current_user.username, squad_type) return resp send_notification(character_id, waitlist_id) diff --git a/waitlist/data/version.py b/waitlist/data/version.py index ad589ede..eac23a84 100644 --- a/waitlist/data/version.py +++ b/waitlist/data/version.py @@ -1 +1 @@ -version = "1.2.3-$Format:%h$" +version = "1.3.1-$Format:%h$" diff --git a/waitlist/utility/eve_id_utils.py b/waitlist/utility/eve_id_utils.py index 378b97b0..f19aafd7 100644 --- a/waitlist/utility/eve_id_utils.py +++ b/waitlist/utility/eve_id_utils.py @@ -11,9 +11,15 @@ from waitlist.utility.swagger import get_api from waitlist.utility.swagger.eve import get_esi_client from waitlist.utility.swagger.eve.search import SearchEndpoint, SearchResponse +from threading import Lock logger = logging.getLogger(__name__) +""" +Lock for checking existance of a character and creating it +""" +character_check_lock: Lock = Lock() + def get_constellation(name: str) -> Constellation: return db.session.query(Constellation).filter(Constellation.constellationName == name).first() @@ -81,7 +87,7 @@ def get_account_from_db(int_id: int) -> Account: # load a character by its id def get_char_from_db(int_id: int) -> Character: - return db.session.query(Character).filter(Character.id == int_id).first() + return db.session.query(Character).get(int_id) def create_new_character(eve_id: int, char_name: str) -> Character: @@ -95,23 +101,25 @@ def create_new_character(eve_id: int, char_name: str) -> Character: def get_character_by_id_and_name(eve_id: int, eve_name: str) -> Character: - char = get_char_from_db(eve_id) - if char is None: - logger.info("No character found for id %d", eve_id) - # create a new char - char = create_new_character(eve_id, eve_name) + with character_check_lock: + char = get_char_from_db(eve_id) + if char is None: + logger.info("No character found for id %d", eve_id) + # create a new char + char = create_new_character(eve_id, eve_name) - return char + return char def get_character_by_id(eve_character_id: int) -> Character: - character: Character = get_char_from_db(eve_character_id) - if character is None: - logger.info("No character found in database for id %d", eve_character_id) - char_info = outgate.character.get_info(eve_character_id) - character = create_new_character(eve_character_id, char_info.characterName) - - return character + with character_check_lock: + character: Character = get_char_from_db(eve_character_id) + if character is None: + logger.info("No character found in database for id %d", eve_character_id) + char_info = outgate.character.get_info(eve_character_id) + character = create_new_character(eve_character_id, char_info.characterName) + + return character def is_charid_banned(character_id: int) -> bool: diff --git a/waitlist/utility/login/__init__.py b/waitlist/utility/login/__init__.py index 526f1880..3f3382d3 100644 --- a/waitlist/utility/login/__init__.py +++ b/waitlist/utility/login/__init__.py @@ -62,7 +62,7 @@ def login_character(char: Character, owner_hash: str, token: SSOToken) -> Respon # if the hash is there but different the owner changed we need to invalidate sessions and update elif char.owner_hash != owner_hash: char.owner_hash = owner_hash - invalidate_all_sessions_for_current_user() + invalidate_all_sessions_for_given_user(char) db.session.commit() tokens = char.get_sso_tokens_with_scopes(['publicData']) diff --git a/waitlist/utility/swagger/eve/__init__.py b/waitlist/utility/swagger/eve/__init__.py index 62b15178..71a0a1c1 100644 --- a/waitlist/utility/swagger/eve/__init__.py +++ b/waitlist/utility/swagger/eve/__init__.py @@ -77,9 +77,11 @@ def make_error_response(resp: Any) -> ESIResponse: msg = resp.data['error'] else: msg = f'Unknown Monolith error {resp.data}' + + logger.debug('ESI responded with status Monolith 520 and msg %s', msg) else: msg = resp.data['error'] if resp.data is not None and 'error' in resp.data else 'No error data send' - logger.error(f'ESI responded with status {resp.status} and msg {msg}') + logger.error('ESI responded with status %s and msg %s', resp.status, msg) return ESIResponse(get_expire_time(resp), resp.status, msg)