Skip to content

A platform for community discussion. Free, open, simple.

FEATURE: suppress duplicate username/names containing .

Sam458b9c3a6298
diff --git a/app/assets/javascripts/discourse/lib/plugin-api.js.es6 b/app/assets/javascripts/discourse/lib/plugin-api.js.es6
index 4f5c0a021df..44b14378600 100644
--- a/app/assets/javascripts/discourse/lib/plugin-api.js.es6
+++ b/app/assets/javascripts/discourse/lib/plugin-api.js.es6
@@ -24,9 +24,10 @@ import { replaceFormatter } from 'discourse/lib/utilities';
import { modifySelectKit } from "select-kit/mixins/plugin-api";
import { addGTMPageChangedCallback } from 'discourse/lib/page-tracker';
import { registerCustomAvatarHelper } from 'discourse/helpers/user-avatar';
+import { disableNameSuppression } from 'discourse/widgets/poster-name';
// If you add any methods to the API ensure you bump up this number
-const PLUGIN_API_VERSION = '0.8.19';
+const PLUGIN_API_VERSION = '0.8.20';
class PluginApi {
constructor(version, container) {
@@ -387,6 +388,16 @@ class PluginApi {
registerCustomAvatarHelper(fn);
}
+ /**
+ * Allows you to disable suppression of similar username / names on posts
+ * If a user has the username bob.bob and the name Bob Bob, one of the two
+ * will be suppressed depending on prioritize_username_in_ux.
+ * This allows you to override core behavior
+ **/
+ disableNameSuppressionOnPosts() {
+ disableNameSuppression();
+ }
+
/**
* Changes a setting associated with a widget. For example, if
* you wanted small avatars in the post stream:
diff --git a/app/assets/javascripts/discourse/widgets/poster-name.js.es6 b/app/assets/javascripts/discourse/widgets/poster-name.js.es6
index 3fc5c0ee2af..41eeb1a4f8b 100644
--- a/app/assets/javascripts/discourse/widgets/poster-name.js.es6
+++ b/app/assets/javascripts/discourse/widgets/poster-name.js.es6
@@ -3,8 +3,12 @@ import { createWidget } from 'discourse/widgets/widget';
import { h } from 'virtual-dom';
import { formatUsername } from 'discourse/lib/utilities';
-function sanitizeName(name){
- return name.toLowerCase().replace(/[\s_-]/g,'');
+let sanitizeName = function(name){
+ return name.toLowerCase().replace(/[\s\._-]/g,'');
+};
+
+export function disableNameSuppression() {
+ sanitizeName = name => name;
}
createWidget('poster-name-title', {