summaryrefslogtreecommitdiffstats
path: root/model/post.go
diff options
context:
space:
mode:
authorJesse Hallam <jesse.hallam@gmail.com>2018-06-26 16:46:58 -0400
committerJoram Wilander <jwawilander@gmail.com>2018-06-26 16:46:57 -0400
commit2d7cd02abcd62ffd60fe3c6e16e5189169de349e (patch)
tree93fde76e72e39577ffb70a6ff0922e5a81ffc973 /model/post.go
parent164e030d33b03cab347ddcdf064615cb9e144317 (diff)
downloadchat-2d7cd02abcd62ffd60fe3c6e16e5189169de349e.tar.gz
chat-2d7cd02abcd62ffd60fe3c6e16e5189169de349e.tar.bz2
chat-2d7cd02abcd62ffd60fe3c6e16e5189169de349e.zip
MM-10833: send down computed channel props (#8953)
* MM-10833: send down computed channel props This allows channel headers to reference channel mentions for a client that doesn't already know about the channels in question. We intentionally don't send down the props for the autocomplete and search endpoints since they aren't used in that context, and would add unnecessary overhead. * update channel props on patch * revert to treating channel purpose as plaintext
Diffstat (limited to 'model/post.go')
-rw-r--r--model/post.go17
1 files changed, 2 insertions, 15 deletions
diff --git a/model/post.go b/model/post.go
index 3d7a31ab5..1dd0a4db6 100644
--- a/model/post.go
+++ b/model/post.go
@@ -7,7 +7,6 @@ import (
"encoding/json"
"io"
"net/http"
- "regexp"
"sort"
"strings"
"unicode/utf8"
@@ -343,20 +342,8 @@ func PostPatchFromJson(data io.Reader) *PostPatch {
return &post
}
-var channelMentionRegexp = regexp.MustCompile(`\B~[a-zA-Z0-9\-_]+`)
-
-func (o *Post) ChannelMentions() (names []string) {
- if strings.Contains(o.Message, "~") {
- alreadyMentioned := make(map[string]bool)
- for _, match := range channelMentionRegexp.FindAllString(o.Message, -1) {
- name := match[1:]
- if !alreadyMentioned[name] {
- names = append(names, name)
- alreadyMentioned[name] = true
- }
- }
- }
- return
+func (o *Post) ChannelMentions() []string {
+ return ChannelMentions(o.Message)
}
func (r *PostActionIntegrationRequest) ToJson() string {