Add webhook

This commit is contained in:
2025-06-09 01:04:02 +07:00
parent 8836c45c9d
commit 1f2780d52a
15 changed files with 195 additions and 19 deletions

View File

@@ -165,4 +165,21 @@ public class UserService : IUserService
await _userRepository.UpdateUser(user);
return user;
}
public async Task<User> UpdateTelegramChannel(User user, string telegramChannel)
{
// Validate Telegram channel format (must start with @ and contain only allowed characters)
if (!string.IsNullOrEmpty(telegramChannel))
{
string pattern = @"^@[a-zA-Z0-9_]{5,32}$";
if (!Regex.IsMatch(telegramChannel, pattern))
{
throw new Exception("Invalid Telegram channel format. Must start with @ and be 5-32 characters long, containing only letters, numbers, and underscores.");
}
}
user.TelegramChannel = telegramChannel;
await _userRepository.UpdateUser(user);
return user;
}
}