aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-05-21 15:50:36 +0300
committerGravatar Vitaly Takmazov2018-05-21 16:09:14 +0300
commitc7c2b377642a337edc303756836c9f0843cdc145 (patch)
tree846b6bfc126d6a3451597a0ca3c1110088347684
parent1179cdc5ba750c87783e442afeb202026ddd458d (diff)
juick.com/m/ links
-rw-r--r--juick-common/src/main/java/com/juick/formatters/PlainTextFormatter.java4
-rw-r--r--juick-common/src/main/java/com/juick/server/CommandsManager.java4
-rw-r--r--juick-common/src/main/java/com/juick/util/MessageUtils.java4
-rw-r--r--juick-server/src/main/java/com/juick/server/TelegramBotManager.java2
-rw-r--r--juick-server/src/main/java/com/juick/server/TopManager.java2
-rw-r--r--juick-server/src/main/java/com/juick/server/TwitterManager.java4
-rw-r--r--juick-server/src/main/java/com/juick/server/XMPPConnection.java6
-rw-r--r--juick-server/src/main/java/com/juick/server/api/rss/RepliesView.java2
-rw-r--r--juick-server/src/test/java/com/juick/server/tests/ServerTests.java8
9 files changed, 18 insertions, 18 deletions
diff --git a/juick-common/src/main/java/com/juick/formatters/PlainTextFormatter.java b/juick-common/src/main/java/com/juick/formatters/PlainTextFormatter.java
index 7275a9da..91748684 100644
--- a/juick-common/src/main/java/com/juick/formatters/PlainTextFormatter.java
+++ b/juick-common/src/main/java/com/juick/formatters/PlainTextFormatter.java
@@ -77,11 +77,11 @@ public class PlainTextFormatter {
public static String formatUrl(com.juick.Message jmsg) {
if (MessageUtils.isReply(jmsg)) {
- return String.format("https://juick.com/%d#%d", jmsg.getMid(), jmsg.getRid());
+ return String.format("https://juick.com/m/%d#%d", jmsg.getMid(), jmsg.getRid());
} else if (MessageUtils.isPM(jmsg)) {
return "https://juick.com/pm/inbox";
}
- return "https://juick.com/" + jmsg.getMid();
+ return "https://juick.com/m/" + jmsg.getMid();
}
public static String formatPostNumber(com.juick.Message jmsg) {
diff --git a/juick-common/src/main/java/com/juick/server/CommandsManager.java b/juick-common/src/main/java/com/juick/server/CommandsManager.java
index 4b32c456..3ba071e2 100644
--- a/juick-common/src/main/java/com/juick/server/CommandsManager.java
+++ b/juick-common/src/main/java/com/juick/server/CommandsManager.java
@@ -118,7 +118,7 @@ public class CommandsManager {
com.juick.Message msg = messagesService.getMessage(mid);
applicationEventPublisher.publishEvent(new MessageReadEvent(this, user, msg));
applicationEventPublisher.publishEvent(new MessageEvent(this, msg, subscriptionService.getSubscribedUsers(msg.getUser().getUid(), msg.getMid())));
- return CommandResult.build(msg, "New message posted.\n#" + msg.getMid() + " https://juick.com/" + msg.getMid(), String.format("[New message](%s) posted", PlainTextFormatter.formatUrl(msg)));
+ return CommandResult.build(msg, "New message posted.\n#" + msg.getMid() + " https://juick.com/m/" + msg.getMid(), String.format("[New message](%s) posted", PlainTextFormatter.formatUrl(msg)));
}
@UserCommand(pattern = "^ping$", patternFlags = Pattern.CASE_INSENSITIVE,
@@ -506,7 +506,7 @@ public class CommandsManager {
Message reply = messagesService.getReply(mid, newrid);
applicationEventPublisher.publishEvent(new MessageEvent(this, reply, subscriptionService.getUsersSubscribedToComments(original, reply)));
return CommandResult.build(reply,"Reply posted.\n#" + mid + "/" + newrid + " "
- + "https://juick.com/" + mid + "#" + newrid,
+ + "https://juick.com/m/" + mid + "#" + newrid,
String.format("[Reply](%s) posted", PlainTextFormatter.formatUrl(reply)));
}
}
diff --git a/juick-common/src/main/java/com/juick/util/MessageUtils.java b/juick-common/src/main/java/com/juick/util/MessageUtils.java
index c9796809..0da7310e 100644
--- a/juick-common/src/main/java/com/juick/util/MessageUtils.java
+++ b/juick-common/src/main/java/com/juick/util/MessageUtils.java
@@ -109,11 +109,11 @@ public class MessageUtils {
// #12345
// <a href="http://juick.com/12345">#12345</a>
- msg = msg.replaceAll("((?<=\\s)|(?<=\\A)|(?<=\\p{Punct}))#(\\d+)((?=\\s)|(?=\\Z)|(?=\\))|(?=\\.)|(?=\\,))", "$1<a href=\"http://juick.com/$2\">#$2</a>$3");
+ msg = msg.replaceAll("((?<=\\s)|(?<=\\A)|(?<=\\p{Punct}))#(\\d+)((?=\\s)|(?=\\Z)|(?=\\))|(?=\\.)|(?=\\,))", "$1<a href=\"http://juick.com/m/$2\">#$2</a>$3");
// #12345/65
// <a href="http://juick.com/12345#65">#12345/65</a>
- msg = msg.replaceAll("((?<=\\s)|(?<=\\A)|(?<=\\p{Punct}))#(\\d+)/(\\d+)((?=\\s)|(?=\\Z)|(?=\\p{Punct}))", "$1<a href=\"http://juick.com/$2#$3\">#$2/$3</a>$4");
+ msg = msg.replaceAll("((?<=\\s)|(?<=\\A)|(?<=\\p{Punct}))#(\\d+)/(\\d+)((?=\\s)|(?=\\Z)|(?=\\p{Punct}))", "$1<a href=\"http://juick.com/m/$2#$3\">#$2/$3</a>$4");
// *bold*
// <b>bold</b>
diff --git a/juick-server/src/main/java/com/juick/server/TelegramBotManager.java b/juick-server/src/main/java/com/juick/server/TelegramBotManager.java
index 6e6198a8..4cac0dff 100644
--- a/juick-server/src/main/java/com/juick/server/TelegramBotManager.java
+++ b/juick-server/src/main/java/com/juick/server/TelegramBotManager.java
@@ -184,7 +184,7 @@ public class TelegramBotManager implements NotificationListener {
juickLink.get().url()).build();
String path = uriComponents.getPath();
if (StringUtils.isNotEmpty(path) && path.length() > 1) {
- int mid = Integer.valueOf(path.substring(1));
+ int mid = Integer.valueOf(path.substring(3));
String prefix = String.format("#%d ", mid);
if (StringUtils.isNotEmpty(uriComponents.getFragment())) {
int rid = Integer.valueOf(uriComponents.getFragment());
diff --git a/juick-server/src/main/java/com/juick/server/TopManager.java b/juick-server/src/main/java/com/juick/server/TopManager.java
index 4d080f54..e6c22533 100644
--- a/juick-server/src/main/java/com/juick/server/TopManager.java
+++ b/juick-server/src/main/java/com/juick/server/TopManager.java
@@ -68,7 +68,7 @@ public class TopManager {
List<String> tags = jmsg.getTags().stream().map(Tag::getName).map(String::toLowerCase).collect(Collectors.toList());
if (!tags.contains("juick")) {
String status = MessageUtils.getMessageHashTags(jmsg) + StringUtils.defaultString(jmsg.getText());
- String link = "https://juick.com/" + jmsg.getMid();
+ String link = "https://juick.com/m/" + jmsg.getMid();
try {
facebookPageManager.post(status, link);
} catch (HttpClientErrorException ex) {
diff --git a/juick-server/src/main/java/com/juick/server/TwitterManager.java b/juick-server/src/main/java/com/juick/server/TwitterManager.java
index 411298bc..9b83b197 100644
--- a/juick-server/src/main/java/com/juick/server/TwitterManager.java
+++ b/juick-server/src/main/java/com/juick/server/TwitterManager.java
@@ -52,8 +52,8 @@ public class TwitterManager implements NotificationListener {
void twitterPost(final com.juick.Message jmsg) {
crosspostService.getTwitterToken(jmsg.getUser().getUid()).ifPresent(t -> {
String status = MessageUtils.getMessageHashTags(jmsg) + StringUtils.defaultString(jmsg.getText());
- if (status.length() > 255) {
- status = status.substring(0, 254) + "…";
+ if (status.length() > 253) {
+ status = status.substring(0, 252) + "…";
}
status += " http://juick.com/" + jmsg.getMid();
ConfigurationBuilder configurationBuilder = new ConfigurationBuilder()
diff --git a/juick-server/src/main/java/com/juick/server/XMPPConnection.java b/juick-server/src/main/java/com/juick/server/XMPPConnection.java
index d15db3f2..72208fa3 100644
--- a/juick-server/src/main/java/com/juick/server/XMPPConnection.java
+++ b/juick-server/src/main/java/com/juick/server/XMPPConnection.java
@@ -284,7 +284,7 @@ public class XMPPConnection implements StanzaListener, NotificationListener {
txt += attachmentUrl + "\n";
}
txt += StringUtils.defaultString(jmsg.getText()) + "\n\n";
- txt += "#" + jmsg.getMid() + " http://juick.com/" + jmsg.getMid();
+ txt += "#" + jmsg.getMid() + " http://juick.com/m/" + jmsg.getMid();
Nickname nick = new Nickname("@" + jmsg.getUser().getName());
@@ -324,7 +324,7 @@ public class XMPPConnection implements StanzaListener, NotificationListener {
if (StringUtils.isNotEmpty(attachmentUrl)) {
txt += attachmentUrl + "\n";
}
- txt += StringUtils.defaultString(jmsg.getText()) + "\n\n" + "#" + jmsg.getMid() + "/" + jmsg.getRid() + " http://juick.com/" + jmsg.getMid() + "#" + jmsg.getRid();
+ txt += StringUtils.defaultString(jmsg.getText()) + "\n\n" + "#" + jmsg.getMid() + "/" + jmsg.getRid() + " http://juick.com/m/" + jmsg.getMid() + "#" + jmsg.getRid();
Message msg = new Message();
msg.setFrom(jid);
@@ -405,7 +405,7 @@ public class XMPPConnection implements StanzaListener, NotificationListener {
txt += " (" + jmsg.getReplies() + " replies)";
}
}
- txt += " http://juick.com/" + jmsg.getMid();
+ txt += " http://juick.com/m/" + jmsg.getMid();
Nickname nick = new Nickname("@" + jmsg.getUser().getName());
diff --git a/juick-server/src/main/java/com/juick/server/api/rss/RepliesView.java b/juick-server/src/main/java/com/juick/server/api/rss/RepliesView.java
index b1e813c4..b67e8b44 100644
--- a/juick-server/src/main/java/com/juick/server/api/rss/RepliesView.java
+++ b/juick-server/src/main/java/com/juick/server/api/rss/RepliesView.java
@@ -76,7 +76,7 @@ public class RepliesView extends AbstractRssFeedView {
private Item createRssItem(ResponseReply msg) {
Item item = new Item();
- String messageUrl = String.format("http://juick.com/%d#%d", msg.getMid(), msg.getRid());
+ String messageUrl = String.format("http://juick.com/m/%d#%d", msg.getMid(), msg.getRid());
String messageTitle = String.format("@%s:", msg.getUname());
String messageDescription = MessageUtils.formatMessage(msg.getDescription());
item.setLink(messageUrl);
diff --git a/juick-server/src/test/java/com/juick/server/tests/ServerTests.java b/juick-server/src/test/java/com/juick/server/tests/ServerTests.java
index 9a78b0a2..41f2b68c 100644
--- a/juick-server/src/test/java/com/juick/server/tests/ServerTests.java
+++ b/juick-server/src/test/java/com/juick/server/tests/ServerTests.java
@@ -545,8 +545,8 @@ public class ServerTests {
}
@Test
public void tg2juickLinks() {
- UriComponents uriComponents = UriComponentsBuilder.fromUriString("http://juick.com/123456#23").build();
- assertThat(uriComponents.getPath().substring(1), is("123456"));
+ UriComponents uriComponents = UriComponentsBuilder.fromUriString("http://juick.com/m/123456#23").build();
+ assertThat(uriComponents.getPath().substring(3), is("123456"));
assertThat(uriComponents.getFragment(), is("23"));
}
@Test
@@ -713,9 +713,9 @@ public class ServerTests {
assertEquals("number of reader users should match", 1,
userService.getUserReaders(uid).size());
String expectedSecondReply = "Reply posted.\n#" + mid + "/2 "
- + "https://juick.com/" + mid + "#2";
+ + "https://juick.com/m/" + mid + "#2";
String expectedThirdReply = "Reply posted.\n#" + mid + "/3 "
- + "https://juick.com/" + mid + "#3";
+ + "https://juick.com/m/" + mid + "#3";
assertEquals("should be second reply", expectedSecondReply,
commandsManager.processCommand(user, "#" + mid + " yoyo", URI.create("http://static.juick.com/settings/facebook.png")).getText());
assertEquals("should be third reply", expectedThirdReply,