Add webhook
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user