diff --git a/bubble-server/src/main/java/bubble/resources/stream/FilterHttpResource.java b/bubble-server/src/main/java/bubble/resources/stream/FilterHttpResource.java index 99294890..bdfce47e 100644 --- a/bubble-server/src/main/java/bubble/resources/stream/FilterHttpResource.java +++ b/bubble-server/src/main/java/bubble/resources/stream/FilterHttpResource.java @@ -38,6 +38,7 @@ import static javax.ws.rs.core.HttpHeaders.CONTENT_LENGTH; import static org.cobbzilla.util.daemon.ZillaRuntime.empty; import static org.cobbzilla.util.daemon.ZillaRuntime.shortError; import static org.cobbzilla.util.http.HttpContentTypes.APPLICATION_JSON; +import static org.cobbzilla.util.json.JsonUtil.COMPACT_MAPPER; import static org.cobbzilla.util.json.JsonUtil.json; import static org.cobbzilla.util.network.NetworkUtil.isLocalIpv4; import static org.cobbzilla.wizard.resources.ResourceUtil.*; @@ -217,8 +218,8 @@ public class FilterHttpResource { activeRequests.put(requestId, filterRequest); } - if (log.isDebugEnabled()) { - log.debug("filterHttp: starting with requestId="+requestId+", deviceId="+deviceId+", matchersJson="+matchersJson+", contentType="+contentType+", last="+last); + if (log.isTraceEnabled()) { + log.trace("filterHttp: starting with requestId="+requestId+", deviceId="+deviceId+", matchersJson="+matchersJson+", contentType="+contentType+", last="+last); } final boolean isLast = last != null && last; @@ -240,6 +241,8 @@ public class FilterHttpResource { final List data = dataDAO.findEnabledByAccountAndAppAndSite (fdc.request.getAccount().getUuid(), fdc.matcher.getApp(), fdc.matcher.getSite()); + if (log.isDebugEnabled()) log.debug("readData: found "+data.size()+" AppData records"); + if (format == null) format = AppDataFormat.key; switch (format) { case key: @@ -264,7 +267,7 @@ public class FilterHttpResource { AppData data) { if (data == null || !data.hasKey()) throw invalidEx("err.key.required"); - + if (log.isDebugEnabled()) log.debug("writeData: received data="+json(data, COMPACT_MAPPER)); final FilterDataContext fdc = new FilterDataContext(requestId, matcherId); data.setAccount(fdc.request.getAccount().getUuid()); @@ -272,6 +275,7 @@ public class FilterHttpResource { data.setSite(fdc.matcher.getSite()); data.setMatcher(fdc.matcher.getUuid()); + if (log.isDebugEnabled()) log.debug("writeData: recording data="+json(data, COMPACT_MAPPER)); return ok(dataDAO.create(data)); } diff --git a/bubble-server/src/main/java/bubble/rule/AbstractAppRuleDriver.java b/bubble-server/src/main/java/bubble/rule/AbstractAppRuleDriver.java index 72239580..237c0875 100644 --- a/bubble-server/src/main/java/bubble/rule/AbstractAppRuleDriver.java +++ b/bubble-server/src/main/java/bubble/rule/AbstractAppRuleDriver.java @@ -1,6 +1,7 @@ package bubble.rule; import bubble.dao.app.AppDataDAO; +import bubble.dao.app.AppSiteDAO; import bubble.model.account.Account; import bubble.model.app.AppMatcher; import bubble.model.app.AppRule; @@ -19,6 +20,7 @@ public abstract class AbstractAppRuleDriver implements AppRuleDriver { @Autowired protected BubbleConfiguration configuration; @Autowired protected AppDataDAO appDataDAO; + @Autowired protected AppSiteDAO appSiteDAO; @Getter @Setter private AppRuleDriver next; diff --git a/bubble-server/src/main/java/bubble/rule/social/block/JsUserBlocker.java b/bubble-server/src/main/java/bubble/rule/social/block/JsUserBlocker.java index 33ed0108..ca7d253f 100644 --- a/bubble-server/src/main/java/bubble/rule/social/block/JsUserBlocker.java +++ b/bubble-server/src/main/java/bubble/rule/social/block/JsUserBlocker.java @@ -1,8 +1,10 @@ package bubble.rule.social.block; +import bubble.model.app.AppMatcher; import bubble.rule.AbstractAppRuleDriver; import lombok.Getter; import org.apache.commons.io.input.ReaderInputStream; +import org.cobbzilla.util.collection.ExpirationMap; import org.cobbzilla.util.handlebars.HandlebarsUtil; import org.cobbzilla.util.io.regex.RegexFilterReader; import org.cobbzilla.util.io.regex.RegexReplacementFilter; @@ -44,7 +46,7 @@ public class JsUserBlocker extends AbstractAppRuleDriver { ctx.put(CTX_JS_PREFIX, "__bubble_"+sha256_hex(requestId)+"_"); ctx.put(CTX_BUBBLE_REQUEST_ID, requestId); ctx.put(CTX_BUBBLE_HOME, configuration.getPublicUriBase()); - ctx.put(CTX_SITE, matcher.getSite()); + ctx.put(CTX_SITE, getSiteName(matcher)); ctx.put(CTX_BUBBLE_DATA_ID, requestId+"/"+matcher.getUuid()); final String siteJs = HandlebarsUtil.apply(getHandlebars(), getSiteJsTemplate(), ctx); @@ -53,4 +55,9 @@ public class JsUserBlocker extends AbstractAppRuleDriver { return HandlebarsUtil.apply(getHandlebars(), BUBBLE_JS_TEMPLATE, ctx); } + private ExpirationMap siteNameCache = new ExpirationMap<>(); + private String getSiteName(AppMatcher matcher) { + return siteNameCache.computeIfAbsent(matcher.getSite(), k -> appSiteDAO.findByAccountAndId(matcher.getAccount(), matcher.getSite()).getName()); + } + } diff --git a/utils/cobbzilla-utils b/utils/cobbzilla-utils index c006089b..7f944cf9 160000 --- a/utils/cobbzilla-utils +++ b/utils/cobbzilla-utils @@ -1 +1 @@ -Subproject commit c006089b05f4461783ee340b9d39f1557b27728d +Subproject commit 7f944cf93d24bd47b5a8f124abddbc34bb2ef7f3