From 4d526ad32ff50c01ae9741c72f39a5cf74a58512 Mon Sep 17 00:00:00 2001
From: Macintosh II <95250141+mctaylors@users.noreply.github.com>
Date: Thu, 12 Oct 2023 13:56:24 +0300
Subject: [PATCH] Sanitize scheduled event names (#159)

In this PR, I added `Markdown.Sanitize` for every `scheduledEvent.Name`
and `eventData.Name`. That means, every title in scheduled event embeds
will be sanitized.

I did that because in scheduled event list event title displays only as
sanitized string.

Signed-off-by: Macintosh II <mctaylxrs@outlook.com>
---
 src/Services/Update/ScheduledEventUpdateService.cs | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/Services/Update/ScheduledEventUpdateService.cs b/src/Services/Update/ScheduledEventUpdateService.cs
index ee2c982..7653d2b 100644
--- a/src/Services/Update/ScheduledEventUpdateService.cs
+++ b/src/Services/Update/ScheduledEventUpdateService.cs
@@ -200,7 +200,7 @@ public sealed class ScheduledEventUpdateService : BackgroundService
 
         var embed = new EmbedBuilder()
             .WithSmallTitle(string.Format(Messages.EventCreatedTitle, creator.GetTag()), creator)
-            .WithTitle(scheduledEvent.Name)
+            .WithTitle(Markdown.Sanitize(scheduledEvent.Name))
             .WithDescription(embedDescription)
             .WithEventCover(scheduledEvent.ID, scheduledEvent.Image)
             .WithCurrentTimestamp()
@@ -296,7 +296,7 @@ public sealed class ScheduledEventUpdateService : BackgroundService
             return Result.FromError(embedDescriptionResult);
         }
 
-        var startedEmbed = new EmbedBuilder().WithTitle(string.Format(Messages.EventStarted, scheduledEvent.Name))
+        var startedEmbed = new EmbedBuilder().WithTitle(string.Format(Messages.EventStarted, Markdown.Sanitize(scheduledEvent.Name)))
             .WithDescription(embedDescription)
             .WithColour(ColorsList.Green)
             .WithCurrentTimestamp()
@@ -321,7 +321,7 @@ public sealed class ScheduledEventUpdateService : BackgroundService
             return Result.FromSuccess();
         }
 
-        var completedEmbed = new EmbedBuilder().WithTitle(string.Format(Messages.EventCompleted, eventData.Name))
+        var completedEmbed = new EmbedBuilder().WithTitle(string.Format(Messages.EventCompleted, Markdown.Sanitize(eventData.Name)))
             .WithDescription(
                 string.Format(
                     Messages.EventDuration,
@@ -358,7 +358,7 @@ public sealed class ScheduledEventUpdateService : BackgroundService
         }
 
         var embed = new EmbedBuilder()
-            .WithSmallTitle(string.Format(Messages.EventCancelled, eventData.Name))
+            .WithSmallTitle(string.Format(Messages.EventCancelled, Markdown.Sanitize(eventData.Name)))
             .WithDescription(":(")
             .WithColour(ColorsList.Red)
             .WithCurrentTimestamp()
@@ -419,7 +419,7 @@ public sealed class ScheduledEventUpdateService : BackgroundService
 
         var earlyResult = new EmbedBuilder()
             .WithDescription(
-                string.Format(Messages.EventEarlyNotification, scheduledEvent.Name,
+                string.Format(Messages.EventEarlyNotification, Markdown.Sanitize(scheduledEvent.Name),
                     Markdown.Timestamp(scheduledEvent.ScheduledStartTime, TimestampStyle.RelativeTime)))
             .WithColour(ColorsList.Default)
             .Build();