MCPcopy Create free account
hub / github.com/gogs/gogs / updateIssueMentions

Function updateIssueMentions

internal/database/issue.go:1158–1197  ·  view source on GitHub ↗

updateIssueMentions extracts mentioned people from content and updates issue-user relations for them.

(e Engine, issueID int64, mentions []string)

Source from the content-addressed store, hash-verified

1156// updateIssueMentions extracts mentioned people from content and
1157// updates issue-user relations for them.
1158func updateIssueMentions(e Engine, issueID int64, mentions []string) error {
1159 if len(mentions) == 0 {
1160 return nil
1161 }
1162
1163 for i := range mentions {
1164 mentions[i] = strings.ToLower(mentions[i])
1165 }
1166 users := make([]*User, 0, len(mentions))
1167
1168 if err := e.In("lower_name", mentions).Asc("lower_name").Find(&users); err != nil {
1169 return errors.Newf("find mentioned users: %v", err)
1170 }
1171
1172 ids := make([]int64, 0, len(mentions))
1173 for _, user := range users {
1174 ids = append(ids, user.ID)
1175 if !user.IsOrganization() || user.NumMembers == 0 {
1176 continue
1177 }
1178
1179 memberIDs := make([]int64, 0, user.NumMembers)
1180 orgUsers, err := getOrgUsersByOrgID(e, user.ID, 0)
1181 if err != nil {
1182 return errors.Newf("getOrgUsersByOrgID [%d]: %v", user.ID, err)
1183 }
1184
1185 for _, orgUser := range orgUsers {
1186 memberIDs = append(memberIDs, orgUser.ID)
1187 }
1188
1189 ids = append(ids, memberIDs...)
1190 }
1191
1192 if err := updateIssueUsersByMentions(e, issueID, ids); err != nil {
1193 return errors.Newf("UpdateIssueUsersByMentions: %v", err)
1194 }
1195
1196 return nil
1197}
1198
1199// IssueStats represents issue statistic information.
1200type IssueStats struct {

Callers 2

mailParticipantsMethod · 0.85
MailParticipantsMethod · 0.85

Calls 6

appendFunction · 0.85
getOrgUsersByOrgIDFunction · 0.85
InMethod · 0.80
IsOrganizationMethod · 0.80
FindMethod · 0.65

Tested by

no test coverage detected