Skip to content

Commit

Permalink
styling
Browse files Browse the repository at this point in the history
  • Loading branch information
Furrior committed Feb 28, 2025
1 parent 1608438 commit 6a41be4
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 41 deletions.
3 changes: 2 additions & 1 deletion app/core/db.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from sqlmodel import SQLModel, create_engine
from sqlmodel import create_engine

from app.core.config import CONFIG

Expand All @@ -17,5 +17,6 @@
TODO: Use SQLAlchemy's async engine
"""


def init_db() -> None:
return
3 changes: 1 addition & 2 deletions app/core/redis.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from typing import AsyncGenerator
import redis.asyncio as redis

from app.core.config import CONFIG
Expand All @@ -8,4 +7,4 @@

async def send_message(channel: str, message: str) -> None:
client = redis.Redis(connection_pool=REDIS_POOL)
await client.publish(f"{CONFIG.redis.channel}.{channel}", message)
await client.publish(f"{CONFIG.redis.channel}.{channel}", message)
28 changes: 0 additions & 28 deletions app/routes/v1/admin.py

This file was deleted.

5 changes: 2 additions & 3 deletions app/routes/v1/donate.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import datetime
import logging

from fastapi import APIRouter, Depends, HTTPException, Request, status
from fastapi import APIRouter, Depends, Request, status
from sqlmodel import select
from sqlmodel.sql.expression import SelectOfScalar

from app.database.models import Donation, Player
from app.deps import SessionDep, verify_bearer
from app.routes.v1.player import create_player, get_or_create_player_by_discord_id
from app.routes.v1.player import get_or_create_player_by_discord_id
from app.schemas.donate import NewDonationDiscord
from app.schemas.generic import PaginatedResponse, paginate_selection
from app.schemas.player import NewPlayer

logger = logging.getLogger(__name__)

Expand Down
9 changes: 5 additions & 4 deletions app/routes/v1/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from app.fur_discord import DiscordOAuthClient
from app.schemas.generic import PaginatedResponse
from app.schemas.player import NewPlayer, PlayerPatch
import app.core.redis as redis
from app.core import redis

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -91,13 +91,14 @@ async def callback(session: SessionDep, code: str, state: str) -> Player:
discord_id = discord_user.id

if link := session.exec(select(Player).where(
Player.discord_id == discord_id)).first():
Player.discord_id == discord_id)).first():
# General player account already exists
if link.ckey is not None:
raise HTTPException(
status_code=status.HTTP_409_CONFLICT, detail="Player already linked")

logger.debug("Linking a preexisting player %s to %s", link.discord_id, ckey)
logger.debug("Linking a preexisting player %s to %s",
link.discord_id, ckey)
link.ckey = ckey
else:
link = Player(ckey=ckey, discord_id=discord_id)
Expand Down Expand Up @@ -250,4 +251,4 @@ async def update_player(session: SessionDep, id: int, player_patch: PlayerPatch)
async def update_player_event(player: Player) -> None:
await redis.send_message("link", player.model_dump_json())

# endregion
# endregion
6 changes: 4 additions & 2 deletions app/routes/v1/whitelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ async def get_whitelisted_ckeys(session: SessionDep,
status.HTTP_404_NOT_FOUND: {"description": "Whitelist not found"},
})
def get_whitelist(session: SessionDep,
id: int): # pylint: disable=redefined-builtin
id: int): # pylint: disable=redefined-builtin
wl = session.exec(select(Whitelist).where(Whitelist.id == id)).first()

if wl is None:
Expand All @@ -124,6 +124,7 @@ def get_whitelist(session: SessionDep,
# endregion
# region Post


WHITELIST_POST_RESPONSES = {
**BEARER_DEP_RESPONSES,
status.HTTP_201_CREATED: {"description": "Whitelist created"},
Expand Down Expand Up @@ -241,7 +242,7 @@ async def get_whitelist_bans(session: SessionDep,
status.HTTP_200_OK: {"description": "Whitelist"},
status.HTTP_404_NOT_FOUND: {"description": "Whitelist not found"},
})
def get_whitelist_ban(session, id): # pylint: disable=redefined-builtin
def get_whitelist_ban(session, id): # pylint: disable=redefined-builtin
wl_ban = session.exec(select(WhitelistBan).where(
WhitelistBan.id == id)).first()

Expand All @@ -254,6 +255,7 @@ def get_whitelist_ban(session, id): # pylint: disable=redefined-builtin
# endregion
# region Post


BAN_POST_RESPONSES = {
**BEARER_DEP_RESPONSES,
status.HTTP_201_CREATED: {"description": "Ban created"},
Expand Down
3 changes: 2 additions & 1 deletion app/schemas/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class PlayerPatch(BaseModel):
discord_id: str | None = None
ckey: str | None = None


class NewPlayer(BaseModel):
discord_id: str
ckey: str | None = None
ckey: str | None = None

0 comments on commit 6a41be4

Please sign in to comment.