Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement/slack bolt #2767

Merged
merged 45 commits into from
Jan 10, 2023
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
2d92e09
Inital work
kevgliss Dec 13, 2022
7a1933a
More bug fixes
kevgliss Dec 13, 2022
85f338d
Adding list participants
kevgliss Dec 13, 2022
7eee62d
Moving error messages
kevgliss Dec 13, 2022
1c20dad
Adds exceptions
kevgliss Dec 13, 2022
34b93ea
Formatting messages
kevgliss Dec 14, 2022
d5cd4c6
Modal submission
kevgliss Dec 16, 2022
25bbda1
More experiments
kevgliss Dec 16, 2022
7471853
Making modal success messages more straight forward
kevgliss Dec 20, 2022
1bd965d
Adding a decorator module
kevgliss Dec 20, 2022
a33e1b3
Allowing unregistered users
kevgliss Dec 20, 2022
75d858d
Resolve KeyError when sending ephemeral message
wssheldon Dec 20, 2022
264d92c
Merge branch 'master' into enhancement/slack-bolt
kevgliss Dec 20, 2022
f30ef0e
Resolves unexpected keyword argument 'code' in BoltResponse
wssheldon Dec 20, 2022
4462616
Resolves async ack never awaited error
wssheldon Dec 20, 2022
2b3b7dd
Enhancement/bolt bookmarks (#2784)
wssheldon Dec 20, 2022
5bf369b
check for existence of body and view in global error handler and ack …
wssheldon Dec 22, 2022
e8990fa
resolves hash conflict in incident report view and resolves UTC event…
wssheldon Dec 22, 2022
9257334
resolves report-tactical command, update view, and pass org slug
wssheldon Dec 22, 2022
ea86e09
implements notification group update command
wssheldon Dec 23, 2022
219cfb0
implement config middleware, functionify refetch_db, and uncomment co…
wssheldon Dec 23, 2022
52ca4e8
update configuring-slack docs to include bookmarks.write scope
wssheldon Dec 23, 2022
968dca6
minor cleanup of unused args, typechecking, and duplicate strings
wssheldon Dec 23, 2022
4dc9c29
resolve workflow exceptions, blockkit bugs, and front-end UI bugs
wssheldon Dec 23, 2022
6ff69a5
Merge branch 'master' into enhancement/slack-bolt
wssheldon Dec 23, 2022
299b95c
enhancement/conversation-bookmarks (#2799)
wssheldon Jan 3, 2023
2724c19
Merge branch 'master' into enhancement/slack-bolt
wssheldon Jan 3, 2023
6eb01bd
removes moved document update code
wssheldon Jan 3, 2023
e52edbb
mvilanova review: address most comments
wssheldon Jan 5, 2023
0d21ad3
mvilanova review: resolve final comments - oncall to lazy func
wssheldon Jan 5, 2023
b1e13d5
Update src/dispatch/plugins/dispatch_slack/incident/interactive.py
wssheldon Jan 5, 2023
eb76e5d
revert oncall success message
wssheldon Jan 5, 2023
1f91b7e
format workflowinstancetab vue file
wssheldon Jan 5, 2023
1a94277
format interactive.py with black to resolve linter issue
wssheldon Jan 5, 2023
d0d26e1
HTTPStatus value from http module and fix typo in engage oncall docst…
wssheldon Jan 5, 2023
2db6247
only build modal if there's a body in error handler
wssheldon Jan 6, 2023
b166152
add type checking to bolt code and fix participant counter func
wssheldon Jan 9, 2023
25743c4
type check workflow code
wssheldon Jan 9, 2023
e6af588
Merge remote-tracking branch 'origin/master' into enhancement/slack-bolt
mvilanova Jan 9, 2023
283d471
Adds missing db commit and fixes docstring
mvilanova Jan 9, 2023
77cad1a
Adds missing filter for channel join and leave subtype messages
mvilanova Jan 9, 2023
5cf4b0c
add args back to handle_message_events func
wssheldon Jan 9, 2023
ed98ba6
reimplement member_joined_channel and other minor fixes
wssheldon Jan 10, 2023
697f783
initial work to make error handling a better ux
wssheldon Jan 10, 2023
7d6f4ac
Merge branch 'master' into enhancement/slack-bolt
kevgliss Jan 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ The following are the bot and user scopes required for the Dispatch Slack App to
**Bot Token Scopes**

```text
bookmarks:write
mvilanova marked this conversation as resolved.
Show resolved Hide resolved
channels:read
chat:write
commands
Expand Down
28 changes: 23 additions & 5 deletions src/dispatch/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -725,11 +725,17 @@ def run_slack_websocket(organization: str, project: str):
"""Runs the slack websocket process."""
import asyncio
from sqlalchemy import true
from dispatch.project.models import ProjectRead
from dispatch.project import service as project_service
from dispatch.plugins.dispatch_slack import socket_mode
from dispatch.plugins.dispatch_slack.decorators import get_organization_scope_from_slug

from slack_bolt.adapter.socket_mode.async_handler import AsyncSocketModeHandler

from dispatch.common.utils.cli import install_plugins
from dispatch.plugins.dispatch_slack import feedback # noqa
mvilanova marked this conversation as resolved.
Show resolved Hide resolved
from dispatch.plugins.dispatch_slack.bolt import app
from dispatch.plugins.dispatch_slack.incident.interactive import configure as incident_configure
from dispatch.plugins.dispatch_slack.service import get_organization_scope_from_slug
from dispatch.plugins.dispatch_slack.workflow import configure as workflow_configure
from dispatch.project import service as project_service
from dispatch.project.models import ProjectRead

install_plugins()

Expand Down Expand Up @@ -760,8 +766,20 @@ def run_slack_websocket(organization: str, project: str):
return

session.close()

click.secho("Slack websocket process started...", fg="blue")
asyncio.run(socket_mode.run_websocket_process(instance.configuration))
incident_configure(instance.configuration)
workflow_configure(instance.configuration)

app._token = instance.configuration.api_bot_token.get_secret_value()

async def main():
handler = AsyncSocketModeHandler(
app, instance.configuration.socket_mode_app_token.get_secret_value()
)
await handler.start_async()

asyncio.run(main())


@dispatch_server.command("shell")
Expand Down
64 changes: 61 additions & 3 deletions src/dispatch/incident/flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,62 @@ def set_conversation_topic(incident: Incident, db_session: SessionLocal):
log.exception(e)


def set_conversation_bookmarks(incident: Incident, db_session: SessionLocal):
"""Sets the conversation bookmarks."""
if not incident.conversation:
log.warning("Conversation bookmark not set. No conversation available for this incident.")
return

plugin = plugin_service.get_active_instance(
db_session=db_session, project_id=incident.project.id, plugin_type="conversation"
)
if not plugin:
log.warning("Bookmarks not created. No conversation plugin enabled.")
return

try:
plugin.instance.set_bookmark(
incident.conversation.channel_id,
resolve_attr(incident, "incident_document.weblink"),
title="Incident Document",
) if incident.documents else log.warning(
"Document bookmark not set. No document available for this incident."
)

plugin.instance.set_bookmark(
incident.conversation.channel_id,
resolve_attr(incident, "conference.weblink"),
title="Video Conference",
) if incident.conference else log.warning(
"Conference bookmark not set. No conference available for this incident."
)

plugin.instance.set_bookmark(
incident.conversation.channel_id,
resolve_attr(incident, "storage.weblink"),
title="Storage",
) if incident.storage else log.warning(
"Storage bookmark not set. No storage available for this incident."
)

plugin.instance.set_bookmark(
incident.conversation.channel_id,
resolve_attr(incident, "ticket.weblink"),
title="Ticket",
) if incident.ticket else log.warning(
"Ticket bookmark not set. No ticket available for this incident."
)

except Exception as e:
event_service.log_incident_event(
db_session=db_session,
source="Dispatch Core App",
description=f"Setting the incident conversation bookmarks failed. Reason: {e}",
incident_id=incident.id,
)
log.exception(e)


def add_participants_to_conversation(
participant_emails: List[str], incident: Incident, db_session: SessionLocal
):
Expand Down Expand Up @@ -848,9 +904,6 @@ def incident_create_flow(*, organization_slug: str, incident_id: int, db_session
description="Conversation added to incident",
incident_id=incident.id,
)

# we set the conversation topic
set_conversation_topic(incident, db_session)
except Exception as e:
event_service.log_incident_event(
db_session=db_session,
Expand Down Expand Up @@ -896,6 +949,11 @@ def incident_create_flow(*, organization_slug: str, incident_id: int, db_session
)
log.exception(e)

# we set the conversation topic
set_conversation_topic(incident, db_session)
# we set the conversation bookmarks
set_conversation_bookmarks(incident, db_session)

# we defer this setup for all resolved incident roles until after resources have been created
roles = ["reporter", "commander", "liaison", "scribe"]

Expand Down
Loading