From a3d98f196c19dca8ada90c64b97e06c4b209318b Mon Sep 17 00:00:00 2001 From: web2brain Date: Thu, 4 Jan 2024 14:10:29 +0100 Subject: [PATCH 1/8] Add token auth to ntfy.py --- tgtg_scanner/notifiers/ntfy.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tgtg_scanner/notifiers/ntfy.py b/tgtg_scanner/notifiers/ntfy.py index c764acf8..f26ede59 100644 --- a/tgtg_scanner/notifiers/ntfy.py +++ b/tgtg_scanner/notifiers/ntfy.py @@ -27,6 +27,7 @@ def __init__(self, config: Config, reservations: Reservations, favorites: Favori self.click = config.ntfy.click self.username = config.ntfy.username self.password = config.ntfy.password + self.token = config.ntfy.token self.timeout = config.ntfy.timeout self.cron = config.ntfy.cron self.headers = dict() @@ -42,8 +43,13 @@ def __init__(self, config: Config, reservations: Reservations, favorites: Favori if self.username is not None and self.password is not None: self.auth = HTTPBasicAuth(self.username, self.password) log.debug("Using basic auth with user '%s' for Ntfy", self.username) - elif (self.username or self.password) is not None: - log.warning("Username or Password missing for Ntfy authentication, defaulting to no auth") + elif self.token is not None: + self.headers = { + "Authorization": "Bearer " + self.token, + } + log.debug("Using access token for Ntfy") + else: + log.warning("Username and Password or Access Token missing for Ntfy authentication, defaulting to no auth") try: Item.check_mask(self.title) Item.check_mask(self.message) @@ -59,7 +65,7 @@ def _send(self, item: Union[Item, Reservation]) -> None: message = item.unmask(self.message).encode("utf-8") tags = item.unmask(self.tags).encode("utf-8") click = item.unmask(self.click).encode("utf-8") - self.headers = { + self.headers |= { "X-Title": title, "X-Message": message, "X-Priority": self.priority, From 36db350509d47704f85b999f66aab211590f7ae9 Mon Sep 17 00:00:00 2001 From: web2brain Date: Thu, 4 Jan 2024 14:19:57 +0100 Subject: [PATCH 2/8] Add token to config.py --- tgtg_scanner/models/config.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tgtg_scanner/models/config.py b/tgtg_scanner/models/config.py index 5901e561..772969dd 100644 --- a/tgtg_scanner/models/config.py +++ b/tgtg_scanner/models/config.py @@ -322,6 +322,7 @@ class NtfyConfig(NotifierConfig): click: str = "${{link}}" username: Union[str, None] = None password: Union[str, None] = None + token: Union[str, None] = None timeout: int = 60 def _read_ini(self, parser: configparser.ConfigParser): @@ -337,6 +338,7 @@ def _read_ini(self, parser: configparser.ConfigParser): self._ini_get(parser, "NTFY", "Click", "click") self._ini_get(parser, "NTFY", "Username", "username") self._ini_get(parser, "NTFY", "Password", "password") + self._ini_get(parser, "NTFY", "Token", "token") self._ini_get_int(parser, "NTFY", "Timeout", "timeout") def _read_env(self): @@ -352,6 +354,7 @@ def _read_env(self): self._env_get("NTFY_CLICK", "click") self._env_get("NTFY_USERNAME", "username") self._env_get("NTFY_PASSWORD", "password") + self._env_get("NTFY_TOKEN", "token") self._env_get_int("NTFY_TIMEOUT", "timeout") From 4184471627755ef9e06b20b3362b20f3ce577c04 Mon Sep 17 00:00:00 2001 From: web2brain Date: Thu, 4 Jan 2024 14:21:35 +0100 Subject: [PATCH 3/8] Add token to config.sample.ini --- config.sample.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/config.sample.ini b/config.sample.ini index fc01ac33..a198a2f2 100644 --- a/config.sample.ini +++ b/config.sample.ini @@ -141,6 +141,7 @@ Topic = ; Click = https://share.toogoodtogo.com/item/${{item_id}} ; Username = ; Password = +; Token = ; Timeout = 60 ; Cron = From 25b913490c00e5c6a01fc74ecd5ad6c57bb84a1d Mon Sep 17 00:00:00 2001 From: web2brain Date: Thu, 4 Jan 2024 14:25:32 +0100 Subject: [PATCH 4/8] Add token to Configuration.md --- wiki/Configuration.md | 1 + 1 file changed, 1 insertion(+) diff --git a/wiki/Configuration.md b/wiki/Configuration.md index ab921dc6..ff6a2a9f 100644 --- a/wiki/Configuration.md +++ b/wiki/Configuration.md @@ -191,6 +191,7 @@ For details on the service URL configuration see Date: Sat, 6 Jan 2024 15:27:17 +0100 Subject: [PATCH 5/8] fix for version extraction from release tag --- .github/workflows/release.yml | 21 ++++++++++++++------- docker/DOCKER_README.md | 4 ++-- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a9c2b2bc..dff5e0ae 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -59,16 +59,23 @@ jobs: push: ${{ github.event_name == 'push' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + - name: Extract Major and Minor Version + if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') + run: | + TAG_NAME=${GITHUB_REF#refs/tags/} + echo "Full Tag: $TAG_NAME" + MAJOR=$(echo $TAG_NAME | cut -d. -f1) + MINOR=$(echo $TAG_NAME | cut -d. -f1,2) + echo "FULL_VERSION=$TAG_NAME" >> $GITHUB_ENV + echo "MAJOR_VERSION=$MAJOR" >> $GITHUB_ENV + echo "MINOR_VERSION=$MINOR" >> $GITHUB_ENV - uses: iamazeem/substitute-action@v1 - env: - VERSION: ${{ steps.meta.outputs.version }} - MAJOR: ${{ steps.meta.outputs.major }} - MINIOR: ${{ steps.meta.outputs.minor }} + if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') with: variables: | - VERSION - MAJOR - MINOR + FULL_VERSION + MAJOR_VERSION + MINOR_VERSION input-files: | ./docker/DOCKER_README.md - uses: peter-evans/dockerhub-description@v3 diff --git a/docker/DOCKER_README.md b/docker/DOCKER_README.md index 069fce9d..90e88c55 100644 --- a/docker/DOCKER_README.md +++ b/docker/DOCKER_README.md @@ -11,8 +11,8 @@ Readme, source, and documentation on [https://github.com/Der-Henning/tgtg](https - [`edge`](https://github.com/Der-Henning/tgtg/blob/main/docker/Dockerfile) - [`edge-alpine`](https://github.com/Der-Henning/tgtg/blob/main/docker/Dockerfile.alpine) -- [`${MAJOR}`, `${MINIOR}`, `${VERSION}`, `latest`](https://github.com/Der-Henning/tgtg/blob/${VERSION}/docker/Dockerfile) -- [`${MAJOR}-alpine`, `${MINIOR}-alpine`, `${VERSION}-alpine`, `latest-alpine`](https://github.com/Der-Henning/tgtg/blob/${VERSION}/docker/Dockerfile.alpine) +- [`${MAJOR_VERSION}`, `${MINIOR_VERSION}`, `${FULL_VERSION}`, `latest`](https://github.com/Der-Henning/tgtg/blob/${FULL_VERSION}/docker/Dockerfile) +- [`${MAJOR_VERSION}-alpine`, `${MINIOR_VERSION}-alpine`, `${FULL_VERSION}-alpine`, `latest-alpine`](https://github.com/Der-Henning/tgtg/blob/${FULL_VERSION}/docker/Dockerfile.alpine) # Quick Start From 3ca13e68f137e72ef46faec5987a8e8b5b4dbe50 Mon Sep 17 00:00:00 2001 From: Henning Merklinger Date: Tue, 9 Jan 2024 21:58:12 +0100 Subject: [PATCH 6/8] minor updates --- .devcontainer/devcontainer.json | 7 +++---- .github/pull_request_template.md | 8 +++----- poetry.lock | 24 ++++++++++++------------ pyproject.toml | 6 ------ tgtg_scanner/tgtg/tgtg_client.py | 6 +++--- 5 files changed, 21 insertions(+), 30 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 983a8aad..0a2f387b 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -23,9 +23,7 @@ "python.terminal.activateEnvironment": true, "python.terminal.activateEnvInCurrentTerminal": true, "editor.rulers": [130], - "python.testing.pytestArgs": [ - "tests" - ], + "python.testing.pytestArgs": ["tests"], "python.testing.unittestEnabled": false, "python.testing.pytestEnabled": true }, @@ -33,7 +31,8 @@ "extensions": [ "ms-python.python", "ms-toolsai.jupyter", - "GitHub.vscode-pull-request-github" + "GitHub.vscode-pull-request-github", + "ms-azuretools.vscode-docker" ] } }, diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 3b9b9899..84bbf583 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,14 +1,12 @@ ### Pull Request Checklist -* [ ] Have you checked to ensure there aren't other open -[Pull Requests](../../pulls) for the same update/change? +* [ ] Have you checked to ensure there aren't other open [Pull Requests](../../pulls) for the same update/change? * [ ] Did you make your Pull Request on the dev branch? * [ ] Does your submission pass tests? `make test` * [ ] Have you lint your code locally prior to submission? `make lint` -* [ ] Could you build and run the docker image successfully? `make image` +* [ ] Could you build and run the docker images successfully? `make images` * [ ] Could you create a running executable? `make executable` -* [ ] Have you added an explanation of what your changes do -and why you'd like to include them? +* [ ] Have you added an explanation of what your changes do and why you'd like to include them? * [ ] Have you written new tests for your changes, as applicable? * [ ] Have you successfully ran manual tests with your changes locally? diff --git a/poetry.lock b/poetry.lock index 8e679b36..59fe0f71 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1302,13 +1302,13 @@ test = ["coverage", "ipykernel (>=6.14)", "mypy", "paramiko", "pre-commit", "pyt [[package]] name = "jupyter-core" -version = "5.7.0" +version = "5.7.1" description = "Jupyter core package. A base package on which Jupyter projects rely." optional = false python-versions = ">=3.8" files = [ - {file = "jupyter_core-5.7.0-py3-none-any.whl", hash = "sha256:16eea462f7dad23ba9f86542bdf17f830804e2028eb48d609b6134d91681e983"}, - {file = "jupyter_core-5.7.0.tar.gz", hash = "sha256:cb8d3ed92144d2463a3c5664fdd686a3f0c1442ea45df8babb1c1a9e6333fe03"}, + {file = "jupyter_core-5.7.1-py3-none-any.whl", hash = "sha256:c65c82126453a723a2804aa52409930434598fd9d35091d63dfb919d2b765bb7"}, + {file = "jupyter_core-5.7.1.tar.gz", hash = "sha256:de61a9d7fc71240f688b2fb5ab659fbb56979458dc66a71decd098e03c79e218"}, ] [package.dependencies] @@ -1362,13 +1362,13 @@ jupyter-server = ">=1.1.2" [[package]] name = "jupyter-server" -version = "2.12.2" +version = "2.12.3" description = "The backend—i.e. core services, APIs, and REST endpoints—to Jupyter web applications." optional = false python-versions = ">=3.8" files = [ - {file = "jupyter_server-2.12.2-py3-none-any.whl", hash = "sha256:abcfa33f98a959f908c8733aa2d9fa0101d26941cbd49b148f4cef4d3046fc61"}, - {file = "jupyter_server-2.12.2.tar.gz", hash = "sha256:5eae86be15224b5375cdec0c3542ce72ff20f7a25297a2a8166a250bb455a519"}, + {file = "jupyter_server-2.12.3-py3-none-any.whl", hash = "sha256:6f85310ea5e6068568a521f079fba99d8d17e4884dd1d602ab0f43b3115204a8"}, + {file = "jupyter_server-2.12.3.tar.gz", hash = "sha256:a1d2d51e497b1a6256c48b6940b0dd49b2553981baf1690077c37792f1fa23a1"}, ] [package.dependencies] @@ -1635,13 +1635,13 @@ files = [ [[package]] name = "more-itertools" -version = "10.1.0" +version = "10.2.0" description = "More routines for operating on iterables, beyond itertools" optional = false python-versions = ">=3.8" files = [ - {file = "more-itertools-10.1.0.tar.gz", hash = "sha256:626c369fa0eb37bac0291bce8259b332fd59ac792fa5497b59837309cd5b114a"}, - {file = "more_itertools-10.1.0-py3-none-any.whl", hash = "sha256:64e0735fcfdc6f3464ea133afe8ea4483b1c5fe3a3d69852e6503b43a0b222e6"}, + {file = "more-itertools-10.2.0.tar.gz", hash = "sha256:8fccb480c43d3e99a00087634c06dd02b0d50fbf088b380de5a41a015ec239e1"}, + {file = "more_itertools-10.2.0-py3-none-any.whl", hash = "sha256:686b06abe565edfab151cb8fd385a05651e1fdf8f0a14191e4439283421f8684"}, ] [[package]] @@ -3126,13 +3126,13 @@ test = ["argcomplete (>=3.0.3)", "mypy (>=1.7.0)", "pre-commit", "pytest (>=7.0, [[package]] name = "trove-classifiers" -version = "2023.11.29" +version = "2024.1.8" description = "Canonical source for classifiers on PyPI (pypi.org)." optional = false python-versions = "*" files = [ - {file = "trove-classifiers-2023.11.29.tar.gz", hash = "sha256:ff8f7fd82c7932113b46e7ef6742c70091cc63640c8c65db00d91f2e940b9514"}, - {file = "trove_classifiers-2023.11.29-py3-none-any.whl", hash = "sha256:02307750cbbac2b3d13078662f8a5bf077732bf506e9c33c97204b7f68f3699e"}, + {file = "trove-classifiers-2024.1.8.tar.gz", hash = "sha256:6e36caf430ff6485c4b57a4c6b364a13f6a898d16b9417c6c37467e59c14b05a"}, + {file = "trove_classifiers-2024.1.8-py3-none-any.whl", hash = "sha256:3c1ff4deb10149c7e39ede6e5bbc107def64362ef1ee7590ec98d71fb92f1b6a"}, ] [[package]] diff --git a/pyproject.toml b/pyproject.toml index ced915d1..4c2eb2ca 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -49,12 +49,6 @@ scanner = "tgtg_scanner.__main__:main" tgtg_server = "tests.tgtg_server:main" [tool.pytest.ini_options] -addopts = [ - "--import-mode=importlib" -] markers = [ "tgtg_api: test directly calls the tgtg API (deselect with '-m \"not tgtg_api\"')" ] -pythonpath = [ - "." -] diff --git a/tgtg_scanner/tgtg/tgtg_client.py b/tgtg_scanner/tgtg/tgtg_client.py index 255f5a55..49692fc6 100644 --- a/tgtg_scanner/tgtg/tgtg_client.py +++ b/tgtg_scanner/tgtg/tgtg_client.py @@ -28,8 +28,8 @@ AUTH_POLLING_ENDPOINT = "auth/v3/authByRequestPollingId" SIGNUP_BY_EMAIL_ENDPOINT = "auth/v3/signUpByEmail" REFRESH_ENDPOINT = "auth/v3/token/refresh" -ACTIVE_ORDER_ENDPOINT = "order/v6/active" -INACTIVE_ORDER_ENDPOINT = "order/v6/inactive" +ACTIVE_ORDER_ENDPOINT = "order/v7/active" +INACTIVE_ORDER_ENDPOINT = "order/v7/inactive" CREATE_ORDER_ENDPOINT = "order/v7/create/" ABORT_ORDER_ENDPOINT = "order/v7/{}/abort" ORDER_STATUS_ENDPOINT = "order/v7/{}/status" @@ -112,7 +112,7 @@ def __init__( user_id=None, datadome_cookie=None, user_agent=None, - language="en-UK", + language="en-GB", proxies=None, timeout=None, access_token_lifetime=DEFAULT_ACCESS_TOKEN_LIFETIME, From 94f61dd413f7e3f66fe372017b33019fb5721600 Mon Sep 17 00:00:00 2001 From: Henning Merklinger Date: Sat, 13 Jan 2024 14:41:08 +0100 Subject: [PATCH 7/8] Bugfix for Warnings about telegram, although telegram is not enabled #444 --- pyproject.toml | 2 +- tgtg_scanner/notifiers/telegram.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 4c2eb2ca..55a1c553 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,7 @@ name = "tgtg-scanner" packages = [{include = "tgtg_scanner"}] readme = "README.md" repository = "https://github.com/Der-Henning/tgtg" -version = "1.18.0" +version = "1.18.1" [tool.poetry.dependencies] apprise = "^1.4.0" diff --git a/tgtg_scanner/notifiers/telegram.py b/tgtg_scanner/notifiers/telegram.py index 4fba4a00..6a37db9d 100644 --- a/tgtg_scanner/notifiers/telegram.py +++ b/tgtg_scanner/notifiers/telegram.py @@ -133,7 +133,7 @@ async def _stop_polling(self): await self.application.shutdown() def start(self) -> None: - if not self.chat_ids: + if self.enabled and not self.chat_ids: asyncio.run(self._get_chat_ids()) super().start() From 812e292378be3b09c4d668e8a01315f11dfec991 Mon Sep 17 00:00:00 2001 From: Henning Merklinger Date: Sat, 13 Jan 2024 14:42:47 +0100 Subject: [PATCH 8/8] bump version 1.19.0 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 55a1c553..56c78cb3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,7 @@ name = "tgtg-scanner" packages = [{include = "tgtg_scanner"}] readme = "README.md" repository = "https://github.com/Der-Henning/tgtg" -version = "1.18.1" +version = "1.19.0" [tool.poetry.dependencies] apprise = "^1.4.0"