server/routes/sockets.js
// Generates and sends notification about the new message to all users subscribed to the given tag.
Generates and sends notification about the new message to all users subscribed to the given tag.
Generates and sends notification about the new message to all users subscribed to the given tag .
function sendNotificationToAllSubscribers(tagName, messageBodyDictionary, username) {
    var notificationText = '';
    var messageText = messageBodyDictionary['pure_message']['text'];
    if (messageText) {
        notificationText = username + ' to ' + tagName + ': ' + messageText;
    } else if (messageBodyDictionary['photo_message']) {
        notificationText = username + ' sent a photo.';
    } else if (messageBodyDictionary['video_message']) {
        notificationText = username + ' sent a video.';
    } else {
        return; 
    }
    helper.findAllSubscribedUsersByTagName(tagName, function (users) { 
        if (users) {
            users.forEach(function (user) {
                helper.findClientsByUserID(user.user_id, function (clients) {
                    if (clients) {
                        clients.forEach(function (client) {
                            if (client.push_token) {
                                notifications.sendNotification([client.push_token], notificationText, true);
                            }
                        });
                    }
                });
            });
        }
    });
}
function sendNotificationToAllSubscribers ( tagName , messageBodyDictionary , username ) { var notificationText = '' ; var messageText = messageBodyDictionary [ 'pure_message' ] [ 'text' ] ; if ( messageText ) { notificationText = username + ' to ' + tagName + ': ' + messageText ; } else if ( messageBodyDictionary [ 'photo_message' ] ) { notificationText = username + ' sent a photo.' ; } else if ( messageBodyDictionary [ 'video_message' ] ) { notificationText = username + ' sent a video.' ; } else { return ; } helper . findAllSubscribedUsersByTagName ( tagName , function ( users ) { if ( users ) { users . forEach ( function ( user ) { helper . findClientsByUserID ( user . user_id , function ( clients ) { if ( clients ) { clients . forEach ( function ( client ) { if ( client . push_token ) { notifications . sendNotification ( [ client . push_token ] , notificationText , true ) ; } } ) ; } } ) ; } ) ; } } ) ; }
Generates and sends notification about the new message to all users subscribed to the given tag.
Generates and sends notification about the new message to all users subscribed to the given tag .
//don't send message bc issue creating it //send remote notifications