@@ -57,8 +57,11 @@ getSettings.schema = {
5757 * @param {Number } userId the user id
5858 */
5959function * 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+ } ) ;
6265 if ( setting ) {
6366 setting . value = entry . value ;
6467 yield setting . save ( ) ;
@@ -79,8 +82,11 @@ function* saveNotificationSetting(entry, userId) {
7982 * @param {Number } userId the user id
8083 */
8184function * 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+ } ) ;
8490 if ( setting ) {
8591 setting . value = entry . value ;
8692 yield setting . save ( ) ;
@@ -181,12 +187,21 @@ function* listNotifications(query, userId) {
181187 const notificationSettings = settings . notifications ;
182188 const limit = query . limit || query . per_page ;
183189 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 ;
189203 }
204+
190205 if ( _ . keys ( notificationSettings ) . length > 0 ) {
191206 // only filter out notifications types which were explicitly set to 'no' - so we return notification by default
192207 const notifications = _ . keys ( notificationSettings ) . filter ( ( notificationType ) =>
0 commit comments