Skip to content

Commit

Permalink
Merge branch 'molly-7.8'
Browse files Browse the repository at this point in the history
  • Loading branch information
valldrac committed May 23, 2024
2 parents 2b776cc + 1625169 commit 09a4609
Show file tree
Hide file tree
Showing 281 changed files with 20,952 additions and 14,018 deletions.
6 changes: 3 additions & 3 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ apply {
from("fix-profm.gradle")
}

val canonicalVersionCode = 1416
val canonicalVersionName = "7.6.2"
val mollyRevision = 2
val canonicalVersionCode = 1421
val canonicalVersionName = "7.8.1"
val mollyRevision = 1

val postFixSize = 100

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ import org.signal.libsignal.messagebackup.MessageBackup
import org.signal.libsignal.messagebackup.MessageBackupKey
import org.signal.libsignal.zkgroup.profiles.ProfileKey
import org.thoughtcrime.securesms.backup.v2.proto.AccountData
import org.thoughtcrime.securesms.backup.v2.proto.AdHocCall
import org.thoughtcrime.securesms.backup.v2.proto.BackupInfo
import org.thoughtcrime.securesms.backup.v2.proto.BodyRange
import org.thoughtcrime.securesms.backup.v2.proto.Call
import org.thoughtcrime.securesms.backup.v2.proto.CallChatUpdate
import org.thoughtcrime.securesms.backup.v2.proto.Chat
import org.thoughtcrime.securesms.backup.v2.proto.ChatItem
import org.thoughtcrime.securesms.backup.v2.proto.ChatUpdateMessage
Expand All @@ -34,8 +33,7 @@ import org.thoughtcrime.securesms.backup.v2.proto.ExpirationTimerChatUpdate
import org.thoughtcrime.securesms.backup.v2.proto.FilePointer
import org.thoughtcrime.securesms.backup.v2.proto.Frame
import org.thoughtcrime.securesms.backup.v2.proto.Group
import org.thoughtcrime.securesms.backup.v2.proto.GroupCallChatUpdate
import org.thoughtcrime.securesms.backup.v2.proto.IndividualCallChatUpdate
import org.thoughtcrime.securesms.backup.v2.proto.IndividualCall
import org.thoughtcrime.securesms.backup.v2.proto.MessageAttachment
import org.thoughtcrime.securesms.backup.v2.proto.ProfileChangeChatUpdate
import org.thoughtcrime.securesms.backup.v2.proto.Quote
Expand Down Expand Up @@ -198,8 +196,7 @@ class ImportExportTest {
masterKey = TestRecipientUtils.generateGroupMasterKey().toByteString(),
whitelisted = true,
hideStory = false,
storySendMode = Group.StorySendMode.ENABLED,
name = "Cool Group $i"
storySendMode = Group.StorySendMode.ENABLED
)
)
)
Expand Down Expand Up @@ -265,8 +262,7 @@ class ImportExportTest {
masterKey = TestRecipientUtils.generateGroupMasterKey().toByteString(),
whitelisted = random.trueWithProbability(0.9f),
hideStory = random.trueWithProbability(0.1f),
storySendMode = if (random.trueWithProbability(0.9f)) Group.StorySendMode.ENABLED else Group.StorySendMode.DISABLED,
name = "Cool Group $i"
storySendMode = if (random.trueWithProbability(0.9f)) Group.StorySendMode.ENABLED else Group.StorySendMode.DISABLED
)
)
)
Expand Down Expand Up @@ -435,7 +431,12 @@ class ImportExportTest {
whitelisted = true,
hideStory = true,
storySendMode = Group.StorySendMode.ENABLED,
name = "Cool test group"
snapshot = Group.GroupSnapshot(
title = Group.GroupAttributeBlob(title = "Group Cool"),
description = Group.GroupAttributeBlob(descriptionText = "Description"),
version = 10,
disappearingMessagesTimer = Group.GroupAttributeBlob(disappearingMessagesDuration = 1500000)
)
)
),
Recipient(
Expand All @@ -445,7 +446,12 @@ class ImportExportTest {
whitelisted = false,
hideStory = false,
storySendMode = Group.StorySendMode.DEFAULT,
name = "Cool test group"
snapshot = Group.GroupSnapshot(
title = Group.GroupAttributeBlob(title = "Group Cool"),
description = Group.GroupAttributeBlob(descriptionText = "Description"),
version = 10,
disappearingMessagesTimer = Group.GroupAttributeBlob(disappearingMessagesDuration = 1500000)
)
)
)
)
Expand Down Expand Up @@ -596,8 +602,7 @@ class ImportExportTest {
masterKey = TestRecipientUtils.generateGroupMasterKey().toByteString(),
whitelisted = true,
hideStory = true,
storySendMode = Group.StorySendMode.DEFAULT,
name = "Cool test group"
storySendMode = Group.StorySendMode.DEFAULT
)
),
Chat(
Expand All @@ -615,113 +620,64 @@ class ImportExportTest {
}

@Test
fun calls() {
val individualCalls = ArrayList<Call>()
val groupCalls = ArrayList<Call>()
val states = arrayOf(Call.State.MISSED, Call.State.COMPLETED, Call.State.DECLINED_BY_USER, Call.State.DECLINED_BY_NOTIFICATION_PROFILE)
val types = arrayOf(Call.Type.VIDEO_CALL, Call.Type.AD_HOC_CALL, Call.Type.AUDIO_CALL)
var id = 1L
var timestamp = 12345L

fun individualCalls() {
val individualCalls = ArrayList<ChatItem>()
val states = arrayOf(IndividualCall.State.ACCEPTED, IndividualCall.State.NOT_ACCEPTED, IndividualCall.State.MISSED, IndividualCall.State.MISSED_NOTIFICATION_PROFILE)
val oldStates = arrayOf(IndividualCall.State.ACCEPTED, IndividualCall.State.MISSED)
val types = arrayOf(IndividualCall.Type.VIDEO_CALL, IndividualCall.Type.AUDIO_CALL)
val directions = arrayOf(IndividualCall.Direction.OUTGOING, IndividualCall.Direction.INCOMING)
var sentTime = 0L
var callId = 1L
val startedAci = TestRecipientUtils.nextAci().toByteString()
for (state in states) {
for (type in types) {
individualCalls.add(
Call(
callId = id++,
conversationRecipientId = 3,
type = type,
state = state,
timestamp = timestamp++,
ringerRecipientId = 3,
outgoing = true
)
)
individualCalls.add(
Call(
callId = id++,
conversationRecipientId = 3,
type = type,
state = state,
timestamp = timestamp++,
ringerRecipientId = selfRecipient.id,
outgoing = false
for (direction in directions) {
// With call id
individualCalls.add(
ChatItem(
chatId = 1,
authorId = selfRecipient.id,
dateSent = sentTime++,
sms = false,
directionless = ChatItem.DirectionlessMessageDetails(),
updateMessage = ChatUpdateMessage(
individualCall = IndividualCall(
callId = callId++,
type = type,
state = state,
direction = direction
)
)
)
)
)
}
}
groupCalls.add(
Call(
callId = id++,
conversationRecipientId = 4,
type = Call.Type.GROUP_CALL,
state = state,
timestamp = timestamp++,
ringerRecipientId = 3,
outgoing = true
)
)
groupCalls.add(
Call(
callId = id++,
conversationRecipientId = 4,
type = Call.Type.GROUP_CALL,
state = state,
timestamp = timestamp++,
ringerRecipientId = selfRecipient.id,
outgoing = false
)
)
}

var sentTime = 0L
val individualCallChatItems = individualCalls.map { call ->
ChatItem(
chatId = 1,
authorId = selfRecipient.id,
dateSent = sentTime++,
sms = false,
incoming = ChatItem.IncomingMessageDetails(
dateReceived = sentTime + 1,
dateServerSent = sentTime,
read = true,
sealedSender = true
),
updateMessage = ChatUpdateMessage(
callingMessage = CallChatUpdate(
callMessage = IndividualCallChatUpdate(
type = IndividualCallChatUpdate.Type.INCOMING_AUDIO_CALL
)
)
)
)
}.toTypedArray()

val startedAci = TestRecipientUtils.nextAci().toByteString()
val groupCallChatItems = groupCalls.map { call ->
ChatItem(
chatId = 1,
authorId = selfRecipient.id,
dateSent = sentTime++,
sms = false,
incoming = ChatItem.IncomingMessageDetails(
dateReceived = sentTime + 1,
dateServerSent = sentTime,
read = true,
sealedSender = true
),
updateMessage = ChatUpdateMessage(
callingMessage = CallChatUpdate(
groupCall = GroupCallChatUpdate(
startedCallAci = startedAci,
startedCallTimestamp = 0,
endedCallTimestamp = 0,
localUserJoined = GroupCallChatUpdate.LocalUserJoined.JOINED,
inCallAcis = emptyList()
for (state in oldStates) {
for (type in types) {
for (direction in directions) {
if (state == IndividualCall.State.MISSED && direction == IndividualCall.Direction.OUTGOING) continue
// Without call id
individualCalls.add(
ChatItem(
chatId = 1,
authorId = selfRecipient.id,
dateSent = sentTime++,
sms = false,
directionless = ChatItem.DirectionlessMessageDetails(),
updateMessage = ChatUpdateMessage(
individualCall = IndividualCall(
callId = null,
type = type,
state = state,
direction = direction
)
)
)
)
)
)
}.toTypedArray()

}
}
}
importExport(
*standardFrames,
Recipient(
Expand All @@ -748,8 +704,7 @@ class ImportExportTest {
masterKey = TestRecipientUtils.generateGroupMasterKey().toByteString(),
whitelisted = true,
hideStory = true,
storySendMode = Group.StorySendMode.DEFAULT,
name = "Cool test group"
storySendMode = Group.StorySendMode.DEFAULT
)
),
Chat(
Expand All @@ -763,10 +718,7 @@ class ImportExportTest {
dontNotifyForMentionsIfMuted = true,
wallpaper = null
),
*individualCalls.toArray(),
*groupCalls.toArray(),
*individualCallChatItems,
*groupCallChatItems
*individualCalls.toArray()
)
}

Expand Down Expand Up @@ -1003,7 +955,7 @@ class ImportExportTest {
chatId = 1,
authorId = alice.id,
dateSent = 101,
expireStartDate = null,
expireStartDate = 0,
expiresInMs = TimeUnit.DAYS.toMillis(1),
sms = false,
incoming = ChatItem.IncomingMessageDetails(
Expand Down Expand Up @@ -1435,7 +1387,7 @@ class ImportExportTest {
is Recipient -> writer.write(Frame(recipient = obj))
is Chat -> writer.write(Frame(chat = obj))
is ChatItem -> writer.write(Frame(chatItem = obj))
is Call -> writer.write(Frame(call = obj))
is AdHocCall -> writer.write(Frame(adHocCall = obj))
is StickerPack -> writer.write(Frame(stickerPack = obj))
else -> Assert.fail("invalid object $obj")
}
Expand Down Expand Up @@ -1496,7 +1448,7 @@ class ImportExportTest {
is Recipient -> writer.write(Frame(recipient = obj))
is Chat -> writer.write(Frame(chat = obj))
is ChatItem -> writer.write(Frame(chatItem = obj))
is Call -> writer.write(Frame(call = obj))
is AdHocCall -> writer.write(Frame(adHocCall = obj))
is StickerPack -> writer.write(Frame(stickerPack = obj))
else -> Assert.fail("invalid object $obj")
}
Expand Down Expand Up @@ -1527,8 +1479,8 @@ class ImportExportTest {
val chatsExported = ArrayList<Chat>()
val chatItemsImported = ArrayList<ChatItem>()
val chatItemsExported = ArrayList<ChatItem>()
val callsImported = ArrayList<Call>()
val callsExported = ArrayList<Call>()
val callsImported = ArrayList<AdHocCall>()
val callsExported = ArrayList<AdHocCall>()
val stickersImported = ArrayList<StickerPack>()
val stickersExported = ArrayList<StickerPack>()

Expand All @@ -1538,7 +1490,7 @@ class ImportExportTest {
f.recipient != null -> recipientsImported.add(f.recipient!!)
f.chat != null -> chatsImported.add(f.chat!!)
f.chatItem != null -> chatItemsImported.add(f.chatItem!!)
f.call != null -> callsImported.add(f.call!!)
f.adHocCall != null -> callsImported.add(f.adHocCall!!)
f.stickerPack != null -> stickersImported.add(f.stickerPack!!)
}
}
Expand All @@ -1549,7 +1501,7 @@ class ImportExportTest {
f.recipient != null -> recipientsExported.add(f.recipient!!)
f.chat != null -> chatsExported.add(f.chat!!)
f.chatItem != null -> chatItemsExported.add(f.chatItem!!)
f.call != null -> callsExported.add(f.call!!)
f.adHocCall != null -> callsExported.add(f.adHocCall!!)
f.stickerPack != null -> stickersExported.add(f.stickerPack!!)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package org.thoughtcrime.securesms.database

import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNotEquals
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Rule
Expand Down Expand Up @@ -75,21 +74,6 @@ class GroupTableTest {
assertEquals(2, groups.size)
}

@Test
fun givenGroups_whenIQueryGroupsByMembership_thenIExpectBothGroups() {
insertPushGroup()
insertMmsGroup(members = listOf(harness.others[1]))

val groups = groupTable.queryGroupsByMembership(
setOf(harness.self.id, harness.others[1]),
includeInactive = false,
excludeV1 = false,
excludeMms = false
)

assertEquals(2, groups.cursor?.count)
}

@Test
fun givenGroups_whenIGetGroups_thenIExpectBothGroups() {
insertPushGroup()
Expand Down Expand Up @@ -181,15 +165,6 @@ class GroupTableTest {
assertFalse(actual)
}

@Test
fun givenAGroup_whenIUpdateMembers_thenIExpectUpdatedMembers() {
val v2Group = insertPushGroup()
groupTable.updateMembers(v2Group, listOf(harness.self.id, harness.others[1]))
val groupRecord = groupTable.getGroup(v2Group)

assertEquals(setOf(harness.self.id, harness.others[1]), groupRecord.get().members.toSet())
}

@Test
fun givenTwoGroupsWithoutMembers_whenIQueryThem_thenIExpectEach() {
val g1 = insertPushGroup(listOf())
Expand Down
Loading

0 comments on commit 09a4609

Please sign in to comment.