use of org.thoughtcrime.securesms.jobs.SendViewedReceiptJob in project Signal-Android by WhisperSystems.
the class VoiceNotePlaybackService method sendViewedReceiptForCurrentWindowIndex.
private void sendViewedReceiptForCurrentWindowIndex() {
if (player.getPlaybackState() == Player.STATE_READY && player.getPlayWhenReady() && player.getCurrentWindowIndex() != C.INDEX_UNSET) {
MediaItem currentMediaItem = player.getCurrentMediaItem();
if (currentMediaItem == null || currentMediaItem.playbackProperties == null) {
return;
}
Uri mediaUri = currentMediaItem.playbackProperties.uri;
if (!mediaUri.getScheme().equals("content")) {
return;
}
SignalExecutors.BOUNDED.execute(() -> {
Bundle extras = currentMediaItem.mediaMetadata.extras;
if (extras == null) {
return;
}
long messageId = extras.getLong(VoiceNoteMediaItemFactory.EXTRA_MESSAGE_ID);
RecipientId recipientId = RecipientId.from(extras.getString(VoiceNoteMediaItemFactory.EXTRA_INDIVIDUAL_RECIPIENT_ID));
MessageDatabase messageDatabase = SignalDatabase.mms();
MessageDatabase.MarkedMessageInfo markedMessageInfo = messageDatabase.setIncomingMessageViewed(messageId);
if (markedMessageInfo != null) {
ApplicationDependencies.getJobManager().add(new SendViewedReceiptJob(markedMessageInfo.getThreadId(), recipientId, markedMessageInfo.getSyncMessageId().getTimetamp(), new MessageId(messageId, true)));
MultiDeviceViewedUpdateJob.enqueue(Collections.singletonList(markedMessageInfo.getSyncMessageId()));
}
});
}
}
use of org.thoughtcrime.securesms.jobs.SendViewedReceiptJob in project Signal-Android by signalapp.
the class VoiceNotePlaybackService method sendViewedReceiptForCurrentWindowIndex.
private void sendViewedReceiptForCurrentWindowIndex() {
if (player.getPlaybackState() == Player.STATE_READY && player.getPlayWhenReady() && player.getCurrentWindowIndex() != C.INDEX_UNSET) {
MediaItem currentMediaItem = player.getCurrentMediaItem();
if (currentMediaItem == null || currentMediaItem.playbackProperties == null) {
return;
}
Uri mediaUri = currentMediaItem.playbackProperties.uri;
if (!mediaUri.getScheme().equals("content")) {
return;
}
SignalExecutors.BOUNDED.execute(() -> {
Bundle extras = currentMediaItem.mediaMetadata.extras;
if (extras == null) {
return;
}
long messageId = extras.getLong(VoiceNoteMediaItemFactory.EXTRA_MESSAGE_ID);
RecipientId recipientId = RecipientId.from(extras.getString(VoiceNoteMediaItemFactory.EXTRA_INDIVIDUAL_RECIPIENT_ID));
MessageDatabase messageDatabase = SignalDatabase.mms();
MessageDatabase.MarkedMessageInfo markedMessageInfo = messageDatabase.setIncomingMessageViewed(messageId);
if (markedMessageInfo != null) {
ApplicationDependencies.getJobManager().add(new SendViewedReceiptJob(markedMessageInfo.getThreadId(), recipientId, markedMessageInfo.getSyncMessageId().getTimetamp(), new MessageId(messageId, true)));
MultiDeviceViewedUpdateJob.enqueue(Collections.singletonList(markedMessageInfo.getSyncMessageId()));
}
});
}
}
use of org.thoughtcrime.securesms.jobs.SendViewedReceiptJob in project Signal-Android by WhisperSystems.
the class ViewOnceMessageRepository method getMessage.
void getMessage(long messageId, @NonNull Callback<Optional<MmsMessageRecord>> callback) {
SignalExecutors.BOUNDED.execute(() -> {
try {
MmsMessageRecord record = (MmsMessageRecord) mmsDatabase.getMessageRecord(messageId);
MessageDatabase.MarkedMessageInfo info = mmsDatabase.setIncomingMessageViewed(record.getId());
if (info != null) {
ApplicationDependencies.getJobManager().add(new SendViewedReceiptJob(record.getThreadId(), info.getSyncMessageId().getRecipientId(), info.getSyncMessageId().getTimetamp(), info.getMessageId()));
MultiDeviceViewedUpdateJob.enqueue(Collections.singletonList(info.getSyncMessageId()));
}
callback.onComplete(Optional.fromNullable(record));
} catch (NoSuchMessageException e) {
callback.onComplete(Optional.absent());
}
});
}
use of org.thoughtcrime.securesms.jobs.SendViewedReceiptJob in project Signal-Android by signalapp.
the class ViewOnceMessageRepository method getMessage.
void getMessage(long messageId, @NonNull Callback<Optional<MmsMessageRecord>> callback) {
SignalExecutors.BOUNDED.execute(() -> {
try {
MmsMessageRecord record = (MmsMessageRecord) mmsDatabase.getMessageRecord(messageId);
MessageDatabase.MarkedMessageInfo info = mmsDatabase.setIncomingMessageViewed(record.getId());
if (info != null) {
ApplicationDependencies.getJobManager().add(new SendViewedReceiptJob(record.getThreadId(), info.getSyncMessageId().getRecipientId(), info.getSyncMessageId().getTimetamp(), info.getMessageId()));
MultiDeviceViewedUpdateJob.enqueue(Collections.singletonList(info.getSyncMessageId()));
}
callback.onComplete(Optional.fromNullable(record));
} catch (NoSuchMessageException e) {
callback.onComplete(Optional.absent());
}
});
}
Aggregations