aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/service
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/juick/service')
-rw-r--r--src/main/java/com/juick/service/MessagesService.java2
-rw-r--r--src/main/java/com/juick/service/MessagesServiceImpl.java6
2 files changed, 4 insertions, 4 deletions
diff --git a/src/main/java/com/juick/service/MessagesService.java b/src/main/java/com/juick/service/MessagesService.java
index dda1cfd3..b9ee612a 100644
--- a/src/main/java/com/juick/service/MessagesService.java
+++ b/src/main/java/com/juick/service/MessagesService.java
@@ -154,7 +154,7 @@ public interface MessagesService {
List<Integer> getUnread(User user);
@CacheEvict(value = { "discover", "discussions", "messages", "replies" }, allEntries = true)
- boolean updateMessage(Integer mid, Integer rid, String body);
+ boolean updateMessage(Integer mid, Integer rid, String body, boolean foreign);
@CacheEvict(value = { "discover", "discussions", "messages", "replies" }, allEntries = true)
boolean updateReplyUri(Message reply, URI replyUri);
diff --git a/src/main/java/com/juick/service/MessagesServiceImpl.java b/src/main/java/com/juick/service/MessagesServiceImpl.java
index 3a4c3767..68d47429 100644
--- a/src/main/java/com/juick/service/MessagesServiceImpl.java
+++ b/src/main/java/com/juick/service/MessagesServiceImpl.java
@@ -1099,14 +1099,14 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
@Transactional
@Override
- public boolean updateMessage(Integer mid, Integer rid, String body) {
+ public boolean updateMessage(Integer mid, Integer rid, String body, boolean foreign) {
Instant now = Instant.now();
Instant messageEditingWindow = now.minus(15, ChronoUnit.MINUTES);
if (rid == 0) {
Optional<Message> message = getMessage(mid);
if (message.isPresent()) {
Instant ts = message.get().getUpdatedAt();
- if (ts.compareTo(messageEditingWindow) >= 0) {
+ if (ts.compareTo(messageEditingWindow) >= 0 || foreign) {
return jdbcTemplate.update(
"UPDATE messages_txt SET txt=?, updated_at=? WHERE messages_txt.message_id=?", body,
Timestamp.from(now), mid) > 0;
@@ -1117,7 +1117,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
Message reply = getReply(mid, rid);
if (reply != null) {
Instant ts = reply.getUpdatedAt();
- if (ts.compareTo(messageEditingWindow) >= 0) {
+ if (ts.compareTo(messageEditingWindow) >= 0 || foreign) {
return jdbcTemplate.update(
"UPDATE replies SET txt=?, updated_at=? WHERE message_id=? AND reply_id=?", body,
Timestamp.from(now), mid, rid) > 0;