Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions src/sentry/notifications/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,9 @@ def _get_setting_mapping_from_mapping(
for provider in notification_providers()
}

notification_settings_mapping = notification_settings_by_recipient.get(recipient)
if notification_settings_mapping:
specific_scope = get_scope_type(type)
notification_setting_option.update(
notification_settings_mapping.get(specific_scope)
or notification_settings_mapping.get(NotificationScopeType.USER)
or notification_settings_mapping.get(NotificationScopeType.TEAM)
or {}
)
notification_settings_mapping = notification_settings_by_recipient.get(recipient, {})
for scope in [NotificationScopeType.USER, NotificationScopeType.TEAM, get_scope_type(type)]:
notification_setting_option.update(notification_settings_mapping.get(scope, {}))

return notification_setting_option

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,26 @@ def test_get_setting_mapping_from_mapping_slack_always(self):
ExternalProviders.EMAIL: NotificationSettingOptionValues.ALWAYS,
ExternalProviders.SLACK: NotificationSettingOptionValues.ALWAYS,
}

def test_get_setting_mapping_from_mapping_project(self):
notification_settings = {
self.user: {
NotificationScopeType.USER: {
ExternalProviders.EMAIL: NotificationSettingOptionValues.NEVER,
ExternalProviders.SLACK: NotificationSettingOptionValues.ALWAYS,
},
NotificationScopeType.PROJECT: {
ExternalProviders.EMAIL: NotificationSettingOptionValues.NEVER,
},
}
}

mapping = _get_setting_mapping_from_mapping(
notification_settings,
self.user,
NotificationSettingTypes.ISSUE_ALERTS,
)
assert mapping == {
ExternalProviders.EMAIL: NotificationSettingOptionValues.NEVER,
ExternalProviders.SLACK: NotificationSettingOptionValues.ALWAYS,
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ def test_where_should_be_participating(self):
assert providers == [ExternalProviders.EMAIL, ExternalProviders.SLACK]

def test_subscription_null(self):
self.user = User(id=1)
notification_settings = {
self.user: {
NotificationScopeType.USER: {
Expand Down