use of org.thoughtcrime.securesms.jobs.TrimThreadJob in project Signal-Android by WhisperSystems.
the class MmsDatabase method insertMessageOutbox.
public long insertMessageOutbox(@NonNull MasterSecretUnion masterSecret, @NonNull OutgoingMediaMessage message, long threadId, boolean forceSms) throws MmsException {
long type = Types.BASE_SENDING_TYPE;
if (masterSecret.getMasterSecret().isPresent())
type |= Types.ENCRYPTION_SYMMETRIC_BIT;
else
type |= Types.ENCRYPTION_ASYMMETRIC_BIT;
if (message.isSecure())
type |= (Types.SECURE_MESSAGE_BIT | Types.PUSH_MESSAGE_BIT);
if (forceSms)
type |= Types.MESSAGE_FORCE_SMS_BIT;
if (message.isGroup()) {
if (((OutgoingGroupMediaMessage) message).isGroupUpdate())
type |= Types.GROUP_UPDATE_BIT;
else if (((OutgoingGroupMediaMessage) message).isGroupQuit())
type |= Types.GROUP_QUIT_BIT;
}
if (message.isExpirationUpdate()) {
type |= Types.EXPIRATION_TIMER_UPDATE_BIT;
}
List<String> recipientNumbers = message.getRecipients().toNumberStringList(true);
MmsAddresses addresses;
if (!message.getRecipients().isSingleRecipient() && message.getDistributionType() == ThreadDatabase.DistributionTypes.BROADCAST) {
addresses = MmsAddresses.forBcc(recipientNumbers);
} else {
addresses = MmsAddresses.forTo(recipientNumbers);
}
ContentValues contentValues = new ContentValues();
contentValues.put(DATE_SENT, message.getSentTimeMillis());
contentValues.put(MESSAGE_TYPE, PduHeaders.MESSAGE_TYPE_SEND_REQ);
contentValues.put(MESSAGE_BOX, type);
contentValues.put(THREAD_ID, threadId);
contentValues.put(READ, 1);
contentValues.put(DATE_RECEIVED, System.currentTimeMillis());
contentValues.put(SUBSCRIPTION_ID, message.getSubscriptionId());
contentValues.put(EXPIRES_IN, message.getExpiresIn());
if (message.getRecipients().isSingleRecipient()) {
try {
contentValues.put(RECEIPT_COUNT, earlyReceiptCache.remove(message.getSentTimeMillis(), canonicalizeNumber(context, message.getRecipients().getPrimaryRecipient().getNumber())));
} catch (InvalidNumberException e) {
Log.w(TAG, e);
}
}
contentValues.remove(ADDRESS);
long messageId = insertMediaMessage(masterSecret, addresses, message.getBody(), message.getAttachments(), contentValues);
DatabaseFactory.getThreadDatabase(context).setLastSeen(threadId);
jobManager.add(new TrimThreadJob(context, threadId));
return messageId;
}
use of org.thoughtcrime.securesms.jobs.TrimThreadJob in project Signal-Android by WhisperSystems.
the class MmsDatabase method markIncomingNotificationReceived.
public void markIncomingNotificationReceived(long threadId) {
notifyConversationListeners(threadId);
DatabaseFactory.getThreadDatabase(context).update(threadId, true);
if (org.thoughtcrime.securesms.util.Util.isDefaultSmsProvider(context)) {
DatabaseFactory.getThreadDatabase(context).setUnread(threadId);
}
jobManager.add(new TrimThreadJob(context, threadId));
}
Aggregations