Skip to content

Commit 5c3c5a3

Browse files
committed
Merge branch 'feature/83' of github.com:typinghard/azure-devops-state-tracker into 5.0.1-rc
2 parents 5b4d03d + 2ec620b commit 5c3c5a3

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

AzureDevopsTracker/Integrations/MicrosoftTeamsIntegration.cs

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,24 @@ internal class Section
2828
}
2929

3030

31-
internal static class MicrosoftTeamsStrings
31+
internal static class MicrosoftTeamsStatics
3232
{
33-
internal static string Type = "MessageCard";
34-
internal static string Context = "http://schema.org/extensions";
35-
internal static string ThemeColor = "7bd1d7";
33+
internal static readonly string Type = "MessageCard";
34+
internal static readonly string Context = "http://schema.org/extensions";
35+
internal static readonly string ThemeColor = "7bd1d7";
36+
internal static readonly int TEXT_SIZE_TO_BREAK_LINE = 100;
37+
internal static readonly int OPENING_DIV_SIZE = 5;
38+
internal static readonly int CLOSING_DIV_SIZE = 6;
3639
}
3740

3841
internal override void Send(ChangeLog changeLog)
3942
{
4043
var values = new MicrosoftTeamsMessage()
4144
{
42-
type = MicrosoftTeamsStrings.Type,
43-
context = MicrosoftTeamsStrings.Context,
44-
themeColor = MicrosoftTeamsStrings.ThemeColor,
45-
summary = GetTitle(),
45+
type = MicrosoftTeamsStatics.Type,
46+
context = MicrosoftTeamsStatics.Context,
47+
themeColor = MicrosoftTeamsStatics.ThemeColor,
48+
summary = GetTitle(changeLog),
4649
sections = new Section[1]
4750
{
4851
new Section()
@@ -92,7 +95,20 @@ private string GetWorkItemsDescriptionSection(string sectionName, IEnumerable<Ch
9295

9396
private string GetWorkItemDescriptionLine(ChangeLogItem workItem)
9497
{
95-
return $"<br><em>{ workItem.WorkItemId }</em> - { workItem.Description }";
98+
var description = GetDescription(workItem.Description);
99+
var descriptionLine = $"<em>**{ workItem.WorkItemId }**</em> - { description }";
100+
if (description.Length > MicrosoftTeamsStatics.TEXT_SIZE_TO_BREAK_LINE)
101+
return $"<br>{ descriptionLine }<br>";
102+
return descriptionLine;
103+
}
104+
105+
private string GetDescription(string description)
106+
{
107+
if (description.StartsWith("<div>"))
108+
description = description[MicrosoftTeamsStatics.OPENING_DIV_SIZE..];
109+
if(description.EndsWith("</div>"))
110+
description = description[0..^MicrosoftTeamsStatics.CLOSING_DIV_SIZE];
111+
return description;
96112
}
97113

98114
private string GetFooter()

0 commit comments

Comments
 (0)