Skip to content

Commit

Permalink
refactor!: Move slack application under api.
Browse files Browse the repository at this point in the history
  • Loading branch information
osala-eng committed Mar 12, 2024
1 parent 185e8a9 commit 8d7416b
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 5 deletions.
4 changes: 4 additions & 0 deletions web/api/index_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class name: route replace capitalise route segments remove `/` and `_`. Example:
"""

# for now we'll manually add imports. TODO: convert to walk the directory and dynamically import using importlib
import importlib

from . import (
chat_completion_handler, # noqa: F401 DO NOT REMOVE
hello_handler, # noqa: F401 DO NOT REMOVE
Expand All @@ -22,3 +24,5 @@ class name: route replace capitalise route segments remove `/` and `_`. Example:
threads_handler, # noqa: F401 DO NOT REMOVE
token_handler, # noqa: F401 DO NOT REMOVE
)

importlib.import_module("web.api.integration.slack.index_handler")
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from typing import Any

from web.slack.slack_application import slack_app
from web.api.integration.slack.slack_application import slack_app


@slack_app.event("app_home_opened")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

from slack_bolt.context.say import Say

from web.slack.slack_application import slack_app
from web.slack.utils import chat_completion
from web.api.integration.slack.slack_application import slack_app
from web.api.integration.utils import chat_completion

CHANNEL_TEMPLATE = "<@{user}> {response}"

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
slack_app = App()


@st_app.api_route("/slack/events", dict(app=slack_app))
@st_app.api_route("/api/integration/slack/v1/events", dict(app=slack_app))
class SlackEventHandler(SlackEventsHandler, BaseRequestHandler):
"""Handle /slack/events requests."""
File renamed without changes.
1 change: 0 additions & 1 deletion web/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from utils.observability import baggage_as_attributes, tracer

import web.api.index_handler # noqa F401 don't remove this line, it's used to register api routes
import web.slack.index_handler # noqa F401 don't remove this line, it's used to register slackbot handlers

with tracer().start_as_current_span("home_page", attributes=baggage_as_attributes()):
render_docq_logo()
Expand Down

0 comments on commit 8d7416b

Please sign in to comment.