Skip to content

Commit

Permalink
Merge branch 'master' into enhancement/add-notification-filter-to-case
Browse files Browse the repository at this point in the history
  • Loading branch information
wssheldon authored Jul 8, 2024
2 parents 4814d74 + f93e43b commit b861284
Show file tree
Hide file tree
Showing 8 changed files with 142 additions and 126 deletions.
12 changes: 6 additions & 6 deletions requirements-base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ catalogue==2.0.10
# spacy
# srsly
# thinc
certifi==2023.11.17
certifi==2024.7.4
# via
# httpcore
# httpx
Expand Down Expand Up @@ -124,7 +124,7 @@ frozenlist==1.4.1
# aiosignal
google-api-core==2.15.0
# via google-api-python-client
google-api-python-client==2.134.0
google-api-python-client==2.136.0
# via -r requirements-base.in
google-auth==2.26.1
# via
Expand Down Expand Up @@ -242,7 +242,7 @@ oauthlib[signedtoken]==3.2.2
# atlassian-python-api
# jira
# requests-oauthlib
openai==1.35.3
openai==1.35.10
# via -r requirements-base.in
packaging==23.2
# via
Expand Down Expand Up @@ -394,9 +394,9 @@ six==1.16.0
# python-dateutil
# sqlalchemy-filters
# validators
slack-bolt==1.19.0
slack-bolt==1.19.1
# via -r requirements-base.in
slack-sdk==3.30.0
slack-sdk==3.31.0
# via
# -r requirements-base.in
# slack-bolt
Expand Down Expand Up @@ -444,7 +444,7 @@ statsmodels==0.14.2
# via -r requirements-base.in
tabulate==0.9.0
# via -r requirements-base.in
tenacity==8.4.1
tenacity==8.5.0
# via -r requirements-base.in
text-unidecode==1.3
# via python-slugify
Expand Down
6 changes: 3 additions & 3 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ executing==2.0.1
# stack-data
factory-boy==3.3.0
# via -r requirements-dev.in
faker==25.9.1
faker==26.0.0
# via
# -r requirements-dev.in
# factory-boy
Expand All @@ -42,7 +42,7 @@ identify==2.5.33
# via pre-commit
iniconfig==2.0.0
# via pytest
ipython==8.25.0
ipython==8.26.0
# via -r requirements-dev.in
jedi==0.19.1
# via ipython
Expand Down Expand Up @@ -86,7 +86,7 @@ python-dateutil==2.9.0.post0
# via faker
pyyaml==6.0.1
# via pre-commit
ruff==0.4.10
ruff==0.5.0
# via -r requirements-dev.in
six==1.16.0
# via
Expand Down
4 changes: 4 additions & 0 deletions src/dispatch/case/flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,10 @@ def case_assign_role_flow(
if result in ["assignee_has_role", "role_not_assigned"]:
return

# we stop here if this is not a dedicated channel case
if not case.dedicated_channel:
return

if case.status != CaseStatus.closed and participant_role == ParticipantRoleType.assignee:
# update the conversation topic
conversation_flows.set_conversation_topic(case, db_session)
Expand Down
22 changes: 18 additions & 4 deletions src/dispatch/enums.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
from enum import Enum
from enum import StrEnum


class DispatchEnum(str, Enum):
def __str__(self) -> str:
return str.__str__(self)
class DispatchEnum(StrEnum):
"""
A custom Enum class that extends StrEnum.
This class inherits all functionality from StrEnum, including
string representation and automatic value conversion to strings.
Example:
class Visibility(DispatchEnum):
OPEN = "Open"
RESTRICTED = "Restricted"
assert str(Visibility.OPEN) == "Open"
assert "Open" in Visibility
"""

pass # No additional implementation needed


class Visibility(DispatchEnum):
Expand Down
7 changes: 4 additions & 3 deletions src/dispatch/plugins/dispatch_slack/case/interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -1939,16 +1939,17 @@ def send_engagement_response(
engagement_status = SignalEngagementStatus.approved
else:
title = "MFA Failed"
message_text = f":warning: {engaged_user} attempted to confirm the behavior *as expected*, but the MFA validation failed. Reason: `{response}`\n\n *Context Provided* \n```{context_from_user}```"
engagement_status = SignalEngagementStatus.denied

if response == PushResponseResult.timeout:
text = "Confirmation failed, the MFA request timed out."
text = "Confirmation failed, the MFA request timed out. Please have your MFA device ready to accept the push notification and try again."
elif response == PushResponseResult.user_not_found:
text = "User not found in MFA provider."
text = "User not found in MFA provider. To validate your identity, please register in Duo and try again."
else:
text = "Confirmation failed. You must accept the MFA prompt."

message_text = f":warning: {engaged_user} attempted to confirm the behavior *as expected*, but the MFA validation failed.\n\n *Error Reason**: `{response}`\n\n{text}\n\n *Context Provided* \n```{context_from_user}```\n\n"

send_success_modal(
client=client,
view_id=view_id,
Expand Down
7 changes: 2 additions & 5 deletions src/dispatch/plugins/dispatch_slack/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,8 @@ def should_retry(exception: Exception) -> bool:
"""
match exception:
case SlackApiError():
# Don't retry for re-adding users in channel.
if exception.response["error"] in [SlackAPIErrorCode.USER_IN_CHANNEL, SlackAPIErrorCode.ALREADY_IN_CHANNEL]:
return False
# Retry if it's not a fatal error
return exception.response["error"] != SlackAPIErrorCode.FATAL_ERROR
# Don't retry for exceptions we have defined.
return exception.response["error"] not in SlackAPIErrorCode
case TimeoutError() | Timeout():
# Always retry on timeout errors
return True
Expand Down
Loading

0 comments on commit b861284

Please sign in to comment.