Ejemplo n.º 1
0
        public async Task DistributeAsync(Guid notificationId)
        {
            var notificationInfo = await _notificationStore.GetNotificationOrNullAsync(notificationId);

            if (notificationInfo == null)
            {
                Logger.Warn("NotificationDistributionJob can not continue since could not found notification by id: " + notificationId);
                return;
            }

            var users = await GetUsers(notificationInfo);

            var userNotifications = await SaveUserNotifications(users, notificationInfo);

            await _notificationStore.DeleteNotificationAsync(notificationInfo);

            try
            {
                await RealTimeNotifier.SendNotificationsAsync(userNotifications.ToArray());
            }
            catch (Exception ex)
            {
                Logger.Warn(ex.ToString(), ex);
            }
        }
Ejemplo n.º 2
0
        public async Task DistributeAsync(Guid notificationId)
        {
            var notificationInfo = await _notificationStore.GetNotificationOrNullAsync(notificationId);

            if (notificationInfo == null)
            {
                Logger.Warn("NotificationDistributionJob can not continue since could not found notification by id: " + notificationId);
                return;
            }

            var users = await GetUsersAsync(notificationInfo);

            if (users.Any())
            {
                var userNotifications = await SaveUserNotificationsAsync(users, notificationInfo);

                await _notificationStore.DeleteNotificationAsync(notificationInfo);

                await NotifyAsync(userNotifications.ToArray());
            }
            else
            {
                // handle Shesha messages without recipients
                // todo: combine with subscriptions
                var notificationMessages = await SaveUserNotificationMessagesAsync(notificationInfo);
                await NotifyAsync(notificationMessages);
            }
        }
        public async Task DistributeAsync(Guid notificationId)
        {
            var notificationInfo = await _notificationStore.GetNotificationOrNullAsync(notificationId);

            if (notificationInfo == null)
            {
                Logger.Warn("NotificationDistributionJob can not continue since could not found notification by id: " + notificationId);
                return;
            }

            var users = await GetUsersAsync(notificationInfo);

            var userNotifications = await SaveUserNotificationsAsync(users, notificationInfo);

            await _notificationStore.DeleteNotificationAsync(notificationInfo);

            await NotifyAsync(userNotifications.ToArray());
        }