diff --git a/app/assets/javascripts/admin/models/admin_user.js b/app/assets/javascripts/admin/models/admin_user.js index f27a1abd859..2f5ad951499 100644 --- a/app/assets/javascripts/admin/models/admin_user.js +++ b/app/assets/javascripts/admin/models/admin_user.js @@ -367,30 +367,46 @@ Discourse.AdminUser = Discourse.User.extend({ deleteAsSpammer: function(successCallback) { var user = this; - var message = I18n.t('flagging.delete_confirm', {posts: user.get('post_count'), topics: user.get('topic_count'), email: user.get('email'), ip_address: user.get('ip_address')}); - var buttons = [{ - "label": I18n.t("composer.cancel"), - "class": "cancel-inline", - "link": true - }, { - "label": ' ' + I18n.t("flagging.yes_delete_spammer"), - "class": "btn btn-danger", - "callback": function() { - Discourse.ajax("/admin/users/" + user.get('id') + '.json', { - type: 'DELETE', - data: {delete_posts: true, block_email: true, block_urls: true, block_ip: true, context: window.location.pathname} - }).then(function(data) { - if (data.deleted) { - if (successCallback) successCallback(); - } else { + + user.checkEmail().then(function() { + var data = { + posts: user.get('post_count'), + topics: user.get('topic_count'), + email: user.get('email') || I18n.t("flagging.hidden_email_address"), + ip_address: user.get('ip_address') || I18n.t("flagging.ip_address_missing") + }; + var message = I18n.t('flagging.delete_confirm', data); + var buttons = [{ + "label": I18n.t("composer.cancel"), + "class": "cancel-inline", + "link": true + }, { + "label": ' ' + I18n.t("flagging.yes_delete_spammer"), + "class": "btn btn-danger", + "callback": function() { + Discourse.ajax("/admin/users/" + user.get('id') + '.json', { + type: 'DELETE', + data: { + delete_posts: true, + block_email: true, + block_urls: true, + block_ip: true, + context: window.location.pathname + } + }).then(function(result) { + if (result.deleted) { + if (successCallback) successCallback(); + } else { + bootbox.alert(I18n.t("admin.user.delete_failed")); + } + }, function() { bootbox.alert(I18n.t("admin.user.delete_failed")); - } - }, function() { - bootbox.alert(I18n.t("admin.user.delete_failed")); - }); - } - }]; - bootbox.dialog(message, buttons, {"classes": "flagging-delete-spammer"}); + }); + } + }]; + bootbox.dialog(message, buttons, {"classes": "flagging-delete-spammer"}); + }); + }, loadDetails: function() { diff --git a/app/assets/javascripts/discourse/models/user.js b/app/assets/javascripts/discourse/models/user.js index 68af6279940..c628a759105 100644 --- a/app/assets/javascripts/discourse/models/user.js +++ b/app/assets/javascripts/discourse/models/user.js @@ -416,15 +416,14 @@ Discourse.User = Discourse.Model.extend({ return Discourse.ajax("/users/" + this.get("username_lower") + "/emails.json", { type: "PUT", data: { context: window.location.pathname } - }) - .then(function (result) { + }).then(function (result) { if (result) { self.setProperties({ email: result.email, associated_accounts: result.associated_accounts }); } - }); + }, function () {}); } }); diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 4ce2aacf416..754421fa984 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -1309,6 +1309,8 @@ en: delete_spammer: "Delete Spammer" delete_confirm: "You are about to delete %{posts} posts and %{topics} topics from this user, remove their account, block signups from their IP address %{ip_address}, and add their email address %{email} to a permanent block list. Are you sure this user is really a spammer?" yes_delete_spammer: "Yes, Delete Spammer" + ip_address_missing: "(N/A)" + hidden_email_address: "(hidden)" submit_tooltip: "Submit the private flag" take_action_tooltip: "Reach the flag threshold immediately, rather than waiting for more community flags" cant: "Sorry, you can't flag this post at this time."