Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update slack api #124

Merged
merged 3 commits into from
Jan 11, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add url check for matrix url
  • Loading branch information
shayaantx committed Jan 11, 2025
commit 40d2b6f5444ba876e76b447ec4818fe6eb67cfc0
25 changes: 21 additions & 4 deletions src/main/java/com/botdarr/clients/matrix/MatrixBootstrap.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import com.botdarr.scheduling.Scheduler;
import org.apache.logging.log4j.util.Strings;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.Properties;

public class MatrixBootstrap extends ChatClientBootstrap {
Expand All @@ -28,13 +30,28 @@ public void init() throws Exception {
chatClient.listen();
}

private boolean isValidURL(String urlString) {
try {
new URL(urlString);
return true;
} catch (MalformedURLException e) {
return false;
}
}

@Override
public boolean isConfigured(Properties properties) {
return
final boolean isConfigured =
!Strings.isBlank(properties.getProperty(Config.Constants.MATRIX_USERNAME)) &&
!Strings.isBlank(properties.getProperty(Config.Constants.MATRIX_PASSWORD)) &&
!Strings.isBlank(properties.getProperty(Config.Constants.MATRIX_ROOM)) &&
!Strings.isBlank(properties.getProperty(Config.Constants.MATRIX_HOME_SERVER));
!Strings.isBlank(properties.getProperty(Config.Constants.MATRIX_PASSWORD)) &&
!Strings.isBlank(properties.getProperty(Config.Constants.MATRIX_ROOM)) &&
!Strings.isBlank(properties.getProperty(Config.Constants.MATRIX_HOME_SERVER));

if (isConfigured && !isValidURL(properties.getProperty(Config.Constants.MATRIX_HOME_SERVER))) {
throw new RuntimeException("Matrix home server must be a url");
}

return isConfigured;
}

@Override
Expand Down