Skip to content

Commit a791fc4

Browse files
authored
Merge pull request #445 from Der-Henning/dev
Bump Version 1.19.0
2 parents 0273785 + 812e292 commit a791fc4

File tree

12 files changed

+53
-44
lines changed

12 files changed

+53
-44
lines changed

.devcontainer/devcontainer.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,16 @@
2323
"python.terminal.activateEnvironment": true,
2424
"python.terminal.activateEnvInCurrentTerminal": true,
2525
"editor.rulers": [130],
26-
"python.testing.pytestArgs": [
27-
"tests"
28-
],
26+
"python.testing.pytestArgs": ["tests"],
2927
"python.testing.unittestEnabled": false,
3028
"python.testing.pytestEnabled": true
3129
},
3230
// Add the IDs of extensions you want installed when the container is created.
3331
"extensions": [
3432
"ms-python.python",
3533
"ms-toolsai.jupyter",
36-
"GitHub.vscode-pull-request-github"
34+
"GitHub.vscode-pull-request-github",
35+
"ms-azuretools.vscode-docker"
3736
]
3837
}
3938
},

.github/pull_request_template.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
<!-- markdownlint-disable-next-line MD041 -->
22
### Pull Request Checklist
33

4-
* [ ] Have you checked to ensure there aren't other open
5-
[Pull Requests](../../pulls) for the same update/change?
4+
* [ ] Have you checked to ensure there aren't other open [Pull Requests](../../pulls) for the same update/change?
65
* [ ] Did you make your Pull Request on the dev branch?
76
* [ ] Does your submission pass tests? `make test`
87
* [ ] Have you lint your code locally prior to submission? `make lint`
9-
* [ ] Could you build and run the docker image successfully? `make image`
8+
* [ ] Could you build and run the docker images successfully? `make images`
109
* [ ] Could you create a running executable? `make executable`
11-
* [ ] Have you added an explanation of what your changes do
12-
and why you'd like to include them?
10+
* [ ] Have you added an explanation of what your changes do and why you'd like to include them?
1311
* [ ] Have you written new tests for your changes, as applicable?
1412
* [ ] Have you successfully ran manual tests with your changes locally?

.github/workflows/release.yml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,23 @@ jobs:
5959
push: ${{ github.event_name == 'push' }}
6060
tags: ${{ steps.meta.outputs.tags }}
6161
labels: ${{ steps.meta.outputs.labels }}
62+
- name: Extract Major and Minor Version
63+
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
64+
run: |
65+
TAG_NAME=${GITHUB_REF#refs/tags/}
66+
echo "Full Tag: $TAG_NAME"
67+
MAJOR=$(echo $TAG_NAME | cut -d. -f1)
68+
MINOR=$(echo $TAG_NAME | cut -d. -f1,2)
69+
echo "FULL_VERSION=$TAG_NAME" >> $GITHUB_ENV
70+
echo "MAJOR_VERSION=$MAJOR" >> $GITHUB_ENV
71+
echo "MINOR_VERSION=$MINOR" >> $GITHUB_ENV
6272
- uses: iamazeem/substitute-action@v1
63-
env:
64-
VERSION: ${{ steps.meta.outputs.version }}
65-
MAJOR: ${{ steps.meta.outputs.major }}
66-
MINIOR: ${{ steps.meta.outputs.minor }}
73+
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
6774
with:
6875
variables: |
69-
VERSION
70-
MAJOR
71-
MINOR
76+
FULL_VERSION
77+
MAJOR_VERSION
78+
MINOR_VERSION
7279
input-files: |
7380
./docker/DOCKER_README.md
7481
- uses: peter-evans/dockerhub-description@v3

config.sample.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ Topic =
141141
; Click = https://share.toogoodtogo.com/item/${{item_id}}
142142
; Username =
143143
; Password =
144+
; Token =
144145
; Timeout = 60
145146
; Cron =
146147

docker/DOCKER_README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ Readme, source, and documentation on [https://github.com/Der-Henning/tgtg](https
1111

1212
- [`edge`](https://github.com/Der-Henning/tgtg/blob/main/docker/Dockerfile)
1313
- [`edge-alpine`](https://github.com/Der-Henning/tgtg/blob/main/docker/Dockerfile.alpine)
14-
- [`${MAJOR}`, `${MINIOR}`, `${VERSION}`, `latest`](https://github.com/Der-Henning/tgtg/blob/${VERSION}/docker/Dockerfile)
15-
- [`${MAJOR}-alpine`, `${MINIOR}-alpine`, `${VERSION}-alpine`, `latest-alpine`](https://github.com/Der-Henning/tgtg/blob/${VERSION}/docker/Dockerfile.alpine)
14+
- [`${MAJOR_VERSION}`, `${MINIOR_VERSION}`, `${FULL_VERSION}`, `latest`](https://github.com/Der-Henning/tgtg/blob/${FULL_VERSION}/docker/Dockerfile)
15+
- [`${MAJOR_VERSION}-alpine`, `${MINIOR_VERSION}-alpine`, `${FULL_VERSION}-alpine`, `latest-alpine`](https://github.com/Der-Henning/tgtg/blob/${FULL_VERSION}/docker/Dockerfile.alpine)
1616

1717
<!-- markdownlint-disable-next-line MD025 -->
1818
# Quick Start

poetry.lock

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ name = "tgtg-scanner"
1212
packages = [{include = "tgtg_scanner"}]
1313
readme = "README.md"
1414
repository = "https://github.com/Der-Henning/tgtg"
15-
version = "1.18.0"
15+
version = "1.19.0"
1616

1717
[tool.poetry.dependencies]
1818
apprise = "^1.4.0"
@@ -49,12 +49,6 @@ scanner = "tgtg_scanner.__main__:main"
4949
tgtg_server = "tests.tgtg_server:main"
5050

5151
[tool.pytest.ini_options]
52-
addopts = [
53-
"--import-mode=importlib"
54-
]
5552
markers = [
5653
"tgtg_api: test directly calls the tgtg API (deselect with '-m \"not tgtg_api\"')"
5754
]
58-
pythonpath = [
59-
"."
60-
]

tgtg_scanner/models/config.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ class NtfyConfig(NotifierConfig):
322322
click: str = "${{link}}"
323323
username: Union[str, None] = None
324324
password: Union[str, None] = None
325+
token: Union[str, None] = None
325326
timeout: int = 60
326327

327328
def _read_ini(self, parser: configparser.ConfigParser):
@@ -337,6 +338,7 @@ def _read_ini(self, parser: configparser.ConfigParser):
337338
self._ini_get(parser, "NTFY", "Click", "click")
338339
self._ini_get(parser, "NTFY", "Username", "username")
339340
self._ini_get(parser, "NTFY", "Password", "password")
341+
self._ini_get(parser, "NTFY", "Token", "token")
340342
self._ini_get_int(parser, "NTFY", "Timeout", "timeout")
341343

342344
def _read_env(self):
@@ -352,6 +354,7 @@ def _read_env(self):
352354
self._env_get("NTFY_CLICK", "click")
353355
self._env_get("NTFY_USERNAME", "username")
354356
self._env_get("NTFY_PASSWORD", "password")
357+
self._env_get("NTFY_TOKEN", "token")
355358
self._env_get_int("NTFY_TIMEOUT", "timeout")
356359

357360

tgtg_scanner/notifiers/ntfy.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def __init__(self, config: Config, reservations: Reservations, favorites: Favori
2727
self.click = config.ntfy.click
2828
self.username = config.ntfy.username
2929
self.password = config.ntfy.password
30+
self.token = config.ntfy.token
3031
self.timeout = config.ntfy.timeout
3132
self.cron = config.ntfy.cron
3233
self.headers = dict()
@@ -42,8 +43,13 @@ def __init__(self, config: Config, reservations: Reservations, favorites: Favori
4243
if self.username is not None and self.password is not None:
4344
self.auth = HTTPBasicAuth(self.username, self.password)
4445
log.debug("Using basic auth with user '%s' for Ntfy", self.username)
45-
elif (self.username or self.password) is not None:
46-
log.warning("Username or Password missing for Ntfy authentication, defaulting to no auth")
46+
elif self.token is not None:
47+
self.headers = {
48+
"Authorization": "Bearer " + self.token,
49+
}
50+
log.debug("Using access token for Ntfy")
51+
else:
52+
log.warning("Username and Password or Access Token missing for Ntfy authentication, defaulting to no auth")
4753
try:
4854
Item.check_mask(self.title)
4955
Item.check_mask(self.message)
@@ -59,7 +65,7 @@ def _send(self, item: Union[Item, Reservation]) -> None:
5965
message = item.unmask(self.message).encode("utf-8")
6066
tags = item.unmask(self.tags).encode("utf-8")
6167
click = item.unmask(self.click).encode("utf-8")
62-
self.headers = {
68+
self.headers |= {
6369
"X-Title": title,
6470
"X-Message": message,
6571
"X-Priority": self.priority,

tgtg_scanner/notifiers/telegram.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ async def _stop_polling(self):
133133
await self.application.shutdown()
134134

135135
def start(self) -> None:
136-
if not self.chat_ids:
136+
if self.enabled and not self.chat_ids:
137137
asyncio.run(self._get_chat_ids())
138138
super().start()
139139

tgtg_scanner/tgtg/tgtg_client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
AUTH_POLLING_ENDPOINT = "auth/v3/authByRequestPollingId"
2929
SIGNUP_BY_EMAIL_ENDPOINT = "auth/v3/signUpByEmail"
3030
REFRESH_ENDPOINT = "auth/v3/token/refresh"
31-
ACTIVE_ORDER_ENDPOINT = "order/v6/active"
32-
INACTIVE_ORDER_ENDPOINT = "order/v6/inactive"
31+
ACTIVE_ORDER_ENDPOINT = "order/v7/active"
32+
INACTIVE_ORDER_ENDPOINT = "order/v7/inactive"
3333
CREATE_ORDER_ENDPOINT = "order/v7/create/"
3434
ABORT_ORDER_ENDPOINT = "order/v7/{}/abort"
3535
ORDER_STATUS_ENDPOINT = "order/v7/{}/status"
@@ -112,7 +112,7 @@ def __init__(
112112
user_id=None,
113113
datadome_cookie=None,
114114
user_agent=None,
115-
language="en-UK",
115+
language="en-GB",
116116
proxies=None,
117117
timeout=None,
118118
access_token_lifetime=DEFAULT_ACCESS_TOKEN_LIFETIME,

wiki/Configuration.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ For details on the service URL configuration see <https://github.com/caronc/appr
192192
| Click | NTFY_CLICK | URL to open on click | `${{link}}` | | YES |
193193
| Username | NTFY_USERNAME | auth username |
194194
| Password | NTFY_PASSWORD | auth password |
195+
| Token | NTFY_TOKEN | auth token, only used if username and password are empty |
195196
| Timeout | NTFY_TIMEOUT | timeout for Ntfy requests | 60 |
196197
| Cron | NTFY_CRON | enable notification only on schedule | `* * * * *` |
197198

0 commit comments

Comments
 (0)