server/events/events.js
// Sends one notification about every event scheduled during the current day. Only sends notif if event starts, ends, or bridges today.
Sends one notification about every event scheduled during the current day. Only sends notif if event starts, ends, or bridges today.
Sends one notification about every event scheduled during the current day . Only sends notif if event starts ends or bridges today .
function sendUpcomingEventNotifications() {
    helper.getAllFutureEvents(function (events) {
        if (events) {
            events.forEach(function (event) {
                var eventStartDate = moment(event.start_date, 'yyyy.MM.ddTHH:mm:ss.SSSZ');
                var eventEndDate = moment(event.end_date, 'yyyy.MM.ddTHH:mm:ss.SSSZ');
                if (eventStartDate.isSame(moment(), 'd') || eventEndDate.isSame(moment(), 'd') || (eventStartDate.isBefore(moment(), 'd') && eventEndDate.isAfter(moment(), 'd'))) {
                    var notificationText = 'Event: ' + event.event_name + ' is happening today.';
                    helper.findAllClients(function (clients) {
                        if (clients) {
                            clients.forEach(function (client) {
                                if (client.push_token) {
                                    notifications.sendNotification([client.push_token], notificationText, true);
                                }
                            });
                        }
                    });
                }
            });
        }
    });
}
function sendUpcomingEventNotifications ( ) { helper . getAllFutureEvents ( function ( events ) { if ( events ) { events . forEach ( function ( event ) { var eventStartDate = moment ( event . start_date , 'yyyy.MM.ddTHH:mm:ss.SSSZ' ) ; var eventEndDate = moment ( event . end_date , 'yyyy.MM.ddTHH:mm:ss.SSSZ' ) ; if ( eventStartDate . isSame ( moment ( ) , 'd' ) || eventEndDate . isSame ( moment ( ) , 'd' ) || ( eventStartDate . isBefore ( moment ( ) , 'd' ) && eventEndDate . isAfter ( moment ( ) , 'd' ) ) ) { var notificationText = 'Event: ' + event . event_name + ' is happening today.' ; helper . findAllClients ( function ( clients ) { if ( clients ) { clients . forEach ( function ( client ) { if ( client . push_token ) { notifications . sendNotification ( [ client . push_token ] , notificationText , true ) ; } } ) ; } } ) ; } } ) ; } } ) ; }
Sends one notification about every event scheduled during the current day.
Sends one notification about every event scheduled during the current day .