diff options
-rw-r--r-- | src/main/java/com/juick/model/Reaction.java | 13 | ||||
-rw-r--r-- | src/main/java/com/juick/service/MessagesServiceImpl.java | 3 |
2 files changed, 13 insertions, 3 deletions
diff --git a/src/main/java/com/juick/model/Reaction.java b/src/main/java/com/juick/model/Reaction.java index 4b3501d4..3f666cf6 100644 --- a/src/main/java/com/juick/model/Reaction.java +++ b/src/main/java/com/juick/model/Reaction.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008-2020, Juick + * Copyright (C) 2008-2023, Juick * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as @@ -20,6 +20,7 @@ package com.juick.model; import org.apache.commons.lang3.builder.ToStringBuilder; import java.io.Serializable; +import java.util.Objects; public class Reaction implements Serializable { @@ -41,6 +42,16 @@ public class Reaction implements Serializable { .append("count", count) .build(); } + @Override + public boolean equals(Object o) { + return o == this || + (o instanceof Reaction) && Objects.equals(id, ((Reaction) o).id); + } + + @Override + public int hashCode() { + return Objects.hash(id); + } public String getDescription() { return description; diff --git a/src/main/java/com/juick/service/MessagesServiceImpl.java b/src/main/java/com/juick/service/MessagesServiceImpl.java index b0e365f8..083524b1 100644 --- a/src/main/java/com/juick/service/MessagesServiceImpl.java +++ b/src/main/java/com/juick/service/MessagesServiceImpl.java @@ -845,8 +845,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ Reaction reaction = new Reaction(likeId); reaction.setCount(count); reaction.setDescription(description); - results.computeIfAbsent(messageId, HashSet::new); - results.get(messageId).add(reaction); + results.computeIfAbsent(messageId, HashSet::new).add(reaction); } return results; }); |