Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 25 additions & 9 deletions AzureDevopsTracker/Integrations/MicrosoftTeamsIntegration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,24 @@ internal class Section
}


internal static class MicrosoftTeamsStrings
internal static class MicrosoftTeamsStatics
{
internal static string Type = "MessageCard";
internal static string Context = "http://schema.org/extensions";
internal static string ThemeColor = "7bd1d7";
internal static readonly string Type = "MessageCard";
internal static readonly string Context = "http://schema.org/extensions";
internal static readonly string ThemeColor = "7bd1d7";
internal static readonly int TEXT_SIZE_TO_BREAK_LINE = 100;
internal static readonly int OPENING_DIV_SIZE = 5;
internal static readonly int CLOSING_DIV_SIZE = 6;
}

internal override void Send(ChangeLog changeLog)
{
var values = new MicrosoftTeamsMessage()
{
type = MicrosoftTeamsStrings.Type,
context = MicrosoftTeamsStrings.Context,
themeColor = MicrosoftTeamsStrings.ThemeColor,
summary = GetTitle(),
type = MicrosoftTeamsStatics.Type,
context = MicrosoftTeamsStatics.Context,
themeColor = MicrosoftTeamsStatics.ThemeColor,
summary = GetTitle(changeLog),
sections = new Section[1]
{
new Section()
Expand Down Expand Up @@ -92,7 +95,20 @@ private string GetWorkItemsDescriptionSection(string sectionName, IEnumerable<Ch

private string GetWorkItemDescriptionLine(ChangeLogItem workItem)
{
return $"<br><em>{ workItem.WorkItemId }</em> - { workItem.Description }";
var description = GetDescription(workItem.Description);
var descriptionLine = $"<em>**{ workItem.WorkItemId }**</em> - { description }";
if (description.Length > MicrosoftTeamsStatics.TEXT_SIZE_TO_BREAK_LINE)
return $"<br>{ descriptionLine }<br>";
return descriptionLine;
}

private string GetDescription(string description)
{
if (description.StartsWith("<div>"))
description = description[MicrosoftTeamsStatics.OPENING_DIV_SIZE..];
if(description.EndsWith("</div>"))
description = description[0..^MicrosoftTeamsStatics.CLOSING_DIV_SIZE];
return description;
}

private string GetFooter()
Expand Down