summaryrefslogtreecommitdiffstats
path: root/model/user.go
diff options
context:
space:
mode:
authorhmhealey <harrisonmhealey@gmail.com>2015-07-13 17:47:57 -0400
committerhmhealey <harrisonmhealey@gmail.com>2015-07-17 15:22:57 -0400
commit098cbcdc21effeebe7e57fbd912a785e85cbfc5d (patch)
treefca1c712fe315ed49058de974b21efdaa0dd5b9c /model/user.go
parentabcb44089c421872de582584049ca4cc6b268f37 (diff)
downloadchat-098cbcdc21effeebe7e57fbd912a785e85cbfc5d.tar.gz
chat-098cbcdc21effeebe7e57fbd912a785e85cbfc5d.tar.bz2
chat-098cbcdc21effeebe7e57fbd912a785e85cbfc5d.zip
Unify all locations where we determine a user's display named based off of their nickname/username into a helper function
Diffstat (limited to 'model/user.go')
-rw-r--r--model/user.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/model/user.go b/model/user.go
index 5422f68a5..5b603cd92 100644
--- a/model/user.go
+++ b/model/user.go
@@ -237,6 +237,14 @@ func (u *User) AddNotifyProp(key string, value string) {
u.NotifyProps[key] = value
}
+func (u *User) GetDisplayName() string {
+ if u.Nickname != "" {
+ return u.Nickname
+ } else {
+ return u.Username
+ }
+}
+
// UserFromJson will decode the input and return a User
func UserFromJson(data io.Reader) *User {
decoder := json.NewDecoder(data)