Skip to content

Add @active_subscription_required decorator and start using it (#347)#1069

Open
markstos wants to merge 2 commits into
mainfrom
issue-347-subscription-required
Open

Add @active_subscription_required decorator and start using it (#347)#1069
markstos wants to merge 2 commits into
mainfrom
issue-347-subscription-required

Conversation

@markstos

@markstos markstos commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Updates one location to use it as example. This commit is not trying
to refactor every potential use of the decorator.

Why?

This addresses several Sentry exceptions. It's good for DRY and consistency with @login_required.

Limitations and Notes

  • Initial scope does not refactor every potential case that could use it.

Applicable Issues

QA Log

  • Confirmed there was already relevant test coverage for the refactored route, thus the code is already tested by existing test coverage.

Questions

Should the scope be expanded to refactor more locations in this PR or continue that work in a follow-up PR?

Updates one location to use it as example. This commit is not trying
to refactor every potential use of the decorator.
@markstos markstos requested a review from MelissaAutumn July 6, 2026 21:48

@MelissaAutumn MelissaAutumn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Perf, thanks! I added a couple of sentry issues to this ticket so let's sprinkle it around the application in this PR.

Off the top of my head almost everything in main.views with login_required needs it.

Comment thread src/thunderbird_accounts/subscription/decorators.py Outdated
#347)

Also: Conditionally reply with JSON vs HTML based the request.

Adds missing authorization tests for related locations. Because this is refactor
test coverage would not normally be needed, but a number of locations were missing
a check to confirm if 403 would be returned without an active subscription.
@markstos markstos changed the title Add @active_subscription_required decorator and use in place. (#347) Add @active_subscription_required decorator and start using it (#347) Jul 6, 2026
@markstos

markstos commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

I've pushed a commit with the expanded scope requests to address HTML vs H JSON responses and broadly implementing the new decorator.

As mentioned in Sentry, the CalDav case turned out to use token auth not the usual auth, so the decorator did not apply there and it was removed from the scope.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants