Esempio n. 1
0
        public static void Notify(
            IRestApi restApi,
            string owner,
            string message,
            BotConfiguration.Notifier notificationConfig,
            bool bIsSuccessfulMerge)
        {
            if (notificationConfig == null)
            {
                return;
            }

            if (bIsSuccessfulMerge && !notificationConfig.HasToNofifyOnSuccessfulTryMerge)
            {
                return;
            }

            string headingMessage = string.IsNullOrEmpty(notificationConfig.IntroMessage) ?
                                    string.Empty : notificationConfig.IntroMessage;

            string trailingMessage = (string.IsNullOrEmpty(notificationConfig.TrailingMessage) || bIsSuccessfulMerge) ?
                                     string.Empty : TransformMessage(notificationConfig.TrailingMessage);

            string messageWithIntro = string.Format(
                "{0}{1}{1}{2}{1}{1}{3}",
                headingMessage,
                System.Environment.NewLine,
                message,
                trailingMessage);

            List <string> recipients = new List <string>();

            recipients.Add(owner);
            recipients.AddRange(notificationConfig.FixedRecipients);

            restApi.Notify(
                notificationConfig.PlugName,
                messageWithIntro,
                Profile.ResolveUserField(
                    restApi, recipients, notificationConfig.UserProfileField));
        }