Skip to content

Commit

Permalink
Show message for password protected blogs (#200)
Browse files Browse the repository at this point in the history
  • Loading branch information
syeopite committed Feb 26, 2025
2 parents c3a62a9 + b86b73b commit e7e0731
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions locales/en_US/LC_MESSAGES/priviblur.po
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ msgstr "Unable to find the requested blog"
msgid "tumblr_error_blog_not_found_error_description"
msgstr "The blog may have been deleted or just never existed in the first place"

msgid "tumblr_error_blog_requires_password_error_heading"
msgstr "This blog requires a password to access"

msgid "priviblur_error_page_title"
msgstr "Error"

Expand Down
14 changes: 14 additions & 0 deletions src/exceptions/error_handlers/extractor_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@ async def tumblr_error_login_walled(request, exception):
)


@extractor_errors.register(priviblur_exceptions.TumblrPasswordRequiredBlogError)
async def tumblr_password_required_blog(request, exception):
return await request.app.ctx.render(
"misc/msg_error",
context={
"app": request.app,
"exception": exception,
"error_heading": request.app.ctx.translate(request.ctx.language, "tumblr_error_blog_requires_password_error_heading"),
"error_description": request.app.ctx.translate(request.ctx.language, "tumblr_error_blog_login_required_error_description"),
},
status=403
)


@extractor_errors.register(priviblur_exceptions.TumblrRestrictedTagError)
async def tumblr_error_restricted_tag(request, exception):
return await request.app.ctx.render(
Expand Down
2 changes: 2 additions & 0 deletions src/priviblur_extractor/api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ def _format(obj): return obj
raise exceptions.TumblrRestrictedTagError(message, code, details, internal_code)
case 4012:
raise exceptions.TumblrLoginRequiredError(message, code, details, internal_code)
case 4013:
raise exceptions.TumblrPasswordRequiredBlogError(message, code, details, internal_code)
case 0:
raise exceptions.TumblrBlogNotFoundError(message, code, details, internal_code)
case _:
Expand Down
5 changes: 5 additions & 0 deletions src/priviblur_extractor/helpers/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ class TumblrLoginRequiredError(TumblrErrorResponse):
pass


class TumblrPasswordRequiredBlogError(TumblrErrorResponse):
pass


class TumblrNon200NorJSONResponse(Exception):
def __init__(self, status_code):
self.status_code = status_code


0 comments on commit e7e0731

Please sign in to comment.