Added media type formatting

This commit is contained in:
mahdium committed 2024-09-25 23:21:05 +03:30
1 parent 86aa430394
commit c675824820
1 file changed
+9 -8
+9 -8
View File
@@ -23,26 +23,27 @@ namespace mstdnCats.Services
if (!existingPosts.Contains(post.mstdnPostId) && post.MediaAttachments.Count > 0) if (!existingPosts.Contains(post.mstdnPostId) && post.MediaAttachments.Count > 0)
{ {
// Send approve or reject message to admin // Send approve or reject message to admin
foreach (var media in post.MediaAttachments) foreach (var media in post.MediaAttachments)
{
if (media.Type == "image")
{ {
try try
{ {
await _bot.SendPhotoAsync(DotNetEnv.Env.GetString("ADMIN_NUMID"), media.PreviewUrl, caption: $"<a href=\"" + post.Url + "\"> Mastodon </a>", parseMode: ParseMode.Html await _bot.SendPhotoAsync(DotNetEnv.Env.GetString("ADMIN_NUMID"), media.PreviewUrl, caption: $"<a href=\"" + post.Url + "\"> Mastodon </a>", parseMode: ParseMode.Html
, replyMarkup: new InlineKeyboardMarkup().AddButton("Approve", $"approve-{media.MediaId}").AddButton("Reject", $"reject-{media.MediaId}")); , replyMarkup: new InlineKeyboardMarkup().AddButton("Approve", $"approve-{media.MediaId}").AddButton("Reject", $"reject-{media.MediaId}"));
// Insert post
await _db.InsertOneAsync(post);
newPosts++;
} }
catch (System.Exception ex) catch (System.Exception ex)
{ {
logger?.LogError("Error while sending message to admin: " + ex.Message + " - Media URL: " + media.PreviewUrl); logger?.LogError("Error while sending message to admin: " + ex.Message + " - Media URL: " + media.PreviewUrl);
} }
} }
}
// Insert post
await _db.InsertOneAsync(post);
newPosts++;
} }
} }