in server/src/jetbrains/buildServer/vsoRooms/notificator/VSOMessageSender.java [30:63]
public void sendMessageOnBehalfOfUsers(@NotNull final Set<SUser> users, @NotNull final String message) {
final Map<Pair<String, Long>, VSOTeamRoomsAPIConnection> connectionsToProcess = new HashMap<Pair<String, Long>, VSOTeamRoomsAPIConnection>();
for(SUser user : users){
final String account = VSOUserProperties.getAccount(user);
final String teamRoomName = VSOUserProperties.getTeamRoomName(user);
if(account == null || teamRoomName == null){
LOG.debug(String.format("Skip sending notification on behalf of %s. Target team room wasn't configured properly.", user.getDescriptiveName()));
continue;
}
final String username = VSOUserProperties.getUsername(user);
final String password = VSOUserProperties.getPassword(user);
if(username == null || password == null){
LOG.debug(String.format("Skip sending notification on behalf of %s. Required credentials were not configured properly.", user.getDescriptiveName()));
continue;
}
final VSOTeamRoomsAPIConnection connection = myAPI.createConnection(username, password);
final Long roomId = myTeamRoomIdsCache.getOrResolveRoomId(account, teamRoomName, connection);
if(roomId == null){
LOG.debug(String.format("Skip sending notification on behalf of %s. Failed to resolve target team room ID.", user.getDescriptiveName()));
continue;
}
connectionsToProcess.put(new Pair<String, Long>(account.toLowerCase(), roomId), connection);
}
for(Pair<String, Long> teamRoomUUID : connectionsToProcess.keySet()){
final VSOTeamRoomsAPIConnection apiConnection = connectionsToProcess.get(teamRoomUUID);
try{
apiConnection.sendMessageToRoom(teamRoomUUID.first, teamRoomUUID.second, message);
} catch (Exception ex){
LOG.warn(String.format("Failed to send message to the team room (%s : %d) ", teamRoomUUID.first, teamRoomUUID.second), ex);
}
}
}