FEATURE: suppress duplicate username/names containing .

- Adds official API to disable suppression if needed
This commit is contained in:
Sam 2018-04-27 11:41:16 +10:00
parent 64f1480cc0
commit 458b9c3a62
2 changed files with 18 additions and 3 deletions

View File

@ -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:

View File

@ -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', {