mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-13 06:20:16 +02:00
Added a check to insure that during the api refresh the server is online for every user minimizes chances of database wipe
This commit is contained in:
parent
d1159d177a
commit
0fa2ceec48
@ -11,6 +11,7 @@ from eveonline.managers import EveManager
|
||||
from services.managers.eve_api_manager import EveApiManager
|
||||
from util.common_task import deactivate_services
|
||||
|
||||
|
||||
def update_jabber_groups(user):
|
||||
syncgroups = SyncGroupCache.objects.filter(user=user)
|
||||
authserviceinfo = AuthServicesInfo.objects.get(user=user)
|
||||
@ -123,7 +124,10 @@ def run_databaseUpdate():
|
||||
@periodic_task(run_every=crontab(minute=0, hour="*/3"))
|
||||
def run_api_refresh():
|
||||
users = User.objects.all()
|
||||
|
||||
for user in users:
|
||||
# Check if the api server is online
|
||||
if EveApiManager.check_if_api_server_online():
|
||||
api_key_pairs = EveManager.get_api_key_pairs(user.id)
|
||||
if api_key_pairs:
|
||||
valid_key = False
|
||||
|
@ -86,3 +86,15 @@ class EveApiManager():
|
||||
return False
|
||||
|
||||
return False
|
||||
|
||||
@staticmethod
|
||||
def check_if_api_server_online():
|
||||
try:
|
||||
api = evelink.api.API()
|
||||
server = evelink.server.Server(api=api)
|
||||
info = server.server_status()
|
||||
return True
|
||||
except evelink.api.APIError as error:
|
||||
return False
|
||||
|
||||
return False
|
Loading…
x
Reference in New Issue
Block a user