Merge pull request #169 from devgianlu/master

Send global chat enabled with FirstLoad
This commit is contained in:
Andy Janata 2018-05-18 18:46:22 -05:00 committed by GitHub
commit 2906ffaa33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -308,7 +308,9 @@ public class Constants {
@GoDataType("int64") @GoDataType("int64")
SERVER_STARTED("SS"), SERVER_STARTED("SS"),
@GoDataType("[]int") @GoDataType("[]int")
WHITE_CARDS("wc"); WHITE_CARDS("wc"),
@GoDataType("bool")
GLOBAL_CHAT_ENABLED("gce");
private final String field; private final String field;

View File

@ -32,6 +32,7 @@ import java.util.Set;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
import net.socialgamer.cah.CahModule;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.Transaction; import org.hibernate.Transaction;
@ -68,15 +69,18 @@ public class FirstLoadHandler extends Handler {
private final Set<String> banList; private final Set<String> banList;
private final Session hibernateSession; private final Session hibernateSession;
private final Provider<Boolean> includeInactiveCardsetsProvider; private final Provider<Boolean> includeInactiveCardsetsProvider;
private final boolean globalChatEnabled;
private final Date serverStarted; private final Date serverStarted;
@Inject @Inject
public FirstLoadHandler(final Session hibernateSession, @BanList final Set<String> banList, public FirstLoadHandler(final Session hibernateSession, @BanList final Set<String> banList,
@IncludeInactiveCardsets final Provider<Boolean> includeInactiveCardsetsProvider, @IncludeInactiveCardsets final Provider<Boolean> includeInactiveCardsetsProvider,
@CahModule.GlobalChatEnabled final boolean globalChatEnabled,
@ServerStarted final Date serverStarted) { @ServerStarted final Date serverStarted) {
this.banList = banList; this.banList = banList;
this.hibernateSession = hibernateSession; this.hibernateSession = hibernateSession;
this.includeInactiveCardsetsProvider = includeInactiveCardsetsProvider; this.includeInactiveCardsetsProvider = includeInactiveCardsetsProvider;
this.globalChatEnabled = globalChatEnabled;
this.serverStarted = serverStarted; this.serverStarted = serverStarted;
} }
@ -84,6 +88,7 @@ public class FirstLoadHandler extends Handler {
public Map<ReturnableData, Object> handle(final RequestWrapper request, public Map<ReturnableData, Object> handle(final RequestWrapper request,
final HttpSession session) { final HttpSession session) {
final HashMap<ReturnableData, Object> ret = new HashMap<ReturnableData, Object>(); final HashMap<ReturnableData, Object> ret = new HashMap<ReturnableData, Object>();
ret.put(AjaxResponse.GLOBAL_CHAT_ENABLED, globalChatEnabled);
if (banList.contains(request.getRemoteAddr())) { if (banList.contains(request.getRemoteAddr())) {
LOG.info(String.format("Rejecting user from %s because they are banned.", LOG.info(String.format("Rejecting user from %s because they are banned.",