|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
3 | | -from typing import Callable, List, Mapping, MutableMapping, Optional, Sequence, Tuple |
| 3 | +from typing import Callable, List, Mapping, MutableMapping, Optional, Tuple |
4 | 4 |
|
5 | 5 | from django.db import router, transaction |
6 | | -from django.db.models import Q, QuerySet |
| 6 | +from django.db.models import QuerySet |
7 | 7 |
|
8 | 8 | from sentry.api.serializers.base import Serializer |
9 | 9 | from sentry.api.serializers.models.notification_setting import NotificationSettingsSerializer |
10 | 10 | from sentry.models.notificationsetting import NotificationSetting |
11 | 11 | from sentry.models.notificationsettingoption import NotificationSettingOption |
12 | 12 | from sentry.models.notificationsettingprovider import NotificationSettingProvider |
13 | 13 | from sentry.models.user import User |
14 | | -from sentry.notifications.helpers import get_scope_type |
15 | 14 | from sentry.notifications.notificationcontroller import NotificationController |
16 | 15 | from sentry.notifications.types import ( |
17 | 16 | NotificationScopeEnum, |
18 | | - NotificationScopeType, |
19 | 17 | NotificationSettingEnum, |
20 | 18 | NotificationSettingOptionValues, |
21 | 19 | NotificationSettingsOptionEnum, |
@@ -112,73 +110,6 @@ def update_notification_options( |
112 | 110 | **kwargs, |
113 | 111 | ) |
114 | 112 |
|
115 | | - # TODO(snigdha): This can be removed in V2. |
116 | | - def get_settings_for_users( |
117 | | - self, |
118 | | - *, |
119 | | - types: List[NotificationSettingTypes], |
120 | | - users: List[RpcUser], |
121 | | - value: NotificationSettingOptionValues, |
122 | | - ) -> List[RpcNotificationSetting]: |
123 | | - settings = NotificationSetting.objects.filter( |
124 | | - user_id__in=[u.id for u in users], |
125 | | - type__in=types, |
126 | | - value=value.value, |
127 | | - scope_type=NotificationScopeType.USER.value, |
128 | | - ) |
129 | | - return [serialize_notification_setting(u) for u in settings] |
130 | | - |
131 | | - def get_settings_for_recipient_by_parent( |
132 | | - self, *, type: NotificationSettingTypes, parent_id: int, recipients: Sequence[RpcActor] |
133 | | - ) -> List[RpcNotificationSetting]: |
134 | | - team_ids = [r.id for r in recipients if r.actor_type == ActorType.TEAM] |
135 | | - user_ids = [r.id for r in recipients if r.actor_type == ActorType.USER] |
136 | | - |
137 | | - parent_specific_scope_type = get_scope_type(type) |
138 | | - notification_settings = NotificationSetting.objects.filter( |
139 | | - Q( |
140 | | - scope_type=parent_specific_scope_type.value, |
141 | | - scope_identifier=parent_id, |
142 | | - ) |
143 | | - | Q( |
144 | | - scope_type=NotificationScopeType.USER.value, |
145 | | - scope_identifier__in=user_ids, |
146 | | - ) |
147 | | - | Q( |
148 | | - scope_type=NotificationScopeType.TEAM.value, |
149 | | - scope_identifier__in=team_ids, |
150 | | - ), |
151 | | - (Q(team_id__in=team_ids) | Q(user_id__in=user_ids)), |
152 | | - type=type.value, |
153 | | - ) |
154 | | - |
155 | | - return [serialize_notification_setting(s) for s in notification_settings] |
156 | | - |
157 | | - def get_settings_for_user_by_projects( |
158 | | - self, *, type: NotificationSettingTypes, user_id: int, parent_ids: List[int] |
159 | | - ) -> List[RpcNotificationSetting]: |
160 | | - try: |
161 | | - User.objects.get(id=user_id) |
162 | | - except User.DoesNotExist: |
163 | | - return [] |
164 | | - |
165 | | - scope_type = get_scope_type(type) |
166 | | - return [ |
167 | | - serialize_notification_setting(s) |
168 | | - for s in NotificationSetting.objects.filter( |
169 | | - Q( |
170 | | - scope_type=scope_type.value, |
171 | | - scope_identifier__in=parent_ids, |
172 | | - ) |
173 | | - | Q( |
174 | | - scope_type=NotificationScopeType.USER.value, |
175 | | - scope_identifier=user_id, |
176 | | - ), |
177 | | - type=type.value, |
178 | | - user_id=user_id, |
179 | | - ) |
180 | | - ] |
181 | | - |
182 | 113 | def remove_notification_settings( |
183 | 114 | self, *, team_id: Optional[int], user_id: Optional[int], provider: ExternalProviders |
184 | 115 | ) -> None: |
|
0 commit comments