Skip to content

Commit

Permalink
Merge pull request #445 from Der-Henning/dev
Browse files Browse the repository at this point in the history
Bump Version 1.19.0
  • Loading branch information
Der-Henning authored Jan 13, 2024
2 parents 0273785 + 812e292 commit a791fc4
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 44 deletions.
7 changes: 3 additions & 4 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,16 @@
"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
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-python.python",
"ms-toolsai.jupyter",
"GitHub.vscode-pull-request-github"
"GitHub.vscode-pull-request-github",
"ms-azuretools.vscode-docker"
]
}
},
Expand Down
8 changes: 3 additions & 5 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
<!-- markdownlint-disable-next-line MD041 -->
### 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?
21 changes: 14 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions config.sample.ini
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ Topic =
; Click = https://share.toogoodtogo.com/item/${{item_id}}
; Username =
; Password =
; Token =
; Timeout = 60
; Cron =

Expand Down
4 changes: 2 additions & 2 deletions docker/DOCKER_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

<!-- markdownlint-disable-next-line MD025 -->
# Quick Start
Expand Down
24 changes: 12 additions & 12 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 1 addition & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.19.0"

[tool.poetry.dependencies]
apprise = "^1.4.0"
Expand Down Expand Up @@ -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 = [
"."
]
3 changes: 3 additions & 0 deletions tgtg_scanner/models/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand All @@ -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")


Expand Down
12 changes: 9 additions & 3 deletions tgtg_scanner/notifiers/ntfy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion tgtg_scanner/notifiers/telegram.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
6 changes: 3 additions & 3 deletions tgtg_scanner/tgtg/tgtg_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions wiki/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ For details on the service URL configuration see <https://github.com/caronc/appr
| Click | NTFY_CLICK | URL to open on click | `${{link}}` | | YES |
| Username | NTFY_USERNAME | auth username |
| Password | NTFY_PASSWORD | auth password |
| Token | NTFY_TOKEN | auth token, only used if username and password are empty |
| Timeout | NTFY_TIMEOUT | timeout for Ntfy requests | 60 |
| Cron | NTFY_CRON | enable notification only on schedule | `* * * * *` |

Expand Down

0 comments on commit a791fc4

Please sign in to comment.