@@ -57,8 +57,11 @@ getSettings.schema = {
57
57
* @param {Number } userId the user id
58
58
*/
59
59
function * saveNotificationSetting ( entry , userId ) {
60
- const setting = yield models . NotificationSetting . findOne ( { where : {
61
- userId, topic : entry . topic , serviceId : entry . serviceId , name : entry . name } } ) ;
60
+ const setting = yield models . NotificationSetting . findOne ( {
61
+ where : {
62
+ userId, topic : entry . topic , serviceId : entry . serviceId , name : entry . name
63
+ }
64
+ } ) ;
62
65
if ( setting ) {
63
66
setting . value = entry . value ;
64
67
yield setting . save ( ) ;
@@ -79,8 +82,11 @@ function* saveNotificationSetting(entry, userId) {
79
82
* @param {Number } userId the user id
80
83
*/
81
84
function * saveServiceSetting ( entry , userId ) {
82
- const setting = yield models . ServiceSettings . findOne ( { where : {
83
- userId, serviceId : entry . serviceId , name : entry . name } } ) ;
85
+ const setting = yield models . ServiceSettings . findOne ( {
86
+ where : {
87
+ userId, serviceId : entry . serviceId , name : entry . name
88
+ }
89
+ } ) ;
84
90
if ( setting ) {
85
91
setting . value = entry . value ;
86
92
yield setting . save ( ) ;
@@ -181,12 +187,21 @@ function* listNotifications(query, userId) {
181
187
const notificationSettings = settings . notifications ;
182
188
const limit = query . limit || query . per_page ;
183
189
const offset = ( query . page - 1 ) * limit ;
184
- const filter = { where : {
185
- userId,
186
- } , offset, limit, order : [ [ 'createdAt' , 'DESC' ] ] } ;
187
- if ( query . platform ) {
188
- filter . where . type = { $like : `notifications\.${ query . platform } \.%` } ;
190
+ const filter = {
191
+ where : {
192
+ userId,
193
+ } , offset, limit, order : [ [ 'createdAt' , 'DESC' ] ]
194
+ } ;
195
+
196
+ switch ( query . platform ) {
197
+ case 'connect' :
198
+ filter . where . type = { $like : 'connect.notification.%' } ;
199
+ break ;
200
+ case 'community' :
201
+ filter . where . type = { $notLike : 'connect.notification.%' } ;
202
+ break ;
189
203
}
204
+
190
205
if ( _ . keys ( notificationSettings ) . length > 0 ) {
191
206
// only filter out notifications types which were explicitly set to 'no' - so we return notification by default
192
207
const notifications = _ . keys ( notificationSettings ) . filter ( ( notificationType ) =>
0 commit comments