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
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,9 @@ def _unsubscribe_issues(team: Team, member: OrganizationMember) -> None:
"""
Unsubscribe user from issues the team is subscribed to
"""
# A pending invite has no subscriptions, and user_id=None would match the team's own.
if member.user_id is None:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we just require_user in the delete func?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah this is member, not request user, so it can't just check the require_user

return
team_assigned_groups = GroupAssignee.objects.filter(team_id=team.id).values_list(
"group_id", flat=True
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,26 @@ def test_cannot_leave_idp_provisioned_team(self) -> None:
team=idp_team, organizationmember=member
).exists()

def test_removing_pending_invite_keeps_team_subscriptions(self) -> None:
invite = self.create_member(
organization=self.org, email="invited@example.com", role="member", teams=[self.team]
)
group = self.create_group()
GroupAssignee.objects.create(group=group, team=self.team, project=group.project)
GroupSubscription.objects.create(
group=group,
project=group.project,
team=self.team,
reason=GroupSubscriptionReason.assigned,
)

self.login_as(self.user)
self.get_success_response(
self.org.slug, invite.id, self.team.slug, status_code=status.HTTP_200_OK
)

assert GroupSubscription.objects.filter(group=group, team=self.team).exists()

def test_unsubscribe_user_from_team_issues_legacy(self) -> None:
"""
We have some legacy DB rows from before the GroupSubscription table had a team_id
Expand Down
Loading