This repository was archived by the owner on Sep 3, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 642
feat(slack): adds slash command for read-in summaries #6126
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
48f363b
feat(slack): adds slash command for read-in summaries
whitdog47 0fd1307
adds new command to test
whitdog47 aeab605
Only generate summary for dedicate channel cases
whitdog47 b9ac6e9
cleaning up subject_type
whitdog47 5febcea
Merge branch 'main' into feat/slash-command-for-readin
whitdog47 83017aa
Merge branch 'main' into feat/slash-command-for-readin
whitdog47 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
src/dispatch/database/revisions/tenant/versions/2025-07-11_aa87efd3d6c1.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| """Adds new Slack command for read-in summary generation | ||
| Revision ID: aa87efd3d6c1 | ||
| Revises: f63ad392dbbf | ||
| Create Date: 2025-07-11 10:02:39.819258 | ||
| """ | ||
|
|
||
| from alembic import op | ||
| from pydantic import SecretStr, ValidationError | ||
| from pydantic.json import pydantic_encoder | ||
|
|
||
| from sqlalchemy import Column, Integer, ForeignKey, String | ||
| from sqlalchemy.ext.declarative import declarative_base | ||
| from sqlalchemy.orm import relationship, Session | ||
| from sqlalchemy.ext.hybrid import hybrid_property | ||
| from sqlalchemy_utils import StringEncryptedType | ||
| from sqlalchemy_utils.types.encrypted.encrypted_type import AesEngine | ||
| from dispatch.config import config, DISPATCH_ENCRYPTION_KEY | ||
|
|
||
|
|
||
| # revision identifiers, used by Alembic. | ||
| revision = "aa87efd3d6c1" | ||
| down_revision = "f63ad392dbbf" | ||
| branch_labels = None | ||
| depends_on = None | ||
|
|
||
| Base = declarative_base() | ||
|
|
||
|
|
||
| def show_secrets_encoder(obj): | ||
| if isinstance(obj, SecretStr): | ||
| return obj.get_secret_value() | ||
| else: | ||
| return pydantic_encoder(obj) | ||
|
|
||
|
|
||
| def migrate_config(instances, slug, config): | ||
| for instance in instances: | ||
| if slug == instance.plugin.slug: | ||
| instance.configuration = config | ||
|
|
||
|
|
||
| class Plugin(Base): | ||
| __tablename__ = "plugin" | ||
| __table_args__ = {"schema": "dispatch_core"} | ||
| id = Column(Integer, primary_key=True) | ||
| slug = Column(String, unique=True) | ||
|
|
||
|
|
||
| class PluginInstance(Base): | ||
| __tablename__ = "plugin_instance" | ||
| id = Column(Integer, primary_key=True) | ||
| _configuration = Column( | ||
| StringEncryptedType(key=str(DISPATCH_ENCRYPTION_KEY), engine=AesEngine, padding="pkcs5") | ||
| ) | ||
| plugin_id = Column(Integer, ForeignKey(Plugin.id)) | ||
| plugin = relationship(Plugin, backref="instances") | ||
|
|
||
| @hybrid_property | ||
| def configuration(self): | ||
| """Property that correctly returns a plugins configuration object.""" | ||
| pass | ||
|
|
||
| @configuration.setter | ||
| def configuration(self, configuration): | ||
| """Property that correctly sets a plugins configuration object.""" | ||
| if configuration: | ||
| self._configuration = configuration.json(encoder=show_secrets_encoder) | ||
|
|
||
|
|
||
| def upgrade(): | ||
| # ### commands auto generated by Alembic - please adjust! ### | ||
| from dispatch.plugins.dispatch_slack.config import SlackConversationConfiguration | ||
|
|
||
| bind = op.get_bind() | ||
| session = Session(bind=bind) | ||
|
|
||
| instances = session.query(PluginInstance).all() | ||
|
|
||
| # Slash commands | ||
| SLACK_COMMAND_SUMMARY_SLUG = config("SLACK_COMMAND_SUMMARY_SLUG", default="/dispatch-summary") | ||
|
|
||
| try: | ||
| slack_conversation_config = SlackConversationConfiguration( | ||
| slack_command_summary=SLACK_COMMAND_SUMMARY_SLUG, | ||
| ) | ||
|
|
||
| migrate_config(instances, "slack-conversation", slack_conversation_config) | ||
|
|
||
| except ValidationError: | ||
| print( | ||
| "Skipping automatic migration of slack plugin credentials, if you are using the slack plugin manually migrate credentials." | ||
| ) | ||
|
|
||
| session.commit() | ||
| # ### end Alembic commands ### | ||
|
|
||
|
|
||
| def downgrade(): | ||
| # ### commands auto generated by Alembic - please adjust! ### | ||
| pass | ||
| # ### end Alembic commands ### | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.