Beispiel #1
0
        public void Notify(NotifierData data)
        {
            var identity = GetSettingsIdentity(data);

            var settings = _notificationSettingsService.Get <EmailNotifierTemplate>(identity);

            if (!settings.IsEnabled)
            {
                return;
            }
            var receivers = _intranetMemberService.GetMany(data.ReceiverIds).ToList();

            foreach (var receiverId in data.ReceiverIds)
            {
                var user = receivers.Find(receiver => receiver.Id == receiverId);

                var message = _notificationModelMapper.Map(data.Value, settings.Template, user);
                _mailService.Send(message);

                _notificationRepository.Add(new Sql.Notification()
                {
                    Id           = Guid.NewGuid(),
                    Date         = DateTime.UtcNow,
                    IsNotified   = true,
                    IsViewed     = false,
                    Type         = data.NotificationType.ToInt(),
                    NotifierType = NotifierTypeEnum.EmailNotifier.ToInt(),
                    Value        = new { message }.ToJson(),
                    ReceiverId   = receiverId
                });
            }
        }
        public void Notify(NotifierData data)
        {
            var isCommunicationSettings = data.NotificationType.In(
                NotificationTypeEnum.CommentLikeAdded,
                NotificationTypeEnum.MonthlyMail); //TODO: temporary for communication settings

            var identity = new ActivityEventIdentity(isCommunicationSettings
                    ? CommunicationTypeEnum.CommunicationSettings
                    : data.ActivityType, data.NotificationType)
                           .AddNotifierIdentity(Type);

            var settings = _notificationSettingsService.Get <EmailNotifierTemplate>(identity);

            if (settings == null || !settings.IsEnabled)
            {
                return;
            }
            var receivers = _intranetUserService.GetMany(data.ReceiverIds).ToList();

            foreach (var receiverId in data.ReceiverIds)
            {
                var user = receivers.Find(receiver => receiver.Id == receiverId);

                var message = _notificationModelMapper.Map(data.Value, settings.Template, user);
                _mailService.Send(message);
            }
        }
Beispiel #3
0
        public void Notify(NotifierData data)
        {
            var isCommunicationSettings = data.NotificationType.In(
                NotificationTypeEnum.CommentLikeAdded,
                NotificationTypeEnum.MonthlyMail) || //TODO: temporary for communication settings
                                          data.ActivityType.In(
                IntranetActivityTypeEnum.ContentPage,
                IntranetActivityTypeEnum.PagePromotion);

            var identity = new ActivityEventIdentity(isCommunicationSettings
                    ? CommunicationTypeEnum.CommunicationSettings
                    : data.ActivityType, data.NotificationType)
                           .AddNotifierIdentity(Type);

            var settings = _notificationSettingsService.Get <UiNotifierTemplate>(identity);

            if (settings == null || !settings.IsEnabled)
            {
                return;
            }
            var receivers = _intranetUserService.GetMany(data.ReceiverIds);

            var messages = receivers.Select(r => _notificationModelMapper.Map(data.Value, settings.Template, r));

            _notificationsService.Notify(messages);
        }
        public void Notify(NotifierData data)
        {
            var identity = new ActivityEventIdentity(CommunicationTypeEnum.Member, data.NotificationType)
                           .AddNotifierIdentity(Type);
            var settings = _notificationSettingsService.Get <PopupNotifierTemplate>(identity);

            if (settings == null || !settings.IsEnabled)
            {
                return;
            }
            var receivers = _intranetMemberService.GetMany(data.ReceiverIds);

            var messages = receivers.Select(r => _notificationModelMapper.Map(data.Value, settings.Template, r));

            _notificationsService.Notify(messages);
        }
        public void Notify(NotifierData data)
        {
            var isCommunicationSettings = data.NotificationType.In(
                NotificationTypeEnum.CommentLikeAdded,
                NotificationTypeEnum.MonthlyMail,
                IntranetActivityTypeEnum.ContentPage);

            var identity = new ActivityEventIdentity(isCommunicationSettings
                    ? CommunicationTypeEnum.CommunicationSettings
                    : data.ActivityType, data.NotificationType)
                           .AddNotifierIdentity(Type);
            var settings = _notificationSettingsService.Get <UiNotifierTemplate>(identity);

            var desktopSettingsIdentity = new ActivityEventIdentity(settings.ActivityType, settings.NotificationType)
                                          .AddNotifierIdentity(NotifierTypeEnum.DesktopNotifier);
            var desktopSettings = _notificationSettingsService.Get <DesktopNotifierTemplate>(desktopSettingsIdentity);

            if (!settings.IsEnabled && !desktopSettings.IsEnabled)
            {
                return;
            }

            var receivers = _intranetMemberService.GetMany(data.ReceiverIds).ToList();

            var messages = receivers.Select(receiver =>
            {
                var uiMsg = _notificationModelMapper.Map(data.Value, settings.Template, receiver);
                if (desktopSettings.IsEnabled)
                {
                    var desktopMsg       = _desktopNotificationModelMapper.Map(data.Value, desktopSettings.Template, receiver);
                    uiMsg.DesktopTitle   = desktopMsg.Title;
                    uiMsg.DesktopMessage = desktopMsg.Message;
                    uiMsg.IsDesktopNotificationEnabled = true;
                    if (uiMsg.NotifierId.HasValue)
                    {
                        uiMsg.NotifierPhotoUrl = _intranetMemberService.Get(uiMsg.NotifierId.Value)?.Photo;
                    }
                }
                return(uiMsg);
            });

            _notificationsService.Notify(messages);
        }
Beispiel #6
0
        internal UiNotificationMessage GetUiNotificationMessage(
            Guid receiverId,
            Enum activityType,
            Enum notificationType,
            INotifierDataValue newValue)
        {
            var notificationIdentity = new ActivityEventNotifierIdentity(activityType, notificationType, UiNotifierType);
            var template             = _notificationSettingsService.Get <UiNotifierTemplate>(notificationIdentity).Template;
            var receiver             = _intranetMemberService.Get(receiverId);
            var message = _notificationModelMapper.Map(newValue, template, receiver);

            return(message);
        }
Beispiel #7
0
 protected override MailBase GetMonthlyMailModel(IIntranetMember receiver, MonthlyMailDataModel dataModel, EmailNotifierTemplate template) =>
 _notificationModelMapper.Map(dataModel, template, receiver);