Skip to content

Commit

Permalink
Merge pull request #7 from SOBotics/feature/6-make-cookies-available
Browse files Browse the repository at this point in the history
Feature/6 make cookies available
  • Loading branch information
FelixSFD authored Aug 12, 2018
2 parents 777f50d + 34d163c commit 46e0ff8
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/org/sobotics/chatexchange/chat/ChatHost.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,17 @@ public String getName() {
public String getBaseUrl() {
return baseUrl;
}

/**
* 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);
}

}
8 changes: 8 additions & 0 deletions src/main/java/org/sobotics/chatexchange/chat/Room.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, String> getCookies() {
return this.cookies;
}

void close() {
executor.shutdown();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,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<String, String> 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.
Expand Down

0 comments on commit 46e0ff8

Please sign in to comment.