Java Code Examples for org.whispersystems.signalservice.api.messages.SignalServiceDataMessage#Reaction
The following examples show how to use
org.whispersystems.signalservice.api.messages.SignalServiceDataMessage#Reaction .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PushProcessMessageJob.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
private void handleReaction(@NonNull SignalServiceContent content, @NonNull SignalServiceDataMessage message) { SignalServiceDataMessage.Reaction reaction = message.getReaction().get(); Recipient targetAuthor = Recipient.externalPush(context, reaction.getTargetAuthor()); MessageRecord targetMessage = DatabaseFactory.getMmsSmsDatabase(context).getMessageFor(reaction.getTargetSentTimestamp(), targetAuthor.getId()); if (targetMessage != null && !targetMessage.isRemoteDelete()) { Recipient reactionAuthor = Recipient.externalPush(context, content.getSender()); MessagingDatabase db = targetMessage.isMms() ? DatabaseFactory.getMmsDatabase(context) : DatabaseFactory.getSmsDatabase(context); if (reaction.isRemove()) { db.deleteReaction(targetMessage.getId(), reactionAuthor.getId()); ApplicationDependencies.getMessageNotifier().updateNotification(context); } else { ReactionRecord reactionRecord = new ReactionRecord(reaction.getEmoji(), reactionAuthor.getId(), message.getTimestamp(), System.currentTimeMillis()); db.addReaction(targetMessage.getId(), reactionRecord); ApplicationDependencies.getMessageNotifier().updateNotification(context, targetMessage.getThreadId(), false); } } else if (targetMessage != null) { Log.w(TAG, "[handleReaction] Found a matching message, but it's flagged as remotely deleted. timestamp: " + reaction.getTargetSentTimestamp() + " author: " + targetAuthor.getId()); } else { Log.w(TAG, "[handleReaction] Could not find matching message! timestamp: " + reaction.getTargetSentTimestamp() + " author: " + targetAuthor.getId()); ApplicationDependencies.getEarlyMessageCache().store(targetAuthor.getId(), reaction.getTargetSentTimestamp(), content); } }
Example 2
Source File: ReactionSendJob.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
private static SignalServiceDataMessage.Reaction buildReaction(@NonNull Context context, @NonNull ReactionRecord reaction, boolean remove, @NonNull Recipient targetAuthor, long targetSentTimestamp) { return new SignalServiceDataMessage.Reaction(reaction.getEmoji(), remove, RecipientUtil.toSignalServiceAddress(context, targetAuthor), targetSentTimestamp); }
Example 3
Source File: Manager.java From signal-cli with GNU General Public License v3.0 | 5 votes |
public void sendGroupMessageReaction(String emoji, boolean remove, String targetAuthor, long targetSentTimestamp, byte[] groupId) throws IOException, EncapsulatedExceptions, InvalidNumberException, NotAGroupMemberException, GroupNotFoundException { SignalServiceDataMessage.Reaction reaction = new SignalServiceDataMessage.Reaction(emoji, remove, canonicalizeAndResolveSignalServiceAddress(targetAuthor), targetSentTimestamp); final SignalServiceDataMessage.Builder messageBuilder = SignalServiceDataMessage.newBuilder() .withReaction(reaction); if (groupId != null) { SignalServiceGroup group = SignalServiceGroup.newBuilder(SignalServiceGroup.Type.DELIVER) .withId(groupId) .build(); messageBuilder.asGroupMessage(group); } final GroupInfo g = getGroupForSending(groupId); sendMessageLegacy(messageBuilder, g.getMembersWithout(account.getSelfAddress())); }
Example 4
Source File: Manager.java From signal-cli with GNU General Public License v3.0 | 5 votes |
public void sendMessageReaction(String emoji, boolean remove, String targetAuthor, long targetSentTimestamp, List<String> recipients) throws IOException, EncapsulatedExceptions, InvalidNumberException { SignalServiceDataMessage.Reaction reaction = new SignalServiceDataMessage.Reaction(emoji, remove, canonicalizeAndResolveSignalServiceAddress(targetAuthor), targetSentTimestamp); final SignalServiceDataMessage.Builder messageBuilder = SignalServiceDataMessage.newBuilder() .withReaction(reaction); sendMessageLegacy(messageBuilder, getSignalServiceAddresses(recipients)); }