MM-32133 shared channel username collisions (#17347)
Support for handling username collisions between remote clusters. Users belonging to remote clusters have their username changed to include the remote name e.g. wiggin becomes wiggin:mattermost. @mentions are also modified so the munged username is replaced with the original username when the post is sync'd with the remote the user belongs to. When adding remote users: - append the remote name to the username with colon separator - append the remote name to the email address with colon separator - store the original username and email address in user props - when resolving @mentions replace with the stored original username
Этот коммит содержится в:
@@ -211,26 +211,30 @@ func TestUserGetDisplayNameWithPrefix(t *testing.T) {
|
||||
assert.Equal(t, user.GetDisplayNameWithPrefix(SHOW_NICKNAME_FULLNAME, "@"), "nickname", "Display name should be nickname")
|
||||
}
|
||||
|
||||
var usernames = []struct {
|
||||
value string
|
||||
expected bool
|
||||
}{
|
||||
{"spin-punch", true},
|
||||
{"sp", true},
|
||||
{"s", true},
|
||||
{"1spin-punch", true},
|
||||
{"-spin-punch", true},
|
||||
{".spin-punch", true},
|
||||
{"Spin-punch", false},
|
||||
{"spin punch-", false},
|
||||
{"spin_punch", true},
|
||||
{"spin", true},
|
||||
{"PUNCH", false},
|
||||
{"spin.punch", true},
|
||||
{"spin'punch", false},
|
||||
{"spin*punch", false},
|
||||
{"all", false},
|
||||
{"system", false},
|
||||
type usernamesTest struct {
|
||||
value string
|
||||
expected bool
|
||||
expectedWhenRemote bool
|
||||
}
|
||||
|
||||
var usernames = []usernamesTest{
|
||||
{"spin-punch", true, true},
|
||||
{"sp", true, true},
|
||||
{"s", true, true},
|
||||
{"1spin-punch", true, true},
|
||||
{"-spin-punch", true, true},
|
||||
{".spin-punch", true, true},
|
||||
{"Spin-punch", false, false},
|
||||
{"spin punch-", false, false},
|
||||
{"spin_punch", true, true},
|
||||
{"spin", true, true},
|
||||
{"PUNCH", false, false},
|
||||
{"spin.punch", true, true},
|
||||
{"spin'punch", false, false},
|
||||
{"spin*punch", false, false},
|
||||
{"all", false, false},
|
||||
{"system", false, false},
|
||||
{"spin:punch", false, true},
|
||||
}
|
||||
|
||||
func TestValidUsername(t *testing.T) {
|
||||
@@ -239,6 +243,11 @@ func TestValidUsername(t *testing.T) {
|
||||
t.Errorf("expect %v as %v", v.value, v.expected)
|
||||
}
|
||||
}
|
||||
for _, v := range usernames {
|
||||
if IsValidUsernameAllowRemote(v.value) != v.expectedWhenRemote {
|
||||
t.Errorf("expect %v as %v", v.value, v.expectedWhenRemote)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestNormalizeUsername(t *testing.T) {
|
||||
|
||||
Ссылка в новой задаче
Block a user