Skip to content

Commit

Permalink
Merge branch 'main' into enhancement/export-forms
Browse files Browse the repository at this point in the history
  • Loading branch information
whitdog47 authored Jan 29, 2025
2 parents ceff2e5 + 063830f commit 0406eb2
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 5 deletions.
4 changes: 0 additions & 4 deletions src/dispatch/auth/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,6 @@ def update(*, db_session, user: DispatchUser, user_in: UserUpdate) -> DispatchUs
if field in update_data:
setattr(user, field, update_data[field])

if user_in.password:
password = bytes(user_in.password, "utf-8")
user.password = password

if user_in.organizations:
roles = []

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""Adds a column allowing an incident priority level configurable on whether a "IC will be slow to respond" Slack message
Revision ID: 753ea20c2680
Revises: dfc8e213a2c4
Create Date: 2025-01-24 13:48:26.599465
"""

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = "753ea20c2680"
down_revision = "dfc8e213a2c4"
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column(
"incident_priority",
sa.Column("disable_delayed_message_warning", sa.Boolean(), nullable=True),
)
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column("incident_priority", "disable_delayed_message_warning")
# ### end Alembic commands ###
2 changes: 2 additions & 0 deletions src/dispatch/incident/priority/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class IncidentPriority(Base, ProjectMixin):
color = Column(String)
enabled = Column(Boolean, default=True)
default = Column(Boolean, default=False)
disable_delayed_message_warning = Column(Boolean, default=False)

# number of hours after which reports should be sent.
tactical_report_reminder = Column(Integer, default=24, server_default="24")
Expand Down Expand Up @@ -53,6 +54,7 @@ class IncidentPriorityBase(DispatchBase):
enabled: Optional[bool]
view_order: Optional[int]
color: Optional[Color] = Field(None, nullable=True)
disable_delayed_message_warning: Optional[bool]


class IncidentPriorityCreate(IncidentPriorityBase):
Expand Down
14 changes: 13 additions & 1 deletion src/dispatch/plugins/dispatch_slack/incident/interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
from dispatch.incident import service as incident_service
from dispatch.incident.enums import IncidentStatus
from dispatch.incident.models import IncidentCreate, IncidentRead, IncidentUpdate
from dispatch.incident.priority import service as incident_priority_service
from dispatch.individual import service as individual_service
from dispatch.individual.models import IndividualContactRead
from dispatch.monitor import service as monitor_service
Expand Down Expand Up @@ -787,6 +788,7 @@ def handle_timeline_added_event(

# TODO: (wshel) handle case reactions
if context["subject"].type == IncidentSubjects.incident:
individual = None
# we fetch the incident
incident = incident_service.get(db_session=db_session, incident_id=context["subject"].id)

Expand All @@ -805,7 +807,7 @@ def handle_timeline_added_event(

source = "Slack message"
# if the individual is not found, see if it is a bot
if individual is None:
if not individual:
if bot_user_id := context["bot_user_id"]:
try:
bot = dispatch_slack_service.get_user_info_by_id(client, bot_user_id)
Expand Down Expand Up @@ -895,6 +897,16 @@ def handle_after_hours_message(
participant = participant_service.get_by_incident_id_and_email(
db_session=db_session, incident_id=context["subject"].id, email=user.email
)

# get incident priority settings and if delayed message warning is disabled, log and return
incident_priority_data = incident_priority_service.get(
db_session=db_session, incident_priority_id=incident.incident_priority_id
)

if incident_priority_data.disable_delayed_message_warning:
log.debug("delayed messaging is disabled, not sending a warning")
return

# handle no participant found
if not participant:
log.warning(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@
hint="Check if this incident priority should be the default."
/>
</v-col>
<v-col cols="12">
<v-checkbox
v-model="disable_delayed_message_warning"
label="Disable delayed message warning"
hint="Would you like to disable Dispatch from notifying users when they send a message in Slack outside of the Incident Commander's 9a-5p working schedule?"
/>
</v-col>
<v-col cols="12">
<v-checkbox
v-model="enabled"
Expand Down Expand Up @@ -161,6 +168,7 @@ export default {
"selected.project",
"selected.tactical_report_reminder",
"selected.view_order",
"selected.disable_delayed_message_warning",
]),
...mapFields("incident_priority", {
default_incident_priority: "selected.default",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const getDefaultSelectedState = () => {
project: null,
tactical_report_reminder: null,
view_order: null,
disable_delayed_message_warning: null,
}
}

Expand Down

0 comments on commit 0406eb2

Please sign in to comment.