Example #1
0
        //called when the timeout has expired which was waiting for pending changes.
        private static void PostChangesToSlack(IssueDtoEventArgs args, GlobalConfigurationWidgetData <SlackConfigData> data, string channel, DateTime createDate)
        {
            var issueManager = GeminiApp.GetManager <IssueManager>(args.User);
            var userManager  = GeminiApp.GetManager <UserManager>(args.User);
            var userDto      = userManager.Convert(args.User);
            var issue        = issueManager.Get(args.Issue.Id);
            //get the changelog of all changes since the create date (minus a second to avoid missing the initial change)
            var changelog = issueManager.GetChangeLog(issue, userDto, userDto, createDate.AddSeconds(-1));

            changelog.RemoveAll(c => c.Entity.AttributeChanged == ItemAttributeVisibility.AssociatedComments); // No need to show comments in updates as we already do that in the AfterComment event.
            if (changelog.Count == 0)
            {
                return;                   // No changes made!
            }
            var fields = changelog
                         .Select(a => new
            {
                title  = a.Field,
                value  = StripHTML(a.FullChange),
                _short = a.Entity.AttributeChanged != ItemAttributeVisibility.Description && a.Entity.AttributeChanged != ItemAttributeVisibility.AssociatedComments
            });

            QuickSlack.Send(data.Value.SlackAPIEndpoint, channel, string.Format("{0} updated issue <{1}|{2} - {3}>"
                                                                                , args.User.Fullname, args.BuildIssueUrl(args.Issue), args.Issue.IssueKey, args.Issue.Title),
                            "details attached",
                            "good",             //todo colors here based on something
                            fields.ToArray());
        }
Example #2
0
        public override void AfterCreate(IssueEventArgs args)
        {
            var data = GetConfig(args.Context);

            if (data == null || data.Value == null)
            {
                return;
            }

            string channel = GetProjectChannel(args.Entity.ProjectId, data.Value.ProjectChannels);

            if (channel == null || channel.Trim().Length == 0)
            {
                return;
            }

            QuickSlack.Send(data.Value.SlackAPIEndpoint, channel, string.Format("{0} created <{1}|{2} - {3}>"
                                                                                , args.User.Fullname, args.BuildIssueUrl(args.Entity), GetIssueKey(args), args.Entity.Title),
                            "more details attached",
                            "good",
                            new[] { new { title = "Description", value = StripHTML(args.Entity.Description), _short = false } },
                            StripHTML(args.Entity.Description));

            base.AfterCreate(args);
        }
Example #3
0
        public override void AfterComment(IssueCommentEventArgs args)
        {
            var data = GetConfig(args.Context);

            if (data == null || data.Value == null)
            {
                return;
            }

            string channel = GetProjectChannel(args.Issue.Project.Id, data.Value.ProjectChannels);

            if (channel == null || channel.Trim().Length == 0)
            {
                return;
            }

            QuickSlack.Send(data.Value.SlackAPIEndpoint, channel, string.Format("{0} added a comment to <{1}|{2} - {3}>"
                                                                                , args.User.Fullname, args.BuildIssueUrl(args.Issue), args.Issue.IssueKey, args.Issue.Title),
                            "more details attached",
                            "good",
                            new[] { new { title = "Comment", value = StripHTML(args.Entity.Comment), _short = false } }, StripHTML(args.Entity.Comment));

            base.AfterComment(args);
        }