forked from mirrors/bookwyrm
Merge pull request #457 from mouse-reeve/post-error
Fixes server error posting status
This commit is contained in:
commit
a0ffac8a78
3 changed files with 11 additions and 6 deletions
|
@ -41,6 +41,9 @@ def handle_remote_webfinger(query):
|
||||||
user = None
|
user = None
|
||||||
|
|
||||||
# usernames could be @user@domain or user@domain
|
# usernames could be @user@domain or user@domain
|
||||||
|
if not query:
|
||||||
|
return None
|
||||||
|
|
||||||
if query[0] == '@':
|
if query[0] == '@':
|
||||||
query = query[1:]
|
query = query[1:]
|
||||||
|
|
||||||
|
@ -218,7 +221,7 @@ def handle_status(user, form):
|
||||||
|
|
||||||
# inspect the text for user tags
|
# inspect the text for user tags
|
||||||
matches = []
|
matches = []
|
||||||
for match in re.finditer(regex.username, status.content):
|
for match in re.finditer(regex.strict_username, status.content):
|
||||||
username = match.group().strip().split('@')[1:]
|
username = match.group().strip().split('@')[1:]
|
||||||
if len(username) == 1:
|
if len(username) == 1:
|
||||||
# this looks like a local user (@user), fill in the domain
|
# this looks like a local user (@user), fill in the domain
|
||||||
|
|
|
@ -2,5 +2,7 @@
|
||||||
|
|
||||||
domain = r'[a-z-A-Z0-9_\-]+\.[a-z]+'
|
domain = r'[a-z-A-Z0-9_\-]+\.[a-z]+'
|
||||||
localname = r'@?[a-zA-Z_\-\.0-9]+'
|
localname = r'@?[a-zA-Z_\-\.0-9]+'
|
||||||
|
strict_localname = r'@[a-zA-Z_\-\.0-9]+'
|
||||||
username = r'%s(@%s)?' % (localname, domain)
|
username = r'%s(@%s)?' % (localname, domain)
|
||||||
|
strict_username = r'%s(@%s)?' % (strict_localname, domain)
|
||||||
full_username = r'%s@%s' % (localname, domain)
|
full_username = r'%s@%s' % (localname, domain)
|
||||||
|
|
|
@ -593,14 +593,14 @@ def tag(request):
|
||||||
def untag(request):
|
def untag(request):
|
||||||
''' untag a book '''
|
''' untag a book '''
|
||||||
name = request.POST.get('name')
|
name = request.POST.get('name')
|
||||||
tag = get_object_or_404(models.Tag, name=name)
|
tag_obj = get_object_or_404(models.Tag, name=name)
|
||||||
book_id = request.POST.get('book')
|
book_id = request.POST.get('book')
|
||||||
book = get_object_or_404(models.Edition, id=book_id)
|
book = get_object_or_404(models.Edition, id=book_id)
|
||||||
|
|
||||||
tag = get_object_or_404(
|
user_tag = get_object_or_404(
|
||||||
models.UserTag, tag=tag, book=book, user=request.user)
|
models.UserTag, tag=tag_obj, book=book, user=request.user)
|
||||||
tag_activity = tag.to_remove_activity(request.user)
|
tag_activity = user_tag.to_remove_activity(request.user)
|
||||||
tag.delete()
|
user_tag.delete()
|
||||||
|
|
||||||
broadcast(request.user, tag_activity)
|
broadcast(request.user, tag_activity)
|
||||||
return redirect('/book/%s' % book_id)
|
return redirect('/book/%s' % book_id)
|
||||||
|
|
Loading…
Reference in a new issue