summaryrefslogtreecommitdiffstats
path: root/models/user.go
diff options
context:
space:
mode:
authorJustin Nuß <nuss.justin@gmail.com>2014-07-24 19:15:31 +0200
committerJustin Nuß <nuss.justin@gmail.com>2014-07-24 19:15:31 +0200
commitcbcd08aa17e95a72dcb294da836aa7f2b966d5c0 (patch)
tree493ed45a00f259fd662702589d58e56dcf723527 /models/user.go
parent3db84c889365a559a6ea81ad4e7dd4a5f089d249 (diff)
downloadgitea-cbcd08aa17e95a72dcb294da836aa7f2b966d5c0.tar.gz
gitea-cbcd08aa17e95a72dcb294da836aa7f2b966d5c0.zip
Mention organisation users when organisation gets mentioned
Diffstat (limited to 'models/user.go')
-rw-r--r--models/user.go42
1 files changed, 42 insertions, 0 deletions
diff --git a/models/user.go b/models/user.go
index a46232427e..581fce23a4 100644
--- a/models/user.go
+++ b/models/user.go
@@ -562,3 +562,45 @@ func UnFollowUser(userId int64, unFollowId int64) (err error) {
}
return session.Commit()
}
+
+func UpdateMentions(userNames []string, issueId int64) error {
+ users := make([]*User, 0, len(userNames))
+
+ if err := x.Where("name IN (?)", strings.Join(userNames, "\",\"")).OrderBy("name ASC").Find(&users); err != nil {
+ return err
+ }
+
+ ids := make([]int64, 0, len(userNames))
+
+ for _, user := range users {
+ ids = append(ids, user.Id)
+
+ if user.Type == INDIVIDUAL {
+ continue
+ }
+
+ if user.NumMembers == 0 {
+ continue
+ }
+
+ tempIds := make([]int64, 0, user.NumMembers)
+
+ orgUsers, err := GetOrgUsersByOrgId(user.Id)
+
+ if err != nil {
+ return err
+ }
+
+ for _, orgUser := range orgUsers {
+ tempIds = append(tempIds, orgUser.Id)
+ }
+
+ ids = append(ids, tempIds...)
+ }
+
+ if err := UpdateIssueUserPairsByMentions(ids, issueId); err != nil {
+ return err
+ }
+
+ return nil
+}