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)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2023-05-25 21:42:32 -07:00
|
|
|
|
2023-03-05 20:12:59 -08:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2023-05-25 21:42:32 -07:00
|
|
|
public static string ConvertHtmlCodes(string message)
|
|
|
|
{
|
|
|
|
message = message.Replace("'", "'");
|
|
|
|
return message;
|
|
|
|
}
|
|
|
|
|
2023-03-05 20:12:59 -08:00
|
|
|
public static bool IsEmbedAuthorValid(DiscordMessageEmbedAuthor author)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|