Skip to content

Commit

Permalink
slack_menu empty tag list fix; uvloop support. (#2419)
Browse files Browse the repository at this point in the history
* fixes empty tag list in non-incident channels

* Added uvloop support

* add uvloop to requirements-base.in
  • Loading branch information
kishore-jalleda authored Aug 18, 2022
1 parent 643dc3b commit f3e2481
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions requirements-base.in
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,5 @@ statsmodels
tabulate
tenacity
uvicorn
uvloop
validators==0.18.2
2 changes: 2 additions & 0 deletions requirements-base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,8 @@ urllib3==1.26.11
# sentry-sdk
uvicorn==0.18.2
# via -r requirements-base.in
uvloop==0.16.0
# via -r requirements-base.in
validators==0.18.2
# via -r requirements-base.in
wasabi==0.10.0
Expand Down
2 changes: 1 addition & 1 deletion src/dispatch/plugins/dispatch_slack/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def get_organization_scope_from_channel_id(channel_id: str) -> SessionLocal:


def get_organization_scope_from_slug(slug: str) -> SessionLocal:
"""Iterate all organizations looking for a relevant channel_id."""
"""Iterate all organizations looking for a matching slug."""
db_session = SessionLocal()
organization = organization_service.get_by_slug(db_session=db_session, slug=slug)
db_session.close()
Expand Down
8 changes: 6 additions & 2 deletions src/dispatch/plugins/dispatch_slack/menus.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
from dispatch.plugins.dispatch_slack.modals.common import parse_submitted_form
from dispatch.plugins.dispatch_slack.modals.incident.enums import IncidentBlockId

from .decorators import get_organization_scope_from_channel_id
from .decorators import get_organization_scope_from_channel_id, get_organization_scope_from_slug

log = logging.getLogger(__name__)


async def handle_slack_menu(*, config, client: WebClient, request: Request):
async def handle_slack_menu(*, config, client: WebClient, request: Request, organization: str):
"""Handles slack menu message."""
# We resolve the user's email
user_id = request["user"]["id"]
Expand All @@ -34,6 +34,10 @@ async def handle_slack_menu(*, config, client: WebClient, request: Request):
action_id = request["action_id"]

db_session = get_organization_scope_from_channel_id(channel_id=channel_id)
if not db_session:
# Command (e.g. report_incident) run from a non-incident channel.
db_session = get_organization_scope_from_slug(organization)

f = menu_functions(action_id)
return f(db_session, user_id, user_email, channel_id, incident_id, query_str, request)

Expand Down
2 changes: 1 addition & 1 deletion src/dispatch/plugins/dispatch_slack/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@ async def handle_menu(
verify_timestamp(x_slack_request_timestamp)

# We verify the signature
verify_signature(organization, raw_request_body, x_slack_request_timestamp, x_slack_signature)
current_configuration = verify_signature(
organization, raw_request_body, x_slack_request_timestamp, x_slack_signature
)
Expand All @@ -248,5 +247,6 @@ async def handle_menu(
config=current_configuration,
client=slack_async_client,
request=request,
organization=organization,
)
return JSONResponse(content=body)

0 comments on commit f3e2481

Please sign in to comment.