Skip to content

Commit

Permalink
Allow developer replies to activity emails of older versions (#22674)
Browse files Browse the repository at this point in the history
  • Loading branch information
diox authored Sep 17, 2024
1 parent fda8b9a commit 69bf1c8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
8 changes: 1 addition & 7 deletions src/olympia/activity/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,7 @@ def is_expired(self):
return self.use_count >= MAX_TOKEN_USE_COUNT

def is_valid(self):
return (
not self.is_expired()
and self.version
== self.version.addon.find_latest_version(
channel=self.version.channel, exclude=()
)
)
return not self.is_expired() and self.version

def expire(self):
self.update(use_count=MAX_TOKEN_USE_COUNT)
Expand Down
12 changes: 6 additions & 6 deletions src/olympia/activity/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ def test_increment_use(self):
)
assert token_from_db.use_count == 1

def test_validity_version_out_of_date(self):
def test_validity_old_version(self):
version_factory(addon=self.addon, channel=amo.CHANNEL_LISTED)
# The token isn't expired.
# The token isn't expired and is still valid, it's just not for the
# latest version.
assert not self.token.is_expired()
# But is invalid, because the version isn't the latest version.
assert not self.token.is_valid()
assert self.token.is_valid()

def test_validity_still_valid_if_new_version_in_different_channel(self):
version_factory(addon=self.addon, channel=amo.CHANNEL_UNLISTED)
Expand All @@ -89,8 +89,8 @@ def test_validity_still_valid_if_new_version_in_different_channel(self):

# The token isn't expired.
assert not self.token.is_expired()
# It's also still valid, since our version is still the latest listed
# one.
# It's also still valid (the fact that we added a new version in
# another channel doesn't change that).
assert self.token.is_valid()

def test_rejected_version_still_valid(self):
Expand Down
2 changes: 1 addition & 1 deletion src/olympia/activity/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def add_email_to_activity_log(parser):
version.id,
)
reason = (
"it's for an old version of the addon"
"it's for a non-existing version of the addon"
if not token.is_expired()
else 'there have been too many replies'
)
Expand Down

0 comments on commit 69bf1c8

Please sign in to comment.