Commit 417cc87c authored by Liang Ding's avatar Liang Ding

🎨 更新 User-Agent

parent b14fa505
...@@ -125,7 +125,8 @@ public final class ArticleSender extends AbstractEventListener<JSONObject> { ...@@ -125,7 +125,8 @@ public final class ArticleSender extends AbstractEventListener<JSONObject> {
requestJSONObject.put("clientAdminEmail", preference.optString(Option.ID_C_ADMIN_EMAIL)); requestJSONObject.put("clientAdminEmail", preference.optString(Option.ID_C_ADMIN_EMAIL));
requestJSONObject.put("clientRuntimeEnv", "LOCAL"); requestJSONObject.put("clientRuntimeEnv", "LOCAL");
HttpRequest.post(ADD_ARTICLE_URL).bodyText(requestJSONObject.toString()).contentTypeJson().sendAsync(); HttpRequest.post(ADD_ARTICLE_URL).bodyText(requestJSONObject.toString()).
contentTypeJson().header("User-Agent", Solos.USER_AGENT).sendAsync();
} catch (final Exception e) { } catch (final Exception e) {
LOGGER.log(Level.ERROR, "Sends an article to Rhythm error: {0}", e.getMessage()); LOGGER.log(Level.ERROR, "Sends an article to Rhythm error: {0}", e.getMessage());
} }
......
...@@ -121,7 +121,8 @@ public final class ArticleUpdater extends AbstractEventListener<JSONObject> { ...@@ -121,7 +121,8 @@ public final class ArticleUpdater extends AbstractEventListener<JSONObject> {
requestJSONObject.put("clientAdminEmail", preference.optString(Option.ID_C_ADMIN_EMAIL)); requestJSONObject.put("clientAdminEmail", preference.optString(Option.ID_C_ADMIN_EMAIL));
requestJSONObject.put("clientRuntimeEnv", "LOCAL"); requestJSONObject.put("clientRuntimeEnv", "LOCAL");
HttpRequest.put(UPDATE_ARTICLE_URL).bodyText(requestJSONObject.toString()).contentTypeJson().sendAsync(); HttpRequest.put(UPDATE_ARTICLE_URL).bodyText(requestJSONObject.toString()).
contentTypeJson().header("User-Agent", Solos.USER_AGENT).sendAsync();
} catch (final Exception e) { } catch (final Exception e) {
LOGGER.log(Level.ERROR, "Sends an article to Rhythm error: {0}", e.getMessage()); LOGGER.log(Level.ERROR, "Sends an article to Rhythm error: {0}", e.getMessage());
} }
......
...@@ -96,7 +96,8 @@ public final class CommentSender extends AbstractEventListener<JSONObject> { ...@@ -96,7 +96,8 @@ public final class CommentSender extends AbstractEventListener<JSONObject> {
requestJSONObject.put("clientAdminEmail", preference.optString(Option.ID_C_ADMIN_EMAIL)); requestJSONObject.put("clientAdminEmail", preference.optString(Option.ID_C_ADMIN_EMAIL));
requestJSONObject.put("userB3Key", preference.optString(Option.ID_C_KEY_OF_SOLO)); requestJSONObject.put("userB3Key", preference.optString(Option.ID_C_KEY_OF_SOLO));
HttpRequest.post(ADD_COMMENT_URL).bodyText(requestJSONObject.toString()).contentTypeJson().sendAsync(); HttpRequest.post(ADD_COMMENT_URL).bodyText(requestJSONObject.toString()).
header("User-Agent", Solos.USER_AGENT).contentTypeJson().sendAsync();
} catch (final Exception e) { } catch (final Exception e) {
LOGGER.log(Level.ERROR, "Sends a comment to Symphony error: {0}", e.getMessage()); LOGGER.log(Level.ERROR, "Sends a comment to Symphony error: {0}", e.getMessage());
} }
......
...@@ -175,7 +175,8 @@ public class BlogProcessor { ...@@ -175,7 +175,8 @@ public class BlogProcessor {
requestJSONObject.put("userB3Key", preference.optString(Option.ID_C_KEY_OF_SOLO)); requestJSONObject.put("userB3Key", preference.optString(Option.ID_C_KEY_OF_SOLO));
requestJSONObject.put("clientHost", Latkes.getServePath()); requestJSONObject.put("clientHost", Latkes.getServePath());
HttpRequest.post(Solos.B3LOG_SYMPHONY_SERVE_PATH + "/apis/user").bodyText(requestJSONObject.toString()).contentTypeJson().sendAsync(); HttpRequest.post(Solos.B3LOG_SYMPHONY_SERVE_PATH + "/apis/user").bodyText(requestJSONObject.toString())
.header("User-Agent", Solos.USER_AGENT).contentTypeJson().sendAsync();
} }
/** /**
......
...@@ -786,7 +786,7 @@ public class CommentMgmtService { ...@@ -786,7 +786,7 @@ public class CommentMgmtService {
int statusCode = HttpServletResponse.SC_OK; int statusCode = HttpServletResponse.SC_OK;
try { try {
statusCode = HttpRequest.get(thumbnailURL).send().statusCode(); statusCode = HttpRequest.get(thumbnailURL).header("User-Agent", Solos.USER_AGENT).send().statusCode();
} catch (final Exception e) { } catch (final Exception e) {
LOGGER.log(Level.DEBUG, "Can not fetch thumbnail from Gravatar [commentEmail={0}]", commentEmail); LOGGER.log(Level.DEBUG, "Can not fetch thumbnail from Gravatar [commentEmail={0}]", commentEmail);
} finally { } finally {
......
...@@ -258,7 +258,7 @@ public class InitService { ...@@ -258,7 +258,7 @@ public class InitService {
} }
try { try {
HttpRequest.get(Latkes.getServePath() + "/blog/symphony/user").sendAsync(); HttpRequest.get(Latkes.getServePath() + "/blog/symphony/user").header("User-Agent", Solos.USER_AGENT).sendAsync();
} catch (final Exception e) { } catch (final Exception e) {
LOGGER.log(Level.TRACE, "Sync account failed"); LOGGER.log(Level.TRACE, "Sync account failed");
} }
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
package org.b3log.solo.util; package org.b3log.solo.util;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.b3log.solo.SoloServletListener;
import java.util.MissingResourceException; import java.util.MissingResourceException;
import java.util.ResourceBundle; import java.util.ResourceBundle;
...@@ -26,7 +27,7 @@ import java.util.ResourceBundle; ...@@ -26,7 +27,7 @@ import java.util.ResourceBundle;
* Solo utilities. * Solo utilities.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.0.0, Jul 31, 2018 * @version 1.2.0.0, Sep 17, 2018
* @since 2.8.0 * @since 2.8.0
*/ */
public final class Solos { public final class Solos {
...@@ -61,6 +62,11 @@ public final class Solos { ...@@ -61,6 +62,11 @@ public final class Solos {
*/ */
public static final String MOBILE_SKIN; public static final String MOBILE_SKIN;
/**
* Solo User-Agent.
*/
public static final String USER_AGENT = "Solo/" + SoloServletListener.VERSION + "; +https://github.com/b3log/solo";
static { static {
ResourceBundle solo; ResourceBundle solo;
try { try {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment