@@ -22,7 +22,7 @@ class UserService {
22
22
23
23
static transactional = true
24
24
25
- def authService, messageSource, grailsApplication
25
+ def authService, queryService, messageSource, grailsApplication
26
26
27
27
def siteLocale = new Locale.Builder (). setLanguageTag(Holders . config. siteDefaultLanguage as String ). build()
28
28
@@ -37,9 +37,15 @@ class UserService {
37
37
def enabledQueries = notificationInstanceList. collect { it. query }
38
38
def enabledIds = enabledQueries. collect { it. id }
39
39
40
- // all standard queries
40
+ // all standard queries + 'my annotations' queries
41
+ // this might include 'my annotations' that belongs to others
42
+ // we need to filter those out
41
43
def allAlertTypes = Query . findAllByCustom(false )
42
44
45
+ def myAnnotationQuery = queryService. createMyAnnotationQuery(user. getUserId())
46
+ // collect standard queries + 'my annotations' belongs to current user
47
+ allAlertTypes = allAlertTypes. findAll { it. name != myAnnotationQuery. name || it. queryPath == myAnnotationQuery. queryPath }
48
+
43
49
allAlertTypes. removeAll { enabledIds. contains(it. id) }
44
50
def customQueries = enabledQueries. findAll { it. custom }
45
51
def standardQueries = enabledQueries. findAll { ! it. custom }
@@ -51,10 +57,8 @@ class UserService {
51
57
user : user]
52
58
53
59
if (grailsApplication. config. getProperty(' myannotation.enabled' , Boolean , false )) {
54
- def myannotationName = messageSource. getMessage(" query.myannotations.title" , null , siteLocale)
55
- def myannotation = userConfig. enabledQueries. findAll { it. name == myannotationName }
56
- userConfig. enabledQueries. removeAll { it. name == myannotationName }
57
- userConfig. myannotation = myannotation
60
+ userConfig. myannotation = userConfig. enabledQueries. findAll { it. name == myAnnotationQuery. name }
61
+ userConfig. enabledQueries. removeAll { it. name == myAnnotationQuery. name }
58
62
}
59
63
60
64
userConfig
0 commit comments