diff --git a/src/olympia/activity/models.py b/src/olympia/activity/models.py index af14b4b82cb7..149f7c2afc4e 100644 --- a/src/olympia/activity/models.py +++ b/src/olympia/activity/models.py @@ -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) diff --git a/src/olympia/activity/tests/test_models.py b/src/olympia/activity/tests/test_models.py index 8e32b2f05265..1c9e6f56699f 100644 --- a/src/olympia/activity/tests/test_models.py +++ b/src/olympia/activity/tests/test_models.py @@ -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) @@ -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): diff --git a/src/olympia/activity/utils.py b/src/olympia/activity/utils.py index 0306a36a4da6..db71dd457ca8 100644 --- a/src/olympia/activity/utils.py +++ b/src/olympia/activity/utils.py @@ -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' )