Skip to content

Commit

Permalink
Merge branch 'master' into chore/test_docker_build
Browse files Browse the repository at this point in the history
  • Loading branch information
roblambell authored Dec 16, 2024
2 parents f0ea255 + e3ee407 commit c0d6e9d
Show file tree
Hide file tree
Showing 71 changed files with 929 additions and 332 deletions.
20 changes: 1 addition & 19 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,11 @@
"files.trimFinalNewlines": true,
"files.insertFinalNewline": true,
"vetur.format.enable": false,
"python.formatting.provider": "black",
"python.formatting.blackArgs": [
"--line-length",
"100"
],
"python.linting.enabled": true,
"python.linting.flake8Enabled": true,
"python.linting.flake8Args": [
"--ignore=E24,W504,E501",
"--verbose"
],
"python.testing.pytestEnabled": true,
"python.sortImports.args": [
"--settings-path",
"${workspaceFolder}/setup.cfg"
],
"python.linting.pylintArgs": [
"--rcfile",
"${workspaceFolder}/setup.cfg"
],
"[python]": {
"editor.codeActionsOnSave": {
"source.organizeImports": "never"
}
},
"codeQL.githubDatabase.update": "never",
}
4 changes: 2 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.13.0-slim-bullseye as sdist
FROM python:3.13.1-slim-bullseye as sdist

LABEL maintainer="[email protected]"
LABEL org.opencontainers.image.title="Dispatch PyPI Wheel"
Expand Down Expand Up @@ -56,7 +56,7 @@ RUN YARN_CACHE_FOLDER="$(mktemp -d)" \
&& mv /usr/src/dispatch/dist /dist

# This is the image to be run
FROM python:3.13.0-slim-bullseye
FROM python:3.13.1-slim-bullseye

LABEL maintainer="[email protected]"
LABEL org.opencontainers.image.title="Dispatch"
Expand Down
22 changes: 22 additions & 0 deletions docs/docs/administration/settings/server.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,28 @@ Make sure the reverse proxy strips this header from incoming requests (i.e. user

> The HTTP request header to use as the user name, this value is case-insensitive.
#### Configuration for `dispatch-auth-provider-aws-alb`

> Authenticate users based on [AWS Application Load Balancer authenticate](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/listener-authenticate-users.html).
#### `DISPATCH_AUTHENTICATION_PROVIDER_AWS_ALB_ARN`

> ARN of your Load Balancer, used to validate the signer.
> The format is `arn:aws:elasticloadbalancing:region-code:account-id:loadbalancer/app/load-balancer-name/load-balancer-id`.
> This is required when using the `dispatch-auth-provider-aws-alb` auth provider.
#### `DISPATCH_AUTHENTICATION_PROVIDER_AWS_ALB_EMAIL_CLAIM` \['default': email\]

> Override where Dispatch should find the user email in the users claims.
#### `DISPATCH_AUTHENTICATION_PROVIDER_AWS_ALB_PUBLIC_KEY_CACHE_SECONDS` \['default': 300\]

> Override how long Dispatch should cache the public key, used to validate the payload.
:::info
Add a ALB listener action without authenticate for `/api/v1/{organization}/events/*` if you want plugins to be public. Plugins determine their own authentication.
:::

### Persistence

#### `DATABASE_HOSTNAME`
Expand Down
7 changes: 4 additions & 3 deletions docs/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions requirements-base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ aiofiles==24.1.0
# via -r requirements-base.in
aiohappyeyeballs==2.4.3
# via aiohttp
aiohttp==3.11.9
aiohttp==3.11.10
# via -r requirements-base.in
aiosignal==1.3.1
# via aiohttp
Expand Down Expand Up @@ -126,7 +126,7 @@ frozenlist==1.5.0
# aiosignal
google-api-core==2.22.0
# via google-api-python-client
google-api-python-client==2.154.0
google-api-python-client==2.155.0
# via -r requirements-base.in
google-auth==2.36.0
# via
Expand Down Expand Up @@ -154,7 +154,7 @@ httplib2==0.22.0
# google-api-python-client
# google-auth-httplib2
# oauth2client
httpx==0.28.0
httpx==0.28.1
# via
# -r requirements-base.in
# openai
Expand Down Expand Up @@ -256,7 +256,7 @@ oauthlib[signedtoken]==3.2.2
# atlassian-python-api
# jira
# requests-oauthlib
openai==1.56.1
openai==1.57.2
# via -r requirements-base.in
packaging==24.2
# via
Expand Down Expand Up @@ -423,9 +423,9 @@ six==1.16.0
# python-dateutil
# sqlalchemy-filters
# validators
slack-bolt==1.21.2
slack-bolt==1.21.3
# via -r requirements-base.in
slack-sdk==3.33.4
slack-sdk==3.33.5
# via
# -r requirements-base.in
# slack-bolt
Expand All @@ -439,7 +439,7 @@ sniffio==1.3.1
# openai
sortedcontainers==2.4.0
# via hypothesis
spacy==3.8.2
spacy==3.8.3
# via -r requirements-base.in
spacy-legacy==3.0.12
# via spacy
Expand Down
6 changes: 3 additions & 3 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ click==8.1.7
# via
# -r requirements-dev.in
# black
coverage==7.6.8
coverage==7.6.9
# via -r requirements-dev.in
decorator==5.1.1
# via ipython
Expand Down Expand Up @@ -86,7 +86,7 @@ python-dateutil==2.9.0.post0
# via faker
pyyaml==6.0.2
# via pre-commit
ruff==0.8.1
ruff==0.8.2
# via -r requirements-dev.in
six==1.16.0
# via
Expand All @@ -104,7 +104,7 @@ typing-extensions==4.12.2
# ipython
virtualenv==20.27.1
# via pre-commit
vulture==2.13
vulture==2.14
# via -r requirements-dev.in
wcwidth==0.2.13
# via prompt-toolkit
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ def run(self):
"dispatch_atlassian_confluence = dispatch.plugins.dispatch_atlassian_confluence.plugin:ConfluencePagePlugin",
"dispatch_atlassian_confluence_document = dispatch.plugins.dispatch_atlassian_confluence.docs.plugin:ConfluencePageDocPlugin",
"dispatch_aws_sqs = dispatch.plugins.dispatch_aws.plugin:AWSSQSSignalConsumerPlugin",
"dispatch_aws_alb_auth = dispatch.plugins.dispatch_core.plugin:AwsAlbAuthProviderPlugin",
"dispatch_auth_mfa = dispatch.plugins.dispatch_core.plugin:DispatchMfaPlugin",
"dispatch_basic_auth = dispatch.plugins.dispatch_core.plugin:BasicAuthProviderPlugin",
"dispatch_contact = dispatch.plugins.dispatch_core.plugin:DispatchContactPlugin",
Expand Down
6 changes: 3 additions & 3 deletions src/dispatch/case/messaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,9 @@ def send_case_welcome_participant_message(
"assignee_fullname": case.assignee.individual.name,
"assignee_team": case.assignee.team,
"assignee_weblink": case.assignee.individual.weblink,
"reporter_fullname": case.reporter.individual.name,
"reporter_team": case.reporter.team,
"reporter_weblink": case.reporter.individual.weblink,
"reporter_fullname": case.reporter.individual.name if case.reporter else None,
"reporter_team": case.reporter.team if case.reporter else None,
"reporter_weblink": case.reporter.individual.weblink if case.reporter else None,
"document_weblink": resolve_attr(case, "case_document.weblink"),
"storage_weblink": resolve_attr(case, "storage.weblink"),
"ticket_weblink": resolve_attr(case, "ticket.weblink"),
Expand Down
26 changes: 19 additions & 7 deletions src/dispatch/case/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
from dispatch.enums import Visibility
from dispatch.event.models import EventRead
from dispatch.group.models import Group, GroupRead
from dispatch.incident.models import IncidentReadMinimal
from dispatch.messaging.strings import CASE_RESOLUTION_DEFAULT
from dispatch.models import (
DispatchBase,
Expand Down Expand Up @@ -230,6 +229,7 @@ class SignalInstanceRead(DispatchBase):
class ProjectRead(DispatchBase):
id: Optional[PrimaryKey]
name: NameStr
display_name: Optional[str]
color: Optional[str]
allow_self_join: Optional[bool] = Field(True, nullable=True)

Expand Down Expand Up @@ -267,6 +267,16 @@ class CaseCreate(CaseBase):
tags: Optional[List[TagRead]] = []


class CaseReadBasic(DispatchBase):
id: PrimaryKey
name: Optional[NameStr]


class IncidentReadBasic(DispatchBase):
id: PrimaryKey
name: Optional[NameStr]


CaseReadMinimal = ForwardRef("CaseReadMinimal")


Expand All @@ -277,8 +287,8 @@ class CaseReadMinimal(CaseBase):
case_priority: CasePriorityRead
case_severity: CaseSeverityRead
case_type: CaseTypeRead
duplicates: Optional[List[CaseReadMinimal]] = []
incidents: Optional[List[IncidentReadMinimal]] = []
duplicates: Optional[List[CaseReadBasic]] = []
incidents: Optional[List[IncidentReadBasic]] = []
related: Optional[List[CaseReadMinimal]] = []
closed_at: Optional[datetime] = None
created_at: Optional[datetime] = None
Expand All @@ -288,6 +298,8 @@ class CaseReadMinimal(CaseBase):
project: ProjectRead
reporter: Optional[ParticipantReadMinimal]
reported_at: Optional[datetime] = None
tags: Optional[List[TagRead]] = []
ticket: Optional[TicketRead] = None
total_cost: float | None
triage_at: Optional[datetime] = None

Expand All @@ -306,12 +318,12 @@ class CaseRead(CaseBase):
conversation: Optional[ConversationRead] = None
created_at: Optional[datetime] = None
documents: Optional[List[DocumentRead]] = []
duplicates: Optional[List[CaseReadMinimal]] = []
duplicates: Optional[List[CaseReadBasic]] = []
escalated_at: Optional[datetime] = None
events: Optional[List[EventRead]] = []
genai_analysis: Optional[dict[str, Any]] = {}
groups: Optional[List[GroupRead]] = []
incidents: Optional[List[IncidentReadMinimal]] = []
incidents: Optional[List[IncidentReadBasic]] = []
name: Optional[NameStr]
participants: Optional[List[ParticipantRead]] = []
project: ProjectRead
Expand All @@ -335,11 +347,11 @@ class CaseUpdate(CaseBase):
case_severity: Optional[CaseSeverityBase]
case_type: Optional[CaseTypeBase]
closed_at: Optional[datetime] = None
duplicates: Optional[List[CaseRead]] = []
duplicates: Optional[List[CaseReadBasic]] = []
related: Optional[List[CaseRead]] = []
reporter: Optional[ParticipantUpdate]
escalated_at: Optional[datetime] = None
incidents: Optional[List[IncidentReadMinimal]] = []
incidents: Optional[List[IncidentReadBasic]] = []
reported_at: Optional[datetime] = None
tags: Optional[List[TagRead]] = []
triage_at: Optional[datetime] = None
Expand Down
1 change: 1 addition & 0 deletions src/dispatch/case/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ def get_cases(
expand: bool = Query(default=False),
):
"""Retrieves all cases."""
common["include_keys"] = include
pagination = search_filter_sort_paginate(model="Case", **common)

if expand:
Expand Down
10 changes: 10 additions & 0 deletions src/dispatch/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,16 @@ def __str__(self) -> str:
"DISPATCH_AUTHENTICATION_PROVIDER_HEADER_NAME", default="remote-user"
)

DISPATCH_AUTHENTICATION_PROVIDER_AWS_ALB_ARN = config(
"DISPATCH_AUTHENTICATION_PROVIDER_AWS_ALB_ARN", default=None
)
DISPATCH_AUTHENTICATION_PROVIDER_AWS_ALB_EMAIL_CLAIM = config(
"DISPATCH_AUTHENTICATION_PROVIDER_AWS_ALB_EMAIL_CLAIM", default="email"
)
DISPATCH_AUTHENTICATION_PROVIDER_AWS_ALB_PUBLIC_KEY_CACHE_SECONDS = config(
"DISPATCH_AUTHENTICATION_PROVIDER_AWS_ALB_PUBLIC_KEY_CACHE_SECONDS", cast=int, default=300
)

# sentry middleware
SENTRY_ENABLED = config("SENTRY_ENABLED", default="")
SENTRY_DSN = config("SENTRY_DSN", default="")
Expand Down
10 changes: 8 additions & 2 deletions src/dispatch/conversation/flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,15 @@ def create_case_conversation(
# Do not overwrite a case conversation with one of the same type (thread, channel)
if case.conversation:
if case.has_channel:
raise RuntimeError("Case already has a dedicated channel conversation.")
log.warning(
f"Trying to create case conversation but case {case.id} already has a dedicated channel conversation."
)
return
if case.has_thread and not case.dedicated_channel:
raise RuntimeError("Case already has a thread conversation.")
log.warning(
"Trying to create case conversation but case {case.id} already has a thread conversation."
)
return

# This case is a thread version, we send a new messaged (threaded) to the conversation target
# for the configured case type
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""Adding display name to the projct model
Revision ID: 2d9e4d392ea4
Revises: 575ca7d954a8
Create Date: 2024-12-12 16:34:58.098426
"""

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = "2d9e4d392ea4"
down_revision = "575ca7d954a8"
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column(
"project", sa.Column("display_name", sa.String(), server_default="", nullable=False)
)

# Copy data from 'name' column to 'display_name' column
op.execute("UPDATE project SET display_name = name")

# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column("project", "display_name")
# ### end Alembic commands ###
Loading

0 comments on commit c0d6e9d

Please sign in to comment.