use of org.thoughtcrime.securesms.database.model.MessageId in project Signal-Android by signalapp.
the class MmsDatabase method markAsSending.
@Override
public void markAsSending(long messageId) {
long threadId = getThreadIdForMessage(messageId);
updateMailboxBitmask(messageId, Types.BASE_TYPE_MASK, Types.BASE_SENDING_TYPE, Optional.of(threadId));
ApplicationDependencies.getDatabaseObserver().notifyMessageUpdateObservers(new MessageId(messageId, true));
}
use of org.thoughtcrime.securesms.database.model.MessageId in project Signal-Android by signalapp.
the class MmsDatabase method markAsSentFailed.
@Override
public void markAsSentFailed(long messageId) {
long threadId = getThreadIdForMessage(messageId);
updateMailboxBitmask(messageId, Types.BASE_TYPE_MASK, Types.BASE_SENT_FAILED_TYPE, Optional.of(threadId));
ApplicationDependencies.getDatabaseObserver().notifyMessageUpdateObservers(new MessageId(messageId, true));
ApplicationDependencies.getDatabaseObserver().notifyConversationListListeners();
}
use of org.thoughtcrime.securesms.database.model.MessageId in project Signal-Android by signalapp.
the class MmsDatabase method getViewedIncomingMessages.
@Override
@NonNull
public List<MarkedMessageInfo> getViewedIncomingMessages(long threadId) {
SQLiteDatabase db = databaseHelper.getSignalReadableDatabase();
String[] columns = new String[] { ID, RECIPIENT_ID, DATE_SENT, MESSAGE_BOX, THREAD_ID };
String where = THREAD_ID + " = ? AND " + VIEWED_RECEIPT_COUNT + " > 0 AND " + MESSAGE_BOX + " & " + Types.BASE_INBOX_TYPE + " = " + Types.BASE_INBOX_TYPE;
String[] args = SqlUtil.buildArgs(threadId);
try (Cursor cursor = db.query(getTableName(), columns, where, args, null, null, null, null)) {
if (cursor == null) {
return Collections.emptyList();
}
List<MarkedMessageInfo> results = new ArrayList<>(cursor.getCount());
while (cursor.moveToNext()) {
long messageId = CursorUtil.requireLong(cursor, ID);
RecipientId recipientId = RecipientId.from(CursorUtil.requireLong(cursor, RECIPIENT_ID));
long dateSent = CursorUtil.requireLong(cursor, DATE_SENT);
SyncMessageId syncMessageId = new SyncMessageId(recipientId, dateSent);
results.add(new MarkedMessageInfo(threadId, syncMessageId, new MessageId(messageId, true), null));
}
return results;
}
}
use of org.thoughtcrime.securesms.database.model.MessageId in project Signal-Android by signalapp.
the class SmsDatabase method updateTypeBitmask.
private void updateTypeBitmask(long id, long maskOff, long maskOn) {
SQLiteDatabase db = databaseHelper.getSignalWritableDatabase();
long threadId;
db.beginTransaction();
try {
db.execSQL("UPDATE " + TABLE_NAME + " SET " + TYPE + " = (" + TYPE + " & " + (Types.TOTAL_MASK - maskOff) + " | " + maskOn + " )" + " WHERE " + ID + " = ?", SqlUtil.buildArgs(id));
threadId = getThreadIdForMessage(id);
SignalDatabase.threads().updateSnippetTypeSilently(threadId);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
ApplicationDependencies.getDatabaseObserver().notifyMessageUpdateObservers(new MessageId(id, false));
ApplicationDependencies.getDatabaseObserver().notifyConversationListListeners();
}
use of org.thoughtcrime.securesms.database.model.MessageId in project Signal-Android by signalapp.
the class SendViewedReceiptJob method enqueue.
/**
* Enqueues all the necessary jobs for viewed receipts, ensuring that they're all within the
* maximum size.
*/
public static void enqueue(long threadId, @NonNull RecipientId recipientId, List<MarkedMessageInfo> markedMessageInfos) {
JobManager jobManager = ApplicationDependencies.getJobManager();
List<List<MarkedMessageInfo>> messageIdChunks = Util.chunk(markedMessageInfos, MAX_TIMESTAMPS);
if (messageIdChunks.size() > 1) {
Log.w(TAG, "Large receipt count! Had to break into multiple chunks. Total count: " + markedMessageInfos.size());
}
for (List<MarkedMessageInfo> chunk : messageIdChunks) {
List<Long> sentTimestamps = chunk.stream().map(info -> info.getSyncMessageId().getTimetamp()).collect(Collectors.toList());
List<MessageId> messageIds = chunk.stream().map(MarkedMessageInfo::getMessageId).collect(Collectors.toList());
jobManager.add(new SendViewedReceiptJob(threadId, recipientId, sentTimestamps, messageIds));
}
}
Aggregations