MM-17071 Add mention counting when marking a post as unread (#11966)
* Add different types for different mentions * Remove redundant THREAD_ANY and THREAD_ROOT constants * Make PostStore.Get return thread in order * MM-17071 Add initial version of countMentionsFromPost * MM-17071 Refactor comment mention counting * MM-17071 Use mention counting when marking post as unread * Fix shadowing in tests * Remove repeated check of user count * Refactor code using MentionType * Update comments around -1 return value * Move inner functions out of countMentionsFromPost * Remove preconditions check as separate test case * Update comments * Add User.GetMentionKeys * Revert "Make PostStore.Get return thread in order" This reverts commit 22aa010cee359655fe75e1dc899cf0ffb0943c2a. * Fix tests * Fix merge conflict * Add store.MentionAllPosts
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
5f28ce9de0
Коммит
e6f67c664c
@@ -397,8 +397,7 @@ func (u *User) SetDefaultNotifications() {
|
||||
|
||||
func (user *User) UpdateMentionKeysFromUsername(oldUsername string) {
|
||||
nonUsernameKeys := []string{}
|
||||
splitKeys := strings.Split(user.NotifyProps[MENTION_KEYS_NOTIFY_PROP], ",")
|
||||
for _, key := range splitKeys {
|
||||
for _, key := range user.GetMentionKeys() {
|
||||
if key != oldUsername && key != "@"+oldUsername {
|
||||
nonUsernameKeys = append(nonUsernameKeys, key)
|
||||
}
|
||||
@@ -410,6 +409,22 @@ func (user *User) UpdateMentionKeysFromUsername(oldUsername string) {
|
||||
}
|
||||
}
|
||||
|
||||
func (user *User) GetMentionKeys() []string {
|
||||
var keys []string
|
||||
|
||||
for _, key := range strings.Split(user.NotifyProps[MENTION_KEYS_NOTIFY_PROP], ",") {
|
||||
trimmedKey := strings.TrimSpace(key)
|
||||
|
||||
if trimmedKey == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
keys = append(keys, trimmedKey)
|
||||
}
|
||||
|
||||
return keys
|
||||
}
|
||||
|
||||
func (u *User) Patch(patch *UserPatch) {
|
||||
if patch.Username != nil {
|
||||
u.Username = *patch.Username
|
||||
|
||||
Ссылка в новой задаче
Block a user