extract Text from gmail import, darkmode updates, auto update app versions etc
This commit is contained in:
@@ -204,6 +204,10 @@ public sealed class GmailOAuthService : IGmailOAuthService
|
||||
{
|
||||
bodyText = StripHtml(bodyHtml);
|
||||
}
|
||||
else if (LooksLikeHtml(bodyText))
|
||||
{
|
||||
bodyText = StripHtml(bodyText);
|
||||
}
|
||||
|
||||
return new GmailMessageDetail(
|
||||
messageId,
|
||||
@@ -423,6 +427,17 @@ public sealed class GmailOAuthService : IGmailOAuthService
|
||||
}
|
||||
}
|
||||
|
||||
private static bool LooksLikeHtml(string? value)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(value)) return false;
|
||||
return value.Contains("<html", StringComparison.OrdinalIgnoreCase)
|
||||
|| value.Contains("<body", StringComparison.OrdinalIgnoreCase)
|
||||
|| value.Contains("<div", StringComparison.OrdinalIgnoreCase)
|
||||
|| value.Contains("<p", StringComparison.OrdinalIgnoreCase)
|
||||
|| value.Contains("<br", StringComparison.OrdinalIgnoreCase)
|
||||
|| value.Contains("<span", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
private static string StripHtml(string html)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(html)) return "";
|
||||
|
||||
Reference in New Issue
Block a user