Newsbot.Collector/Newsbot.Collector.Services/Notifications/Discord/MessageValidation.cs
James Tombleson 39bf92dd53
Features/codeprojects/disable commit checks (#30)
* hard disable for checking commits till I can debug it more

* New HtmlCode method added
2023-05-25 21:42:32 -07:00

56 lines
1.3 KiB
C#

using Newsbot.Collector.Domain.Models;
namespace Newsbot.Collector.Services.Notifications.Discord;
public class MessageValidation
{
public void IsMessageValid(DiscordMessage payload)
{
if (payload.Embeds is null)
{
}
}
public static bool IsEmbedFooterValid(DiscordMessageEmbed[] embeds)
{
if (embeds.Count() == 0)
{
return true;
}
foreach (var embed in embeds)
{
if (embed.Footer is null)
{
return true;
}
if (embed.Footer.IconUrl is null)
{
return true;
}
var containsHttp = embed.Footer.IconUrl.Contains("http://");
var containsHttps = embed.Footer.IconUrl.Contains("https://");
if (containsHttp == false || containsHttps == false)
{
throw new Exception("Footer.IconUrl does not contain http:// or https://");
}
}
return true;
}
public static string ConvertHtmlCodes(string message)
{
message = message.Replace("&#39", "'");
return message;
}
public static bool IsEmbedAuthorValid(DiscordMessageEmbedAuthor author)
{
return true;
}
}