diff options
author | Vitaly Takmazov | 2023-01-04 07:18:16 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2023-01-04 07:18:16 +0300 |
commit | 0e20ca44eee0cb2726b575aed88a495206481973 (patch) | |
tree | 65dc225857d836eebd5acca9125fbc1cdde0c158 /src/main/java/com/juick/service | |
parent | a48e976347abe9e61d7b4ba61831098629aabece (diff) |
ActivityPub: handle Note updates
Diffstat (limited to 'src/main/java/com/juick/service')
-rw-r--r-- | src/main/java/com/juick/service/MessagesService.java | 2 | ||||
-rw-r--r-- | src/main/java/com/juick/service/MessagesServiceImpl.java | 6 |
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; |