diff --git a/.travis.yml b/.travis.yml index b10f852..53b8e62 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,6 +15,14 @@ deploy: repo: SOBotics/chatexchange branch: master jdk: oraclejdk8 + - + provider: script + script: .travis/deploy.sh + skip_cleanup: true + on: + repo: SOBotics/chatexchange + branch: develop + jdk: oraclejdk8 - provider: script script: .travis/deploy.sh diff --git a/src/main/java/org/sobotics/chatexchange/chat/ChatHost.java b/src/main/java/org/sobotics/chatexchange/chat/ChatHost.java index 70bdcfa..4d7afca 100644 --- a/src/main/java/org/sobotics/chatexchange/chat/ChatHost.java +++ b/src/main/java/org/sobotics/chatexchange/chat/ChatHost.java @@ -51,6 +51,18 @@ public String getBaseUrl() { */ public String getLoginHost() { return this.loginHost; + } + + + * Compares the host to another object + * @param otherHost other object + * @return true, if the name is the same + */ + public boolean equals(ChatHost otherHost) { + if (otherHost == null) + return false; + + return this.name.equals(otherHost.name); } } diff --git a/src/main/java/org/sobotics/chatexchange/chat/Room.java b/src/main/java/org/sobotics/chatexchange/chat/Room.java index ea5420d..4cc262d 100644 --- a/src/main/java/org/sobotics/chatexchange/chat/Room.java +++ b/src/main/java/org/sobotics/chatexchange/chat/Room.java @@ -618,6 +618,14 @@ public RoomThumbs getThumbs() { public ChatHost getHost() { return host; } + + /** + * Returns the cookies used to post in this room + * @return cookies as Map + */ + public Map getCookies() { + return this.cookies; + } void close() { executor.shutdown(); diff --git a/src/main/java/org/sobotics/chatexchange/chat/StackExchangeClient.java b/src/main/java/org/sobotics/chatexchange/chat/StackExchangeClient.java index 38e6379..1d88747 100644 --- a/src/main/java/org/sobotics/chatexchange/chat/StackExchangeClient.java +++ b/src/main/java/org/sobotics/chatexchange/chat/StackExchangeClient.java @@ -250,6 +250,24 @@ public boolean getAutoCreateAccount() { public void setAutoCreateAccount(boolean autoCreateAccount) { this.autoCreateAccount = autoCreateAccount; } + + + /** + * Returns the cookies for the first room with the given host + * @param host {@link ChatHost} to search for + * @return null, if no room with the given {@link ChatHost} was found + */ + public Map getCookies(ChatHost host) { + for (Room room : this.rooms) { + ChatHost roomHost = room.getHost(); + + if (host.equals(roomHost)) { + return room.getCookies(); + } + } + + return null; + } /** * Closes this client by making the logged-in user leave all the chat rooms they joined.