In some circumstances, when a user subscribed to a list before creating
an account for the same email address, it can be impossible for the user
to unsubscribe from a list, because the unsubscribe code path only
checks for subscriptions for the user's ID, not the user's email.
This commit makes the unsubscribe code path look for subscriptions for
the user's email as well, if none were found for the ID. While this does
not fix the root cause (doing so is a bit more involved), it does allow
users who are in this situation to successfully unsubscribe.
---
listssrht/process.py | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/listssrht/process.py b/listssrht/process.py
index 2e877dd..64bd2fa 100644
--- a/listssrht/process.py
+++ b/listssrht/process.py
@@ -472,6 +472,10 @@ def _unsubscribe(dest, mail):
sub = Subscription.query.filter(
Subscription.list_id == dest.id,
Subscription.user_id == user.id).one_or_none()
+ if sub is None:
+ sub = Subscription.query.filter(
+ Subscription.list_id == dest.id,
+ Subscription.email == user.email).one_or_none()
else:
sub = Subscription.query.filter(
Subscription.list_id == dest.id,
--
2.45.2