Newsbot.Collector/Newsbot.Collector.Services/Notifications/Discord/MessageValidation.cs

50 lines
1.1 KiB
C#
Raw Normal View History

2023-03-05 20:12:59 -08:00
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 bool IsEmbedAuthorValid(DiscordMessageEmbedAuthor author)
{
return true;
}
}