Skip to content

Commit

Permalink
Add channel to update check and use new endpoint (CTFd#1568)
Browse files Browse the repository at this point in the history
* Add a channel key to update check and use a new GET based update check endpoint
* Bump `black` version to `19.10b0`
  • Loading branch information
ColdHeat authored Jul 24, 2020
1 parent 1e2160b commit 4d4097a
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CTFd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from CTFd.utils.updates import update_check

__version__ = "3.0.0b3"
__channel__ = "oss"


class CTFdRequest(Request):
Expand Down Expand Up @@ -209,6 +210,7 @@ def set_sqlite_pragma(dbapi_connection, connection_record):

app.db = db
app.VERSION = __version__
app.CHANNEL = __channel__

from CTFd.cache import cache

Expand Down
5 changes: 3 additions & 2 deletions CTFd/utils/updates/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@ def update_check(force=False):
"team_count": Teams.query.count(),
"theme": get_config("ctf_theme"),
"upload_provider": get_app_config("UPLOAD_PROVIDER"),
"channel": app.CHANNEL,
}
check = requests.post(
"https://versioning.ctfd.io/", json=params, timeout=0.1
check = requests.get(
"https://versioning.ctfd.io/check", params=params, timeout=0.1
).json()
except requests.exceptions.RequestException:
pass
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
lint:
flake8 --ignore=E402,E501,E712,W503,E203 --exclude=CTFd/uploads CTFd/ migrations/ tests/
yarn lint
black --check --exclude=CTFd/uploads --exclude=node_modules .
black --check --diff --exclude=CTFd/uploads --exclude=node_modules .
prettier --check 'CTFd/themes/**/assets/**/*'
prettier --check '**/*.md'

Expand Down
2 changes: 1 addition & 1 deletion development.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ isort==4.3.21
flake8-isort==3.0.0
Faker==4.1.0
pipdeptree==0.13.2
black==19.3b0
black==19.10b0
2 changes: 1 addition & 1 deletion tests/utils/test_updates.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def test_update_check_is_called():
assert get_config("version_latest") is None


@patch.object(requests, "post")
@patch.object(requests, "get")
def test_update_check_identifies_update(fake_get_request):
"""Update checks properly identify new versions"""
app = create_ctfd()
Expand Down

0 comments on commit 4d4097a

Please sign in to comment.