Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CHANGE] Set user agent according to MDN guidelines #245

Merged
merged 1 commit into from
Dec 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ Section Order:
### Security
-->

### Changed

- Set user agent according to MDN guidelines

## [2.5.4] - 2024-12-14

### Added
Expand Down
18 changes: 12 additions & 6 deletions aasrp/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,24 @@
Constants
"""

# Third Party
from requests.__version__ import __version__ as requests_version

# Django
from django.utils.text import slugify
from django.utils.translation import gettext_lazy as _

# Alliance Auth
from esi import __version__ as esi_version

# AA SRP
from aasrp import __version__

VERBOSE_NAME = "AA-SRP - A ship replacement module for Alliance Auth"

verbose_name_slugified: str = slugify(value=VERBOSE_NAME, allow_unicode=True)
github_url: str = "https://github.com/ppfeufer/aa-srp"
USERAGENT = f"{verbose_name_slugified} v{__version__} {github_url}"
APP_NAME = "aa-srp"
GITHUB_URL = f"https://github.com/ppfeufer/{APP_NAME}"
USER_AGENT_ESI = f"{APP_NAME}/{__version__} +{GITHUB_URL} via django-esi/{esi_version}"
USER_AGENT_REQUESTS = (
f"{APP_NAME}/{__version__} +{GITHUB_URL} via requests/{requests_version}"
)


SRP_REQUEST_NOTIFICATION_INQUIRY_NOTE = _(
Expand Down
7 changes: 5 additions & 2 deletions aasrp/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

# AA SRP
from aasrp import __title__
from aasrp.constants import KILLBOARD_DATA, USERAGENT
from aasrp.constants import KILLBOARD_DATA, USER_AGENT_REQUESTS
from aasrp.providers import esi

logger = LoggerAddTag(get_extension_logger(__name__), __title__)
Expand Down Expand Up @@ -59,7 +59,10 @@

zkillboard_api_url = KILLBOARD_DATA["zKillboard"]["api_url"]
url = f"{zkillboard_api_url}killID/{kill_id}/"
headers = {"User-Agent": USERAGENT, "Content-Type": "application/json"}
headers = {

Check warning on line 62 in aasrp/managers.py

View check run for this annotation

Codecov / codecov/patch

aasrp/managers.py#L62

Added line #L62 was not covered by tests
"User-Agent": USER_AGENT_REQUESTS,
"Content-Type": "application/json",
}
request_result = requests.get(url=url, headers=headers, timeout=5)

try:
Expand Down
4 changes: 2 additions & 2 deletions aasrp/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from esi.clients import EsiClientProvider

# AA SRP
from aasrp.constants import USERAGENT
from aasrp.constants import USER_AGENT_ESI

# ESI client
esi = EsiClientProvider(app_info_text=USERAGENT)
esi = EsiClientProvider(app_info_text=USER_AGENT_ESI)
Loading