Skip to content

Commit

Permalink
Adds the Slack domain to the conversation weblink URL. (#3520)
Browse files Browse the repository at this point in the history
* Allows pre-population of the incident title, description, and tags in the incident intake form by including them in the URL path.

* Adds the Slack domain to the conversation weblink URL

* Bump ruff from 0.0.269 to 0.0.270 (#3432)

Bumps [ruff](https://github.com/charliermarsh/ruff) from 0.0.269 to 0.0.270.
- [Release notes](https://github.com/charliermarsh/ruff/releases)
- [Changelog](https://github.com/charliermarsh/ruff/blob/main/BREAKING_CHANGES.md)
- [Commits](astral-sh/ruff@v0.0.269...v0.0.270)

---
updated-dependencies:
- dependency-name: ruff
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump google-api-python-client from 2.86.0 to 2.87.0 (#3431)

Bumps [google-api-python-client](https://github.com/googleapis/google-api-python-client) from 2.86.0 to 2.87.0.
- [Release notes](https://github.com/googleapis/google-api-python-client/releases)
- [Changelog](https://github.com/googleapis/google-api-python-client/blob/main/CHANGELOG.md)
- [Commits](googleapis/google-api-python-client@v2.86.0...v2.87.0)

---
updated-dependencies:
- dependency-name: google-api-python-client
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump schemathesis from 3.19.2 to 3.19.3 (#3430)

Bumps [schemathesis](https://github.com/schemathesis/schemathesis) from 3.19.2 to 3.19.3.
- [Release notes](https://github.com/schemathesis/schemathesis/releases)
- [Changelog](https://github.com/schemathesis/schemathesis/blob/master/docs/changelog.rst)
- [Commits](schemathesis/schemathesis@v3.19.2...v3.19.3)

---
updated-dependencies:
- dependency-name: schemathesis
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump @playwright/test in /src/dispatch/static/dispatch (#3429)

Bumps [@playwright/test](https://github.com/Microsoft/playwright) from 1.34.2 to 1.34.3.
- [Release notes](https://github.com/Microsoft/playwright/releases)
- [Commits](microsoft/playwright@v1.34.2...v1.34.3)

---
updated-dependencies:
- dependency-name: "@playwright/test"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump requests from 2.28.2 to 2.31.0 (#3436)

Bumps [requests](https://github.com/psf/requests) from 2.28.2 to 2.31.0.
- [Release notes](https://github.com/psf/requests/releases)
- [Changelog](https://github.com/psf/requests/blob/main/HISTORY.md)
- [Commits](psf/requests@v2.28.2...v2.31.0)

---
updated-dependencies:
- dependency-name: requests
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump eslint-plugin-vue in /src/dispatch/static/dispatch (#3435)

Bumps [eslint-plugin-vue](https://github.com/vuejs/eslint-plugin-vue) from 9.14.0 to 9.14.1.
- [Release notes](https://github.com/vuejs/eslint-plugin-vue/releases)
- [Commits](vuejs/eslint-plugin-vue@v9.14.0...v9.14.1)

---
updated-dependencies:
- dependency-name: eslint-plugin-vue
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump vite from 3.2.6 to 3.2.7 in /src/dispatch/static/dispatch (#3434)

Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 3.2.6 to 3.2.7.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/v3.2.7/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v3.2.7/packages/vite)

---
updated-dependencies:
- dependency-name: vite
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump coverage from 7.2.6 to 7.2.7 (#3442)

Bumps [coverage](https://github.com/nedbat/coveragepy) from 7.2.6 to 7.2.7.
- [Release notes](https://github.com/nedbat/coveragepy/releases)
- [Changelog](https://github.com/nedbat/coveragepy/blob/master/CHANGES.rst)
- [Commits](nedbat/coveragepy@7.2.6...7.2.7)

---
updated-dependencies:
- dependency-name: coverage
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump google-api-python-client from 2.87.0 to 2.88.0 (#3441)

Bumps [google-api-python-client](https://github.com/googleapis/google-api-python-client) from 2.87.0 to 2.88.0.
- [Release notes](https://github.com/googleapis/google-api-python-client/releases)
- [Changelog](https://github.com/googleapis/google-api-python-client/blob/main/CHANGELOG.md)
- [Commits](googleapis/google-api-python-client@v2.87.0...v2.88.0)

---
updated-dependencies:
- dependency-name: google-api-python-client
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump protobuf from 4.23.1 to 4.23.2 (#3440)

Bumps [protobuf](https://github.com/protocolbuffers/protobuf) from 4.23.1 to 4.23.2.
- [Release notes](https://github.com/protocolbuffers/protobuf/releases)
- [Changelog](https://github.com/protocolbuffers/protobuf/blob/main/generate_changelog.py)
- [Commits](protocolbuffers/protobuf@v4.23.1...v4.23.2)

---
updated-dependencies:
- dependency-name: protobuf
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump cachetools from 5.3.0 to 5.3.1 (#3439)

Bumps [cachetools](https://github.com/tkem/cachetools) from 5.3.0 to 5.3.1.
- [Changelog](https://github.com/tkem/cachetools/blob/master/CHANGELOG.rst)
- [Commits](tkem/cachetools@v5.3.0...v5.3.1)

---
updated-dependencies:
- dependency-name: cachetools
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump pandas from 2.0.1 to 2.0.2 (#3438)

Bumps [pandas](https://github.com/pandas-dev/pandas) from 2.0.1 to 2.0.2.
- [Release notes](https://github.com/pandas-dev/pandas/releases)
- [Commits](pandas-dev/pandas@v2.0.1...v2.0.2)

---
updated-dependencies:
- dependency-name: pandas
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Fix a bug where db_session is not passed in Slack Case creation (#3443)

* Re-imports the incident auto tagger function (#3448)

* db_session needs to be passed here (#3447)

* Re scoping the database session close (#3445)

* Responses for message posts and updates now return the message permalink instead of the channel permalink

* fix lint errors

* Refactor message permalink retrieval to its own function

* fix lint errors

* Caches the Slack domain

* Reverts complete Slack URL retrieval

* Resolves error with adding already-engaged participants to the Slack conversation.

* Adds the Slack domain to the conversation weblink URL

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Will Sheldon <[email protected]>
Co-authored-by: Marc Vilanova <[email protected]>
Co-authored-by: kevgliss <[email protected]>
  • Loading branch information
5 people authored Jun 26, 2023
1 parent 019f313 commit 0fe2a88
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/dispatch/plugins/dispatch_slack/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@


class SlackAPIGetEndpoints(DispatchEnum):
chat_permalink = "chat.getPermalink"
conversations_history = "conversations.history"
conversations_info = "conversations.info"
team_info = "team.info"
users_conversations = "users.conversations"
users_info = "users.info"
users_lookup_by_email = "users.lookupByEmail"
Expand Down
5 changes: 5 additions & 0 deletions src/dispatch/plugins/dispatch_slack/incident/interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -931,6 +931,11 @@ def handle_member_joined_channel(
participant = incident_flows.incident_add_or_reactivate_participant_flow(
user_email=user.email, incident_id=context["subject"].id, db_session=db_session
)

if not participant:
# Participant is already in the incident channel.
return

participant.user_conversation_id = context["user_id"]

incident = incident_service.get(db_session=db_session, incident_id=context["subject"].id)
Expand Down
21 changes: 18 additions & 3 deletions src/dispatch/plugins/dispatch_slack/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ def list_conversation_messages(client: WebClient, conversation_id: str, **kwargs
)


@functools.lru_cache()
def get_domain(client: WebClient) -> str:
"""Gets the team's Slack domain."""
return make_call(client, SlackAPIGetEndpoints.team_info)["team"]["domain"]


@functools.lru_cache()
def get_user_info_by_id(client: WebClient, user_id: str) -> dict:
"""Gets profile information about a user by id."""
Expand Down Expand Up @@ -195,7 +201,7 @@ def create_conversation(client: WebClient, name: str, is_private: bool = False)
return {
"id": response["id"],
"name": response["name"],
"weblink": f"https://slack.com/app_redirect?channel={response['id']}",
"weblink": f"https://{get_domain(client)}.slack.com/app_redirect?channel={response['id']}",
}


Expand Down Expand Up @@ -270,6 +276,15 @@ def add_users_to_conversation(
pass


def get_message_permalink(client: WebClient, conversation_id: str, ts: str) -> str:
return make_call(
client,
SlackAPIGetEndpoints.chat_permalink,
channel=conversation_id,
message_ts=ts,
)


def send_message(
client: WebClient,
conversation_id: str,
Expand All @@ -294,7 +309,7 @@ def send_message(
return {
"id": response["channel"],
"timestamp": response["ts"],
"weblink": f"https://slack.com/app_redirect?channel={response['id']}", # TODO should we fetch the permalink?
"weblink": get_message_permalink(client, response["channel"], response["ts"]),
}


Expand All @@ -318,7 +333,7 @@ def update_message(
return {
"id": response["channel"],
"timestamp": response["ts"],
"weblink": f"https://slack.com/app_redirect?channel={response['id']}", # TODO should we fetch the permalink?
"weblink": get_message_permalink(client, response["channel"], response["ts"]),
}


Expand Down

0 comments on commit 0fe2a88

Please sign in to comment.