unify user-agents

This commit is contained in:
Joel Falknau 2024-10-21 12:46:23 +10:00
parent 42ee06470c
commit d89639e873
No known key found for this signature in database
5 changed files with 22 additions and 8 deletions

View File

@ -8,10 +8,13 @@ from esi.errors import TokenError
from esi.models import Token
from allianceauth.eveonline.models import EveCorporationInfo, EveCharacter, EveAllianceInfo
from allianceauth.notifications import notify
from allianceauth import __version__
from esi import __version__ as esi__version__
from allianceauth.corputils.managers import CorpStatsManager
SWAGGER_SPEC_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'swagger.json')
APP_INFO_TEXT = f"allianceauth/{__version__} django-esi/{esi__version__}"
"""
Swagger spec operations:
@ -47,7 +50,7 @@ class CorpStats(models.Model):
def update(self):
try:
c = self.token.get_esi_client(spec_file=SWAGGER_SPEC_PATH)
c = self.token.get_esi_client(spec_file=SWAGGER_SPEC_PATH, app_info_text=APP_INFO_TEXT)
assert c.Character.get_characters_character_id(character_id=self.token.character_id).result()['corporation_id'] == int(self.corp.corporation_id)
member_ids = c.Corporation.get_corporations_corporation_id_members(
corporation_id=self.corp.corporation_id).result()

View File

@ -9,10 +9,14 @@ from django.shortcuts import render, redirect, get_object_or_404
from django.utils.translation import gettext_lazy as _
from esi.decorators import token_required
from allianceauth.eveonline.models import EveCharacter, EveCorporationInfo
from allianceauth import __version__
from esi import __version__ as esi__version__
from .models import CorpStats, CorpMember
SWAGGER_SPEC_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'swagger.json')
APP_INFO_TEXT = f"allianceauth/{__version__} django-esi/{esi__version__}"
"""
Swagger spec operations:
@ -36,7 +40,7 @@ def corpstats_add(request, token):
corp_id = EveCharacter.objects.get(character_id=token.character_id).corporation_id
else:
corp_id = \
token.get_esi_client(spec_file=SWAGGER_SPEC_PATH).Character.get_characters_character_id(
token.get_esi_client(spec_file=SWAGGER_SPEC_PATH, app_info_text=APP_INFO_TEXT).Character.get_characters_character_id(
character_id=token.character_id).result()['corporation_id']
try:
corp = EveCorporationInfo.objects.get(corporation_id=corp_id)

View File

@ -8,8 +8,10 @@ from django.conf import settings
from esi.clients import esi_client_factory
from allianceauth import __version__
from esi import __version__ as esi__version__
from allianceauth.utils.django import StartupCommand
APP_INFO_TEXT = f"allianceauth.eveonline/{__version__} allianceauth/{__version__} django-esi/{esi__version__}"
SWAGGER_SPEC_PATH = os.path.join(os.path.dirname(
os.path.abspath(__file__)), 'swagger.json'
@ -185,7 +187,7 @@ class EveSwaggerProvider(EveProvider):
self._client = esi_client_factory(
token=token,
spec_file=SWAGGER_SPEC_PATH,
app_info_text=f"allianceauth v{__version__}"
app_info_text=APP_INFO_TEXT
)
except (HTTPError, RefResolutionError):
logger.exception(
@ -202,7 +204,7 @@ class EveSwaggerProvider(EveProvider):
def client(self):
if self._client is None:
self._client = esi_client_factory(
token=self._token, spec_file=SWAGGER_SPEC_PATH, app_info_text=("allianceauth v" + __version__)
token=self._token, spec_file=SWAGGER_SPEC_PATH, app_info_text=APP_INFO_TEXT
)
return self._client

View File

@ -16,12 +16,16 @@ from allianceauth.eveonline.providers import provider
from .forms import FatlinkForm
from .models import Fatlink, Fat
from django.utils.crypto import get_random_string
from allianceauth import __version__
from esi import __version__ as esi__version__
from allianceauth.eveonline.models import EveAllianceInfo
from allianceauth.eveonline.models import EveCharacter
from allianceauth.eveonline.models import EveCorporationInfo
SWAGGER_SPEC_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'swagger.json')
APP_INFO_TEXT = f"allianceauth/{__version__} django-esi/{esi__version__}"
"""
Swagger spec operations:
@ -256,7 +260,7 @@ def fatlink_monthly_personal_statistics_view(request, year, month, char_id=None)
]
)
def click_fatlink_view(request, token, fat_hash=None):
c = token.get_esi_client(spec_file=SWAGGER_SPEC_PATH)
c = token.get_esi_client(spec_file=SWAGGER_SPEC_PATH, app_info_text=APP_INFO_TEXT)
character = EveCharacter.objects.get_character_by_id(token.character_id)
character_online = c.Location.get_characters_character_id_online(
character_id=token.character_id

View File

@ -2,9 +2,10 @@ import os
from esi.clients import EsiClientProvider
from allianceauth import __version__
from esi import __version__ as esi__version__
SWAGGER_SPEC = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'swagger.json')
APP_INFO_TEXT = f"allianceauth/{__version__} django-esi/{esi__version__}"
"""
Swagger spec operations:
get_killmails_killmail_id_killmail_hash
@ -14,5 +15,5 @@ get_universe_types_type_id
esi = EsiClientProvider(
spec_file=SWAGGER_SPEC,
app_info_text=("allianceauth v" + __version__)
app_info_text=APP_INFO_TEXT
)