Пример #1
0
        public async Task DistributeAsync(UserEventMessage userEvent)
        {
            using (Telemetry.Activities.StartActivity("HandleUserEvent"))
            {
                try
                {
                    var user = await userStore.GetCachedAsync(userEvent.AppId, userEvent.UserId);

                    if (user == null)
                    {
                        throw new DomainException(Texts.Notification_NoUser);
                    }

                    var dueTime = Scheduling.CalculateScheduleTime(userEvent.Scheduling, clock, user.PreferredTimezone);

                    await userEventQueue.ScheduleAsync(ScheduleKey(userEvent), userEvent, dueTime, true);
                }
                catch (DomainException ex)
                {
                    await logStore.LogAsync(userEvent.AppId, ex.Message);

                    await userNotificationsStore.TrackFailedAsync(userEvent);
                }
            }
        }