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.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
@ -28,6 +29,7 @@ import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import eu.siacs.conversations.crypto.OtrService;
|
import eu.siacs.conversations.crypto.OtrService;
|
||||||
import eu.siacs.conversations.entities.Presence;
|
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
|
// TODO use occupant id for isSelf assessment
|
||||||
final boolean isReceived = !mucOptions.isSelf(counterpart);
|
final boolean isReceived = !mucOptions.isSelf(counterpart);
|
||||||
if (occupantId != null && message != null) {
|
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 =
|
final var combinedReactions =
|
||||||
Reaction.withOccupantId(
|
Reaction.withOccupantId(
|
||||||
message.getReactions(),
|
message.getReactions(),
|
||||||
|
@ -1443,6 +1447,7 @@ public class MessageParser extends AbstractParser implements Consumer<im.convers
|
||||||
message.getRemoteMsgId());
|
message.getRemoteMsgId());
|
||||||
message.setReactions(combinedReactions);
|
message.setReactions(combinedReactions);
|
||||||
mXmppConnectionService.updateMessage(message, false);
|
mXmppConnectionService.updateMessage(message, false);
|
||||||
|
if (!isCarbon) mXmppConnectionService.getNotificationService().push(message, counterpart, occupantId, newReactions);
|
||||||
} else {
|
} else {
|
||||||
Log.d(Config.LOGTAG,"not found occupant or message");
|
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);
|
packet.fromAccount(account);
|
||||||
if (message != null) {
|
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 =
|
final var combinedReactions =
|
||||||
Reaction.withFrom(
|
Reaction.withFrom(
|
||||||
message.getReactions(),
|
message.getReactions(),
|
||||||
|
@ -1468,6 +1475,7 @@ public class MessageParser extends AbstractParser implements Consumer<im.convers
|
||||||
message.getRemoteMsgId());
|
message.getRemoteMsgId());
|
||||||
message.setReactions(combinedReactions);
|
message.setReactions(combinedReactions);
|
||||||
mXmppConnectionService.updateMessage(message, false);
|
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.Conversation;
|
||||||
import eu.siacs.conversations.entities.Conversational;
|
import eu.siacs.conversations.entities.Conversational;
|
||||||
import eu.siacs.conversations.entities.Message;
|
import eu.siacs.conversations.entities.Message;
|
||||||
|
import eu.siacs.conversations.entities.Reaction;
|
||||||
import eu.siacs.conversations.entities.MucOptions;
|
import eu.siacs.conversations.entities.MucOptions;
|
||||||
import eu.siacs.conversations.persistance.FileBackend;
|
import eu.siacs.conversations.persistance.FileBackend;
|
||||||
import eu.siacs.conversations.ui.ConversationsActivity;
|
import eu.siacs.conversations.ui.ConversationsActivity;
|
||||||
|
@ -85,6 +86,7 @@ import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
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) {
|
public void pushFailedDelivery(final Message message) {
|
||||||
final Conversation conversation = (Conversation) message.getConversation();
|
final Conversation conversation = (Conversation) message.getConversation();
|
||||||
final boolean isScreenLocked = !mXmppConnectionService.isScreenLocked();
|
final boolean isScreenLocked = !mXmppConnectionService.isScreenLocked();
|
||||||
|
|
Loading…
Add table
Reference in a new issue