Add Telegram notification for news publication to users
- Implemented NotifyUsersNewsPublishedAsync method in TelegramNotifier to send notifications to activated Telegram users when a news post is published. - Updated CreatePostCommandHandler to invoke the new Telegram notification method after creating a news post. - Enhanced IIdentityService to retrieve activated linked Telegram user IDs for notifications. - Updated ITelegramNotifier interface to include the new notification method documentation.
This commit is contained in:
@@ -252,6 +252,14 @@ internal sealed class IdentityService(UserManager<AppUser> userManager, SignInMa
|
||||
: new TelegramLinkInfo(false, null, null);
|
||||
}
|
||||
|
||||
public async Task<IReadOnlyCollection<long>> GetActivatedLinkedTelegramUserIdsAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
return await userManager.Users.AsNoTracking()
|
||||
.Where(u => u.TelegramUserId != null && u.IsActivated && !u.IsBlocked)
|
||||
.Select(u => u.TelegramUserId!.Value)
|
||||
.ToListAsync(cancellationToken);
|
||||
}
|
||||
|
||||
private async Task<string> GetPrimaryRoleNameAsync(AppUser user)
|
||||
{
|
||||
var roles = await userManager.GetRolesAsync(user);
|
||||
|
||||
Reference in New Issue
Block a user