Skip to content

Commit

Permalink
Fix slack and discord app template logic and input fields (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
vegito22 authored Sep 16, 2023
1 parent a5f47a8 commit c073648
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 20 deletions.
15 changes: 4 additions & 11 deletions apps/handlers/discord_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ class DiscordBotRunner(AppRunner):
def app_init(self):
self.discord_bot_token = self.discord_config.get('bot_token')
self.session_id = self._get_discord_bot_seession_id(self.request.data)
self._input_field_name = self.app.input_schema.get(
'required', ['question'],
)[0]

def _get_discord_bot_seession_id(self, discord_request_payload):
if 'id' in discord_request_payload:
Expand Down Expand Up @@ -73,17 +70,12 @@ def _get_input_data(self, discord_request_payload):

def _get_discord_processor_actor_configs(self, input_data):
output_template = convert_template_vars_from_legacy_format(
self.app.output_template.get('markdown', ''),
self.app_data['output_template'].get(
'markdown', '') if self.app_data and 'output_template' in self.app_data else self.app.output_template.get('markdown', ''),
)

vendor_env = self.app_owner_profile.get_vendor_env()

processors = [
x.exit_endpoint for x in self.app.run_graph.all().order_by(
'id',
) if x is not None and x.exit_endpoint is not None
]

return ActorConfig(
name='discord_processor',
template_key='discord_processor',
Expand Down Expand Up @@ -141,7 +133,8 @@ def run_app(self):
processor_configs = {}
else:
template = convert_template_vars_from_legacy_format(
self.app.output_template.get('markdown', ''),
self.app_data['output_template'].get(
'markdown', '') if self.app_data and 'output_template' in self.app_data else self.app.output_template.get('markdown', ''),
)
actor_configs = [
ActorConfig(
Expand Down
15 changes: 6 additions & 9 deletions apps/handlers/slack_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,22 +110,18 @@ def _get_input_data(self, slack_request_payload):
'channel': slack_request_payload['event']['channel'],
'text-type': slack_request_payload['event']['type'],
'ts': slack_request_payload['event']['ts'],
**dict(zip(self.app.input_schema.get('properties', {}).keys(), [payload] * len(self.app.input_schema.get('properties', {})))),
**dict(zip(list(map(lambda x: x['name'], self.app_data['input_fields'])), [payload] * len(self.app_data['input_fields']))),
},
}
else:
raise Exception('Invalid Slack message type')

def _get_slack_processor_actor_configs(self, input_data):
output_template = convert_template_vars_from_legacy_format(
self.app.output_template.get('markdown', ''),
self.app_data['output_template'].get(
'markdown', '') if self.app_data and 'output_template' in self.app_data else self.app.output_template.get('markdown', ''),
)
vendor_env = self.app_owner_profile.get_vendor_env()
processors = [
x.exit_endpoint for x in self.app.run_graph.all().order_by(
'id',
) if x is not None and x.exit_endpoint is not None
]

return ActorConfig(
name='slack_processor',
Expand Down Expand Up @@ -189,8 +185,9 @@ def run_app(self):
processor_configs = {}
else:
template = convert_template_vars_from_legacy_format(
self.app.output_template.get('markdown', ''),
)
self.app_data['output_template'].get(
'markdown', '') if self.app_data and 'output_template' in self.app_data else self.app.output_template.get('markdown', ''),
)
actor_configs = [
ActorConfig(
name='input', template_key='_inputs0', actor=InputActor, kwargs={'input_request': self.input_actor_request},
Expand Down

0 comments on commit c073648

Please sign in to comment.