Added updating of username based mentions on username change
Этот коммит содержится в:
@@ -5,6 +5,7 @@ package store
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
"github.com/mattermost/platform/model"
|
"github.com/mattermost/platform/model"
|
||||||
"github.com/mattermost/platform/utils"
|
"github.com/mattermost/platform/utils"
|
||||||
)
|
)
|
||||||
@@ -163,6 +164,17 @@ func (us SqlUserStore) Update(user *model.User, allowActiveUpdate bool) StoreCha
|
|||||||
user.EmailVerified = false
|
user.EmailVerified = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if user.Username != oldUser.Username {
|
||||||
|
nonUsernameKeys := []string{}
|
||||||
|
splitKeys := strings.Split(user.NotifyProps["mention_keys"], ",")
|
||||||
|
for _, key := range splitKeys {
|
||||||
|
if key != oldUser.Username && key != "@" + oldUser.Username {
|
||||||
|
nonUsernameKeys = append(nonUsernameKeys, key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
user.NotifyProps["mention_keys"] = strings.Join(nonUsernameKeys, ",") + user.Username + ",@" + user.Username
|
||||||
|
}
|
||||||
|
|
||||||
if count, err := us.GetMaster().Update(user); err != nil {
|
if count, err := us.GetMaster().Update(user); err != nil {
|
||||||
if IsUniqueConstraintError(err.Error(), "Email", "users_email_teamid_key") {
|
if IsUniqueConstraintError(err.Error(), "Email", "users_email_teamid_key") {
|
||||||
result.Err = model.NewAppError("SqlUserStore.Update", "This email is already taken. Please choose another", "user_id="+user.Id+", "+err.Error())
|
result.Err = model.NewAppError("SqlUserStore.Update", "This email is already taken. Please choose another", "user_id="+user.Id+", "+err.Error())
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user