Skip to content

Commit

Permalink
Drop gift messages in MCPv2
Browse files Browse the repository at this point in the history
  • Loading branch information
valldrac committed Aug 24, 2023
1 parent 512531a commit 224d27b
Showing 1 changed file with 2 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -790,37 +790,8 @@ object DataMessageProcessor {

notifyTypingStoppedFromIncomingMessage(context, senderRecipient, threadRecipientId, metadata.sourceDeviceId)

val token = ReceiptCredentialPresentation(message.giftBadge.receiptCredentialPresentation.toByteArray()).serialize()
val giftBadge = GiftBadge.newBuilder()
.setRedemptionToken(ByteString.copyFrom(token))
.setRedemptionState(GiftBadge.RedemptionState.PENDING)
.build()

val insertResult: InsertResult? = try {
val mediaMessage = IncomingMediaMessage(
from = senderRecipient.id,
sentTimeMillis = envelope.timestamp,
serverTimeMillis = envelope.serverTimestamp,
receivedTimeMillis = receivedTime,
expiresIn = message.expireTimer.seconds.inWholeMilliseconds,
isUnidentified = metadata.sealedSender,
body = Base64.encodeBytes(giftBadge.toByteArray()),
serverGuid = envelope.serverGuid,
giftBadge = giftBadge
)

SignalDatabase.messages.insertSecureDecryptedMessageInbox(mediaMessage, -1).orNull()
} catch (e: MmsException) {
throw StorageFailedException(e, metadata.sourceServiceId.toString(), metadata.sourceDeviceId)
}

return if (insertResult != null) {
ApplicationDependencies.getMessageNotifier().updateNotification(context, ConversationId.forConversation(insertResult.threadId))
TrimThreadJob.enqueueAsync(insertResult.threadId)
MessageId(insertResult.messageId)
} else {
null
}
warn(envelope.timestamp, "Dropping unsupported gift badge message.")
return null
}

@Throws(StorageFailedException::class)
Expand Down

0 comments on commit 224d27b

Please sign in to comment.