Notify for reactions
(cherry picked from commit 6d8d06cc2b221161ac4ac609d82e6db2ab6663cc)
This commit is contained in:
parent
87d0e0e7d6
commit
eec5308a77
2 changed files with 30 additions and 0 deletions
|
@ -21,6 +21,7 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
@ -28,6 +29,7 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import eu.siacs.conversations.crypto.OtrService;
|
||||
import eu.siacs.conversations.entities.Presence;
|
||||
|
@ -1432,6 +1434,8 @@ public class MessageParser extends AbstractParser implements Consumer<im.convers
|
|||
// TODO use occupant id for isSelf assessment
|
||||
final boolean isReceived = !mucOptions.isSelf(counterpart);
|
||||
if (occupantId != null && message != null) {
|
||||
final var newReactions = new HashSet<>(reactions.getReactions());
|
||||
newReactions.removeAll(message.getReactions().stream().filter(r -> occupantId.equals(r.occupantId)).map(r -> r.reaction).collect(Collectors.toList()));
|
||||
final var combinedReactions =
|
||||
Reaction.withOccupantId(
|
||||
message.getReactions(),
|
||||
|
@ -1443,6 +1447,7 @@ public class MessageParser extends AbstractParser implements Consumer<im.convers
|
|||
message.getRemoteMsgId());
|
||||
message.setReactions(combinedReactions);
|
||||
mXmppConnectionService.updateMessage(message, false);
|
||||
if (!isCarbon) mXmppConnectionService.getNotificationService().push(message, counterpart, occupantId, newReactions);
|
||||
} else {
|
||||
Log.d(Config.LOGTAG,"not found occupant or message");
|
||||
}
|
||||
|
@ -1459,6 +1464,8 @@ public class MessageParser extends AbstractParser implements Consumer<im.convers
|
|||
}
|
||||
packet.fromAccount(account);
|
||||
if (message != null) {
|
||||
final var newReactions = new HashSet<>(reactions.getReactions());
|
||||
newReactions.removeAll(message.getReactions().stream().filter(r -> reactionFrom.equals(r.from)).map(r -> r.reaction).collect(Collectors.toList()));
|
||||
final var combinedReactions =
|
||||
Reaction.withFrom(
|
||||
message.getReactions(),
|
||||
|
@ -1468,6 +1475,7 @@ public class MessageParser extends AbstractParser implements Consumer<im.convers
|
|||
message.getRemoteMsgId());
|
||||
message.setReactions(combinedReactions);
|
||||
mXmppConnectionService.updateMessage(message, false);
|
||||
if (!isCarbon) mXmppConnectionService.getNotificationService().push(message, counterpart, null, newReactions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,6 +64,7 @@ import eu.siacs.conversations.entities.Contact;
|
|||
import eu.siacs.conversations.entities.Conversation;
|
||||
import eu.siacs.conversations.entities.Conversational;
|
||||
import eu.siacs.conversations.entities.Message;
|
||||
import eu.siacs.conversations.entities.Reaction;
|
||||
import eu.siacs.conversations.entities.MucOptions;
|
||||
import eu.siacs.conversations.persistance.FileBackend;
|
||||
import eu.siacs.conversations.ui.ConversationsActivity;
|
||||
|
@ -85,6 +86,7 @@ import java.io.File;
|
|||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
|
@ -533,6 +535,26 @@ public class NotificationService {
|
|||
}
|
||||
}
|
||||
|
||||
public void push(final Message reactingTo, final Jid counterpart, final String occupantId, final Collection<String> newReactions) {
|
||||
if (newReactions.isEmpty()) return;
|
||||
|
||||
final var message = reactingTo.reply();
|
||||
message.appendBody(String.join(" ", newReactions));
|
||||
message.setCounterpart(counterpart);
|
||||
message.setOccupantId(occupantId);
|
||||
message.setStatus(Message.STATUS_RECEIVED);
|
||||
synchronized (CATCHUP_LOCK) {
|
||||
final XmppConnection connection =
|
||||
message.getConversation().getAccount().getXmppConnection();
|
||||
if (connection != null && connection.isWaitingForSmCatchup()) {
|
||||
connection.incrementSmCatchupMessageCounter();
|
||||
pushFromBacklog(message);
|
||||
} else {
|
||||
pushNow(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void pushFailedDelivery(final Message message) {
|
||||
final Conversation conversation = (Conversation) message.getConversation();
|
||||
final boolean isScreenLocked = !mXmppConnectionService.isScreenLocked();
|
||||
|
|
Loading…
Reference in a new issue