summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
Diffstat (limited to 'models')
-rw-r--r--models/user.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/models/user.go b/models/user.go
index 3131a88d55..750f59e5c4 100644
--- a/models/user.go
+++ b/models/user.go
@@ -373,6 +373,15 @@ func (u *User) DisplayName() string {
return u.Name
}
+// ShortName returns shorted user name with given maximum length,
+// it adds "..." at the end if user name has more length than maximum.
+func (u *User) ShortName(length int) string {
+ if len(u.Name) < length {
+ return u.Name
+ }
+ return u.Name[:length] + "..."
+}
+
// IsUserExist checks if given user name exist,
// the user name should be noncased unique.
// If uid is presented, then check will rule out that one,