-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor integration connection and fix usability problems with integ…
…rations for new users - Add `AppUser.first_name_possesive` - Set `BotIntegration` streaming default to `True` and don't overwrite streaming=True in integration connect code - Simplify run title generation in `BasePage`. - Create `bot_integration_connect.py` for common integration methods. - Streamline integration logic: use published run only & pass pr_id in the integration redirect url state - Remove integration welcome screen for logged-in users - simply duplicate the published run for them - Cleanup URL generation and fix redirects on the integrations page - Add user nudges for unpublished changes + for non-owners - Fix slack personal channel creation: Avoid setting slack_create_personal_channels=False after connect so re-connect force creates personal channels
- Loading branch information
Showing
12 changed files
with
229 additions
and
214 deletions.
There are no files selected for viewing
This file contains 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
18 changes: 18 additions & 0 deletions
18
bots/migrations/0080_alter_botintegration_streaming_enabled.py
This file contains 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,18 @@ | ||
# Generated by Django 4.2.7 on 2024-08-19 16:46 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('bots', '0079_remove_botintegration_twilio_asr_language_and_more'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='botintegration', | ||
name='streaming_enabled', | ||
field=models.BooleanField(default=True, help_text='If set, the bot will stream messages to the frontend (Slack, Web & Whatsapp only)'), | ||
), | ||
] |
This file contains 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 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 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,44 @@ | ||
import json | ||
|
||
from fastapi import HTTPException, Request | ||
|
||
from bots.models import ( | ||
BotIntegration, | ||
Platform, | ||
PublishedRun, | ||
) | ||
from daras_ai_v2.base import RecipeTabs | ||
|
||
|
||
def connect_bot_to_published_run( | ||
bi: BotIntegration, published_run: PublishedRun | None | ||
) -> str: | ||
""" | ||
Connect the bot integration to the provided saved and published runs. | ||
Returns the redirect url to the integrations page for that bot integration. | ||
""" | ||
|
||
from daras_ai_v2.slack_bot import send_confirmation_msg | ||
from recipes.VideoBots import VideoBotsPage | ||
|
||
print(f"Connecting {bi} to {published_run}") | ||
|
||
bi.published_run = published_run | ||
bi.save(update_fields=["published_run"]) | ||
|
||
if bi.platform == Platform.SLACK: | ||
send_confirmation_msg(bi) | ||
|
||
return VideoBotsPage.app_url( | ||
tab=RecipeTabs.integrations, | ||
example_id=published_run.published_run_id, | ||
path_params=dict(integration_id=bi.api_integration_id()), | ||
) | ||
|
||
|
||
def load_published_run_from_state(request: Request) -> PublishedRun: | ||
pr_id = json.loads(request.query_params.get("state") or "{}").get("pr_id") | ||
try: | ||
return PublishedRun.objects.get(id=pr_id) | ||
except PublishedRun.DoesNotExist: | ||
raise HTTPException(status_code=404, detail="Published Run not found") |
This file contains 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 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.