Skip to content

Commit

Permalink
Check channel creadentials for merged config
Browse files Browse the repository at this point in the history
  • Loading branch information
norkans7 committed Mar 10, 2023
1 parent fdbd9e8 commit 1ae190e
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions temba/channels/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,18 +425,11 @@ def add_config_field(self, config_key: str, field, *, default):
self.fields[config_key] = field
self.config_fields.append(config_key)

def creds_config(self, cleaned_data: dict, extra: dict) -> dict:
"""
Transform form data credentials to config format dict
"""
config = cleaned_data.copy()
config.update(**extra)
return config

def clean(self) -> dict[str, Any]:
cleaned_data = super().clean()
credentials_config = self.creds_config(cleaned_data, {})
if not Channel.get_type_from_code(self.object.channel_type).check_credentials(credentials_config):
updated_config = self.object.config | cleaned_data

if not Channel.get_type_from_code(self.object.channel_type).check_credentials(updated_config):
raise ValidationError(_("Channel credentials don't appear to be valid."))
return cleaned_data

Expand Down

0 comments on commit 1ae190e

Please sign in to comment.