From 0e20ca44eee0cb2726b575aed88a495206481973 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 4 Jan 2023 07:18:16 +0300 Subject: ActivityPub: handle Note updates --- src/main/java/com/juick/service/MessagesService.java | 2 +- src/main/java/com/juick/service/MessagesServiceImpl.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/main/java/com/juick/service') 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 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 = 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; -- cgit v1.2.3