Enhance Telegram notification system with optional link support
- Updated NotifyUserAsync method in TelegramNotifier to accept an optional linkPath parameter for dynamic URL generation. - Modified various command handlers to utilize the new linkPath feature, providing users with relevant links in their notifications. - Adjusted ITelegramNotifier interface documentation to reflect the changes in method signature and functionality. - Enhanced unit tests to verify the correct invocation of the updated NotifyUserAsync method.
This commit is contained in:
@@ -228,6 +228,7 @@ internal sealed class TelegramNotifier(
|
||||
public async Task NotifyUserAsync(
|
||||
Guid userId,
|
||||
string message,
|
||||
string? linkPath,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
@@ -240,15 +241,14 @@ internal sealed class TelegramNotifier(
|
||||
|
||||
InlineKeyboardMarkup? keyboard = null;
|
||||
if (!string.IsNullOrWhiteSpace(options.Value.PublicSiteUrl))
|
||||
{
|
||||
var url = string.IsNullOrWhiteSpace(linkPath)
|
||||
? options.Value.PublicSiteUrl
|
||||
: $"{options.Value.PublicSiteUrl.TrimEnd('/')}{linkPath}";
|
||||
keyboard = new InlineKeyboardMarkup(
|
||||
new[]
|
||||
{
|
||||
InlineKeyboardButton.WithUrl(
|
||||
"🌐 Открыть на сайте",
|
||||
options.Value.PublicSiteUrl
|
||||
),
|
||||
}
|
||||
new[] { InlineKeyboardButton.WithUrl("🌐 Открыть на сайте", url) }
|
||||
);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user