Esempio n. 1
0
        public NotificationMessageDescription(I18NString Title,
                                              I18NString Description,
                                              NotificationVisibility Visibility,
                                              NotificationMessageType Message)

            : this(Title,
                   Description,
                   Visibility,
                   new NotificationTag[0],
                   new NotificationMessageType[] { Message })

        {
        }
Esempio n. 2
0
        public NotificationMessageDescription(I18NString Title,
                                              I18NString Description,
                                              NotificationVisibility Visibility,
                                              IEnumerable <NotificationTag> Tags,
                                              NotificationMessageType Message)

            : this(Title,
                   Description,
                   Visibility,
                   Tags,
                   new NotificationMessageType[] { Message })

        {
        }
Esempio n. 3
0
        public static Task AddTelegramGroupNotification(this UsersAPI UsersAPI,
                                                        User_Id UserId,
                                                        NotificationMessageType NotificationMessageType,
                                                        String Username,
                                                        Int32?ChatId        = null,
                                                        String SharedSecret = null,
                                                        String TextTemplate = null)

        => UsersAPI.AddNotification(UserId,
                                    new TelegramGroupNotification(Username,
                                                                  ChatId,
                                                                  SharedSecret,
                                                                  TextTemplate),
                                    NotificationMessageType);
Esempio n. 4
0
        /// <summary>
        /// Create a new notification message.
        /// </summary>
        /// <param name="Timestamp">The timestamp of the notification message.</param>
        /// <param name="Type">The message type of the notification message.</param>
        /// <param name="Data">The data of the notification message.</param>
        /// <param name="Owners">The owners of the notification message.</param>
        /// <param name="Signatures">Optional cryptographic signatures of the notification message.</param>
        public NotificationMessage(DateTime Timestamp,
                                   NotificationMessageType Type,
                                   JObject Data,
                                   IEnumerable <Organization_Id> Owners,
                                   IEnumerable <Signature> Signatures = null)

            : this(NotificationMessage_Id.Random(),
                   Timestamp,
                   Type,
                   Data,
                   Owners,
                   Signatures)

        {
        }
Esempio n. 5
0
        public static Task AddEMailNotification(this UsersAPI UsersAPI,
                                                User User,
                                                NotificationMessageType NotificationMessageType,
                                                EMailAddress EMailAddress        = null,
                                                String Subject                   = null,
                                                String SubjectPrefix             = null,
                                                EventTracking_Id EventTrackingId = null,
                                                User_Id?CurrentUserId            = null)

        => UsersAPI.AddNotification(User,
                                    new EMailNotification(EMailAddress ?? User.EMail,
                                                          Subject,
                                                          SubjectPrefix),
                                    NotificationMessageType,
                                    EventTrackingId,
                                    CurrentUserId);
Esempio n. 6
0
        public static Task AddHTTPSNotification(this UsersAPI UsersAPI,
                                                User User,
                                                NotificationMessageType NotificationMessageType,
                                                String URL,
                                                HTTPMethod?Method         = null,
                                                IPPort?TCPPort            = null,
                                                String BasicAuth_Login    = null,
                                                String BasicAuth_Password = null,
                                                String APIKey             = null)

        => UsersAPI.AddNotification(User,
                                    new HTTPSNotification(URL,
                                                          Method,
                                                          TCPPort,
                                                          BasicAuth_Login,
                                                          BasicAuth_Password,
                                                          APIKey),
                                    NotificationMessageType);
Esempio n. 7
0
        public static Task AddTelegramNotification(this UsersAPI UsersAPI,
                                                   User User,
                                                   NotificationMessageType NotificationMessageType,
                                                   String Username,
                                                   Int32?ChatId        = null,
                                                   String SharedSecret = null,
                                                   String TextTemplate = null,
                                                   EventTracking_Id EventTrackingId = null,
                                                   User_Id?CurrentUserId            = null)

        => UsersAPI.AddNotification(User,
                                    new TelegramNotification(Username,
                                                             ChatId,
                                                             SharedSecret,
                                                             TextTemplate),
                                    NotificationMessageType,
                                    EventTrackingId,
                                    CurrentUserId);
Esempio n. 8
0
        public static Task AddSMSNotification(this UsersAPI UsersAPI,
                                              User User,
                                              NotificationMessageType NotificationMessageType,
                                              PhoneNumber?PhoneNumber          = null,
                                              String TextTemplate              = null,
                                              EventTracking_Id EventTrackingId = null,
                                              User_Id?CurrentUserId            = null)
        {
            var phoneNumber = PhoneNumber ?? User.MobilePhone;

            if (!phoneNumber.HasValue || phoneNumber.Value.IsNullOrEmpty)
            {
                throw new ArgumentNullException(nameof(PhoneNumber), "The given mobile phone number must not be null or empty!");
            }

            return(UsersAPI.AddNotification(User,
                                            new SMSNotification(phoneNumber.Value,
                                                                TextTemplate),
                                            NotificationMessageType,
                                            EventTrackingId,
                                            CurrentUserId));
        }
Esempio n. 9
0
        public T Add <T>(T NotificationType,
                         NotificationMessageType NotificationMessageType,
                         Action <T> OnUpdate = null)

            where T : ANotification

        {
            lock (_NotificationTypes)
            {
                var notification = _NotificationTypes.OfType <T>().FirstOrDefault(typeT => typeT.Equals(NotificationType));

                if (notification == null)
                {
                    _NotificationTypes.Add(NotificationType);
                    notification = NotificationType;
                }

                notification.Add(NotificationMessageType,
                                 () => OnUpdate?.Invoke(notification));

                return(notification);
            }
        }
Esempio n. 10
0
        public static Boolean TryParse(JObject JSON, out HTTPSNotification Notification)
        {
            var url = JSON["URL"]?.Value <String>();

            if (JSON["@context"]?.Value <String>() == JSONLDContext &&
                url.IsNotNullOrEmpty())
            {
                Notification = new HTTPSNotification(JSON["URL"]?.Value <String>(),
                                                     JSON["method"] != null ? HTTPMethod.ParseString(JSON["method"].Value <String>()) : HTTPMethod.POST,
                                                     JSON["TCPPort"] != null ? IPPort.Parse(JSON["TCPPort"].Value <String>()) : IPPort.HTTPS,
                                                     JSON["basicAuth"]?["login"]?.Value <String>(),
                                                     JSON["basicAuth"]?["password"]?.Value <String>(),
                                                     JSON["APIKey"]?.Value <String>(),
                                                     JSON["RequestTimeout"] != null ? TimeSpan.FromSeconds((Double)JSON["RequestTimeout"]?.Value <Int32>()) : new TimeSpan?(),
                                                     (JSON["messageTypes"] as JArray)?.SafeSelect(element => NotificationMessageType.Parse(element.Value <String>())),
                                                     JSON["description"]?.Value <String>());

                return(true);
            }

            Notification = null;
            return(false);
        }
Esempio n. 11
0
        public static Boolean TryParse(JObject JSON, out EMailNotification Notification)
        {
            if (JSON["@context"]?.Value <String>() == JSONLDContext &&
                JSON["email"] is JObject EMailJSON &&
                EMailAddress.TryParseJSON(EMailJSON,
                                          out EMailAddress EMail,
                                          out String ErrorResponse,
                                          true))
            {
                Notification = new EMailNotification(EMail,
                                                     JSON["subject"]?.Value <String>(),
                                                     JSON["subjectPrefix"]?.Value <String>(),
                                                     JSON["listId"]?.Value <String>(),
                                                     (JSON["messageTypes"] as JArray)?.SafeSelect(element => NotificationMessageType.Parse(element.Value <String>())),
                                                     JSON["description"]?.Value <String>());

                return(true);
            }

            Notification = null;
            return(false);
        }
Esempio n. 12
0
        public static Boolean TryParse(JObject JSON, out TelegramGroupNotification Notification)
        {
            var GroupName = JSON["groupName"]?.Value <String>();

            if (JSON["@context"]?.Value <String>() == JSONLDContext && GroupName.IsNeitherNullNorEmpty())
            {
                Notification = new TelegramGroupNotification(GroupName,
                                                             JSON["chatId"]?.Value <Int32>(),
                                                             JSON["sharedSecret"]?.Value <String>(),
                                                             JSON["textTemplate"]?.Value <String>(),
                                                             (JSON["messageTypes"] as JArray)?.SafeSelect(element => NotificationMessageType.Parse(element.Value <String>())),
                                                             JSON["description"]?.Value <String>());

                return(true);
            }

            Notification = null;
            return(false);
        }
Esempio n. 13
0
        public static Boolean TryParse(JObject JSON, out SMSNotification Notification)
        {
            if (JSON["@context"]?.Value <String>() == JSONLDContext &&
                PhoneNumber.TryParse(JSON["phoneNumber"]?.Value <String>(), out PhoneNumber phoneNumber))
            {
                Notification = new SMSNotification(PhoneNumber.Parse(JSON["phoneNumber"]?.Value <String>()),
                                                   JSON["textTemplate"]?.Value <String>(),
                                                   (JSON["messageTypes"] as JArray)?.SafeSelect(element => NotificationMessageType.Parse(element.Value <String>())),
                                                   JSON["description"]?.Value <String>());

                return(true);
            }

            Notification = null;
            return(false);
        }