Added more logging
This commit is contained in:
1 parent
3e73caade3
commit
321f48660d
1 file changed
+18
-9
@@ -45,8 +45,7 @@ namespace mstdnCats.Services
|
|||||||
if (mediaAttachment != null)
|
if (mediaAttachment != null)
|
||||||
{
|
{
|
||||||
// Check if the media attachment is already approved
|
// Check if the media attachment is already approved
|
||||||
bool isAlreadyApproved = mediaAttachment.Approved;
|
if (mediaAttachment.Approved){
|
||||||
if (isAlreadyApproved){
|
|
||||||
await _bot.AnswerCallbackQuery(callbackQuery.Id, "Media attachment is already approved.",true);
|
await _bot.AnswerCallbackQuery(callbackQuery.Id, "Media attachment is already approved.",true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -58,15 +57,25 @@ namespace mstdnCats.Services
|
|||||||
|
|
||||||
if (updated)
|
if (updated)
|
||||||
{
|
{
|
||||||
// Send the media attachment to the channel
|
try
|
||||||
await _bot.SendPhoto(config.CHANNEL_NUMID, allMediaAttachments.First(m => m.MediaId == mediaId).Url, caption: $"Post from " + $"<a href=\"" + post.Account.Url + "\">" + post.Account.DisplayName + " </a>", parseMode: ParseMode.Html
|
{
|
||||||
, replyMarkup: new InlineKeyboardMarkup(InlineKeyboardButton.WithUrl("View on Mastodon", post.Url)));
|
// Send the media attachment to the channel
|
||||||
|
await _bot.SendPhoto(config.CHANNEL_NUMID,
|
||||||
|
allMediaAttachments.First(m => m.MediaId == mediaId).Url,
|
||||||
|
caption: $"Post from " + $"<a href=\"" + post.Account.Url + "\">" +
|
||||||
|
post.Account.DisplayName + " </a>", parseMode: ParseMode.Html
|
||||||
|
, replyMarkup: new InlineKeyboardMarkup(InlineKeyboardButton.WithUrl("View on Mastodon", post.Url)));
|
||||||
|
|
||||||
await _bot.AnswerCallbackQuery(callbackQuery.Id, "Media attachment approved and sent to channel.");
|
await _bot.AnswerCallbackQuery(callbackQuery.Id,
|
||||||
await _bot.DeleteMessage(callbackQuery.Message.Chat.Id, callbackQuery.Message.Id);
|
"Media attachment approved and sent to channel.");
|
||||||
|
await _bot.DeleteMessage(callbackQuery.Message.Chat.Id, callbackQuery.Message.Id);
|
||||||
logger?.LogTrace($"Media attachment {mediaId} approved.");
|
|
||||||
|
|
||||||
|
logger?.LogTrace($"Media attachment {mediaId} approved.");
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
logger?.LogError($"Error while sending image to the channel:{e}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user