Skip to content
Draft
Changes from 1 commit
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
16 changes: 13 additions & 3 deletions app/models/subscription.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,23 @@ def name
end
end

def creator_no_longer_associated_with?(creation)
return false unless subscribable_type == "User"

# If any of the creation's pseud's users matches the subscribable, then the
# creator still matches, so we return "true"
return false if creation.pseuds.any? { |p| p.user == subscribable }

# We reach this case if e.g. someone is subscribed to a user, but they
# orphan the work before the subscription notification would be sent
return true
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's possible we may also reach this check if:

  1. A and B have a work together
  2. User subscribes to A
  3. B posts a new chapter to the work, without listing A as co-creator for the chapter

The Jira issue for https://otwarchive.atlassian.net/browse/AO3-5696 suggests this behavior is not desired, so I need to do more testing/checking here to see what the behavior is in practice


# Guard against scenarios that may break anonymity or other things.
# Emails should only contain works or chapters.
# Emails should only contain posted works or chapters.
# Emails should never contain chapters of draft works.
# Emails should never contain hidden works or chapters of hidden works.
# Emails should never contain orphaned works or chapters.
# TODO: AO3-3620 & AO3-5696: Allow subscriptions to orphan_account to receive notifications.
# Emails should not contain orphaned works or chapters if the subscription is to a creator no longer associated with the work
# Emails for user subs should never contain anon works or chapters.
# Emails for work subs should never contain anything but chapters.
# TODO: AO3-1250: Anon series subscription improvements
Expand All @@ -52,7 +62,7 @@ def valid_notification_entry?(creation)
return false unless creation.try(:posted)
return false if creation.is_a?(Chapter) && !creation.work.try(:posted)
return false if creation.try(:hidden_by_admin) || (creation.is_a?(Chapter) && creation.work.try(:hidden_by_admin))
return false if creation.pseuds.any? { |p| p.user == User.orphan_account }
return false if creator_no_longer_associated_with?(creation)
return false if subscribable_type == "User" && creation.anonymous?
return false if subscribable_type == "Work" && !creation.is_a?(Chapter)

Expand Down
Loading