Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions src/api/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
router: APIRouter = APIRouter()


@router.get("/calendar")
@router.get("/api/calendar")
async def get_calendar() -> JSONResponse:
"""
Returns calendar data.
Expand All @@ -31,7 +31,7 @@ async def get_calendar() -> JSONResponse:
return JSONResponse(formatted_events)


@router.get("/announcement")
@router.get("/api/announcement")
def get_announcement() -> JSONResponse:
"""
Returns announcement data.
Expand All @@ -57,11 +57,9 @@ async def slack_events(request: Request) -> JSONResponse:

try:
logger.info("Received Slack event!")

body: dict = await request.json()
if request.headers.get("content-type") == "application/json":


if body.get("type") == "url_verification":
return JSONResponse({"challenge": body.get("challenge")})

Expand Down Expand Up @@ -128,7 +126,7 @@ async def message_actions(payload: str = Form(...)) -> JSONResponse:
return JSONResponse({"status": "success"}, status_code=200)


@router.get("/wikithought")
@router.get("/api/wikithought")
async def wikithought() -> JSONResponse:
"""
Returns a random CSH wiki thought from the MediaWiki API.
Expand Down
12 changes: 6 additions & 6 deletions src/core/wikithoughts.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ async def refresh_page_dictionary() -> None:

def reset_queues() -> None:
"""
Swaps Queued and Shown pages que
Swaps Queued and Shown pages queued
"""
global queued_pages, shown_pages
logger.warning("RESETING QUEUES FOR WIKITHOUGHTS")
Expand Down Expand Up @@ -277,20 +277,20 @@ async def get_next_display() -> dict[str, str]:

await refresh_category_pages()

que_empty: bool = len(queued_pages) == 0
if que_empty and len(shown_pages) == 0:
queue_empty: bool = len(queued_pages) == 0
if queue_empty and len(shown_pages) == 0:
logger.warning("ERROR?!?")
current_page = {
"page": "ERROR GETTING PAGE",
"content": "ERROR FETCHING CONTENT",
}
elif que_empty:
elif queue_empty:
reset_queues()
que_empty = False
queue_empty = False

new_page: str = queued_pages.pop()

if que_empty:
if queue_empty:
reset_queues()

shown_pages.append(new_page)
Expand Down
3 changes: 2 additions & 1 deletion src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ async def docs_redirect():
logger.warning("Documentation directory not found, skipping documentation setup!")

logger.info("Importing API endpoints!")
app.include_router(endpoints.router, prefix="/api")
# app.include_router(endpoints.router, prefix="/api")
app.include_router(endpoints.router)

logger.info("Finished setting up the application!")

Expand Down
Loading