Skip to content

Commit 2ec620b

Browse files
Improve format in Microsoft Teams Integration
1 parent a76c710 commit 2ec620b

File tree

1 file changed

+25
-15
lines changed

1 file changed

+25
-15
lines changed

AzureDevopsTracker/Integrations/MicrosoftTeamsIntegration.cs

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,23 @@ 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
{
40-
//Formatar o texto com o MicrosoftTeamsHelper
41-
4243
var values = new MicrosoftTeamsMessage()
4344
{
44-
type = MicrosoftTeamsStrings.Type,
45-
context = MicrosoftTeamsStrings.Context,
46-
themeColor = MicrosoftTeamsStrings.ThemeColor,
45+
type = MicrosoftTeamsStatics.Type,
46+
context = MicrosoftTeamsStatics.Context,
47+
themeColor = MicrosoftTeamsStatics.ThemeColor,
4748
summary = GetTitle(changeLog),
4849
sections = new Section[1]
4950
{
@@ -58,11 +59,7 @@ internal override void Send(ChangeLog changeLog)
5859
}
5960
};
6061

61-
var response = Notify(values);
62-
63-
//Seta o retorno no ChangeLog
64-
65-
//Retorna o ChangeLog
62+
Notify(values);
6663
}
6764

6865
private string GetText(ChangeLog changeLog)
@@ -98,7 +95,20 @@ private string GetWorkItemsDescriptionSection(string sectionName, IEnumerable<Ch
9895

9996
private string GetWorkItemDescriptionLine(ChangeLogItem workItem)
10097
{
101-
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;
102112
}
103113

104114
private string GetFooter()

0 commit comments

Comments
 (0)