コード例 #1
0
        private async Task ExecuteAsync(NotificationDistributionJobArgs args)
        {
            var notification = await _notificationStore.GetNotificationOrNullAsync(args.NotificationId);

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

            long[] userIds;
            if (notification.UserIds.IsNullOrEmpty())
            {
                userIds = await _notificationStore.GetSubscribedUserIdsAsync(notification);
            }
            else
            {
                userIds = notification.UserIds.Split(",").Select(uidAsStr => Convert.ToInt64(uidAsStr)).ToArray();
            }

            var userNotifications = userIds.Select(userId => new UserNotificationInfo(userId, notification.Id)).ToList();

            await SaveUserNotifications(userNotifications);

            await _realTimeNotifier.SendNotificationAsync(notification, userNotifications);
        }