1
- const Device = require ( '../../model/device' ) ;
2
-
3
- const logger = require ( 'log4js' ) . getLogger ( 'peterparker' ) ;
4
-
5
1
const utils = require ( '../../controllers/utils/utils' ) ;
6
2
7
3
const constants = require ( '../../config/constants' ) ;
8
4
9
5
const CandidatesHelper = require ( '../../controllers/candidates/candidatesHelper' ) ;
10
6
11
- const pushSender = require ( './push-sender' ) ;
12
-
13
- const i18n = require ( "i18n" ) ;
14
-
15
7
const Q = require ( 'q' ) ;
16
8
17
9
const _ = require ( 'underscore' ) ;
18
10
19
11
module . exports = {
20
- findCandidates : findCandidates ,
21
- sendPushNotification : sendPushNotification
12
+ findCandidates : findCandidates
22
13
} ;
23
14
24
15
function findCandidates ( item , ageMin , ageMax , lastLoginInDays ) {
@@ -87,36 +78,3 @@ function findCandidates(item, ageMin, ageMax, lastLoginInDays) {
87
78
88
79
return deferred . promise ;
89
80
}
90
-
91
- function sendPushNotification ( user , labelKey ) {
92
- Device . findDevice ( user . _id ) . then ( function ( device ) {
93
- if ( utils . isNotNull ( device ) && ! utils . isStringEmpty ( device . tokenId ) ) {
94
- processNofication ( user , device , labelKey ) ;
95
- }
96
- } , function ( error ) {
97
- logger . info ( 'error' , 'Error while looking for device informations.' ) ;
98
- } ) ;
99
- }
100
-
101
- function processNofication ( user , device , labelKey ) {
102
-
103
- if ( utils . isNotNull ( user . userParams ) && utils . isNotNull ( user . userParams . appSettings ) && user . userParams . appSettings . pushNotifications ) {
104
-
105
- const msgText = getPushNotificationText ( user , device , labelKey ) ;
106
-
107
- pushSender . pushNotification ( msgText , device ) . then ( function ( data ) {
108
- // Coolio all right here
109
- } , function ( error ) {
110
- logger . info ( 'error' , 'Error while pushing the notification to the client. ' + JSON . stringify ( error ) ) ;
111
- } ) ;
112
- } else {
113
- // Means user don't want to receive push notifications
114
- }
115
- }
116
-
117
- function getPushNotificationText ( user , device , labelKey ) {
118
-
119
- const language = ! utils . isStringEmpty ( device . language ) ? device . language : 'en' ;
120
-
121
- return i18n . __ ( { phrase : labelKey , locale : language } , { who : user . facebook . firstName } ) ;
122
- }
0 commit comments