Catch MastodonNotFoundErrors that were not being caught

This will cause a much more sensible error message in the case of
trying to reply to or view the thread of deleted messages
This commit is contained in:
Jason McBrayer 2020-03-10 18:38:03 -04:00
parent 72c7bbcc3d
commit 2354dadddb

View File

@ -673,9 +673,9 @@ def note(request, next=None, prev=None):
@br_login_required @br_login_required
def thread(request, id): def thread(request, id):
account, mastodon = get_usercontext(request) account, mastodon = get_usercontext(request)
try:
toot = mastodon.status(id) toot = mastodon.status(id)
root = toot root = toot
try:
context = mastodon.status_context(id) context = mastodon.status_context(id)
if context.ancestors and len(context.ancestors) > 0: if context.ancestors and len(context.ancestors) > 0:
root = context.ancestors[0] root = context.ancestors[0]
@ -1049,8 +1049,11 @@ def safe_get_attachment(toot, index):
def reply(request, id): def reply(request, id):
if request.method == "GET": if request.method == "GET":
account, mastodon = get_usercontext(request) account, mastodon = get_usercontext(request)
try:
toot = mastodon.status(id) toot = mastodon.status(id)
context = mastodon.status_context(id) context = mastodon.status_context(id)
except MastodonNotFoundError:
raise Http404(_("Thread not found; the message may have been deleted."))
notifications = _notes_count(account, mastodon) notifications = _notes_count(account, mastodon)
if toot.account.acct != request.session["active_user"].acct: if toot.account.acct != request.session["active_user"].acct:
initial_text = "@" + toot.account.acct + " " initial_text = "@" + toot.account.acct + " "