diff --git a/app/assets/v2/js/status.js b/app/assets/v2/js/status.js index 1644ddb4645..26050a921d1 100644 --- a/app/assets/v2/js/status.js +++ b/app/assets/v2/js/status.js @@ -428,6 +428,10 @@ $(document).ready(function() { return; } + if (!document.contxt.github_handle) { + return; + } + if (typeof ga !== 'undefined') { ga('send', 'event', 'Submit Status Update', 'click', 'Person'); } @@ -501,7 +505,7 @@ $(document).ready(function() { localStorage.setItem(lskey, the_message); _alert( { message: gettext('An error occurred. Please try again.') }, - 'error' + 'danger' ); }; @@ -547,7 +551,7 @@ $(document).ready(function() { } else { _alert( { message: gettext('An error occurred. Please try again.') }, - 'error' + 'danger' ); } }).catch(err => fail_callback()); diff --git a/app/retail/views.py b/app/retail/views.py index 5fd9e8d181a..f0e01395fd5 100644 --- a/app/retail/views.py +++ b/app/retail/views.py @@ -908,7 +908,12 @@ def create_status_update(request): issue_re = re.compile(r'^(?:https?://)?(?:github\.com)/(?:[\w,\-,\_]+)/(?:[\w,\-,\_]+)/issues/(?:[\d]+)') response = {} - if request.POST: + if request.POST and request.user.is_authenticated: + if (request.user.profile.is_blocked or request.user.profile.shadowbanned): + response['status'] = 400 + response['message'] = 'Status updated!' + return JsonResponse(response, status=400) + profile = request.user.profile title = request.POST.get('data') resource = request.POST.get('resource', '') @@ -919,12 +924,6 @@ def create_status_update(request): attach_token_name = request.POST.get('attachTokenName', '') tx_id = request.POST.get('attachTxId', '') - if request.user.is_authenticated and (request.user.profile.is_blocked or request.user.profile.shadowbanned): - response['status'] = 200 - response['message'] = 'Status updated!' - return JsonResponse(response, status=400) - - kwargs = { 'activity_type': 'status_update', 'metadata': { @@ -1015,6 +1014,11 @@ def create_status_update(request): response['message'] = 'Bad Request' logger.error('Status Update error - Error: (%s) - Handle: (%s)', e, profile.handle if profile else '') return JsonResponse(response, status=400) + else: + response['status'] = 401 + response['message'] = 'Not logged in!' + return JsonResponse(status=response['status'], data={'status': 401,'message':response['message']}) + return JsonResponse(response)