Add support for new backup calls proto and call links.

This commit is contained in:
Clark
2024-04-30 10:05:31 -04:00
committed by Greyson Parrelli
parent 333fa22c96
commit 1223c3c768
12 changed files with 502 additions and 373 deletions

View File

@@ -91,18 +91,22 @@ class CallLinkTable(context: Context, databaseHelper: SignalDatabase) : Database
fun insertCallLink(
callLink: CallLink
) {
writableDatabase.withinTransaction { db ->
): RecipientId {
val recipientId: RecipientId = writableDatabase.withinTransaction { db ->
val recipientId = SignalDatabase.recipients.getOrInsertFromCallLinkRoomId(callLink.roomId)
db
.insertInto(TABLE_NAME)
.values(CallLinkSerializer.serialize(callLink.copy(recipientId = recipientId)))
.run()
recipientId
}
ApplicationDependencies.getDatabaseObserver().notifyCallLinkObservers(callLink.roomId)
ApplicationDependencies.getDatabaseObserver().notifyCallUpdateObservers()
return recipientId!!
}
fun updateCallLinkCredentials(
@@ -402,7 +406,7 @@ class CallLinkTable(context: Context, databaseHelper: SignalDatabase) : Database
}
}
private object CallLinkDeserializer : Serializer<CallLink, Cursor> {
object CallLinkDeserializer : Serializer<CallLink, Cursor> {
override fun serialize(data: CallLink): Cursor {
throw UnsupportedOperationException()
}

View File

@@ -5,7 +5,7 @@ import androidx.annotation.Nullable;
import org.signal.core.util.Base64;
import org.signal.core.util.logging.Log;
import org.thoughtcrime.securesms.backup.v2.proto.GroupCallChatUpdate;
import org.thoughtcrime.securesms.backup.v2.proto.GroupCall;
import org.thoughtcrime.securesms.database.model.databaseprotos.GroupCallUpdateDetails;
import org.thoughtcrime.securesms.recipients.Recipient;
import org.whispersystems.signalservice.api.push.ServiceId;
@@ -28,7 +28,7 @@ public final class GroupCallUpdateDetailsUtil {
/**
* Generates a group chat update message body from backup data
*/
public static @NonNull String createBodyFromBackup(@NonNull GroupCallChatUpdate groupCallChatUpdate) {
public static @NonNull String createBodyFromBackup(@NonNull GroupCall groupCallChatUpdate) {
ServiceId.ACI startedCall = groupCallChatUpdate.startedCallAci != null ? ServiceId.ACI.parseOrNull(groupCallChatUpdate.startedCallAci) : null;
GroupCallUpdateDetails details = new GroupCallUpdateDetails.Builder()
@@ -36,15 +36,7 @@ public final class GroupCallUpdateDetailsUtil {
.startedCallTimestamp(groupCallChatUpdate.startedCallTimestamp)
.endedCallTimestamp(groupCallChatUpdate.endedCallTimestamp)
.isCallFull(false)
.inCallUuids(groupCallChatUpdate.inCallAcis.stream()
.filter(Objects::nonNull)
.map(ServiceId.ACI::parseOrNull)
.filter(Objects::nonNull)
.map(ServiceId.ACI::toString)
.collect(Collectors.toList())
)
.isRingingOnLocalDevice(false)
.localUserJoined(groupCallChatUpdate.localUserJoined != GroupCallChatUpdate.LocalUserJoined.DID_NOT_JOIN)
.build();
return Base64.encodeWithPadding(details.encode());