Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rebuild Disappearing Messages #1313

Merged
merged 282 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
282 commits
Select commit Hold shift + click to select a range
2494483
Clear open group inbox messages
Dec 16, 2022
d23b849
Group settings refactor
Dec 16, 2022
b18cebe
Fix conversation title alignment
Dec 16, 2022
9e004cd
Expiration config tweaks
Dec 16, 2022
8a51c88
Fix legacy expiration timer update handling
Dec 18, 2022
065417e
Add synced expiries job
Dec 19, 2022
70abf8a
Close expiration settings screen after save
Dec 19, 2022
d52fc4d
Default to first expiration timer option
Dec 19, 2022
9d056ff
Update disappearing messages client status banner display logic
Dec 19, 2022
644484b
Restore disappearing messages menu item
Dec 19, 2022
487f99a
Fix expiry timer update handling
Dec 19, 2022
3c6b93b
Merge branch 'dev' into disappearing-messages
Dec 19, 2022
42923b5
Fix message disappearance after send
Dec 20, 2022
304bf42
Fix expiry info disappearance
Dec 20, 2022
92b3073
Disappearing messages job update
Dec 21, 2022
7d25fd9
Start disappearing after sent
Dec 21, 2022
4cfa800
Refactor
Dec 21, 2022
2ed2712
Fix disappearing messages menu item title
Dec 21, 2022
8f99b5a
Start disappearing after sent for closed groups
Dec 21, 2022
2228bfc
Fix expiry start
Dec 21, 2022
18ff597
Fix outdated client banner display
Dec 21, 2022
1ba8f9f
Remove incomplete SyncedExpiry implementation
Dec 21, 2022
e460e08
Cleanup
Dec 21, 2022
03c95f1
Expire group update info and call messages
Dec 21, 2022
7c6e467
Expire data extraction messages
Dec 22, 2022
f600e4d
Add accessibility id's
Dec 22, 2022
03766d5
Disappear after read info refactor
Dec 22, 2022
6769789
Fix call info expiry
Dec 22, 2022
1f0a076
Cleanup refactor
Dec 22, 2022
cdbf76c
Only allow admins to change disappearing messages config
Dec 22, 2022
b1f6953
Apply conversation config on messages being converted to protobuf
Dec 22, 2022
0f4e18f
Update group admin check
Dec 23, 2022
06947b6
fix: handle the correct legacy setting of expiring config based on th…
0x330a Jan 11, 2023
b6a4fb9
refactor: fix star imports
0x330a Jan 11, 2023
2048e08
fix: legacy message deletions working better now
0x330a Jan 11, 2023
f0aba3a
fix: look at early expiring incoming messages for delete after read
0x330a Jan 13, 2023
dd51c9a
refactor: move the legacy/updated expiring and add extra condition it…
0x330a Jan 16, 2023
ba87cbc
fix: standardise call menu recipient function to share with the new a…
0x330a Jan 16, 2023
325abe0
Merge remote-tracking branch 'upstream/dev' into disappearing-messages
0x330a Jul 5, 2023
4c9a237
fix: compile errors
0x330a Jul 6, 2023
07e1d80
Merge remote-tracking branch 'upstream/dev' into disappearing-messages
0x330a Jul 18, 2023
74ee433
fix: more merge conflict compile issues
0x330a Jul 18, 2023
68248db
fix: compile errors to build
0x330a Jul 19, 2023
36df2b3
Merge remote-tracking branch 'origin/disappearing-messages' into disa…
0x330a Jul 25, 2023
6bd970c
build: rebuild protos
0x330a Jul 25, 2023
57d4327
fix: compile issues
0x330a Jul 25, 2023
7f7971e
Merge remote-tracking branch 'upstream/dev' into disappearing-messages
0x330a Jul 25, 2023
41c05b1
fix: compile issues and deprecate java for kotlin lint
0x330a Jul 26, 2023
2acb7b5
refactor: remove unused parameter
0x330a Jul 26, 2023
6998ae7
fix: use the env->IsSameObject function correctly checking class types
0x330a Jul 26, 2023
0e30d14
refactor: start looking at how to incorporate the user config changes…
0x330a Jul 26, 2023
87d76b2
refactor: moving radio indexes out of expiration configuration
0x330a Jul 27, 2023
7f4db64
refactor: refactor ExpirationConfigurationDatabase to return a specif…
0x330a Jul 27, 2023
19083e2
refactor: use the shared config expiry mode types instead of custom p…
0x330a Jul 28, 2023
bcb2071
fix: compile issues and dependencies resolved to use shared configs t…
0x330a Jul 31, 2023
06c0ab3
refactor: let frontend use the normal types and enabled options prope…
0x330a Aug 2, 2023
8db92cc
feat: add user config integrated into config sync
0x330a Aug 3, 2023
2e3d503
fix: issue for overwriting local config with an outdated user config …
0x330a Aug 4, 2023
9dc8f18
fix: prevent message request response from being deleted by any config
0x330a Aug 9, 2023
317ecf6
refactor: making radio options and adapter and list items generic
0x330a Aug 9, 2023
9faa400
refactor: use generic option adapters, fix compile issues
0x330a Aug 10, 2023
d6dd7a8
fix: error with legacy type and set type check
0x330a Aug 16, 2023
60f396a
Fix ExpSettingsViewModel
bemusementpark Aug 21, 2023
9123dd9
Utilise typealias for RadioOptions
bemusementpark Aug 21, 2023
78eef35
Add radioOption DSL
bemusementpark Aug 21, 2023
d9c48ec
Move getDeleteOptions() to ViewModel
bemusementpark Aug 21, 2023
6818be2
Remove trailing divider
bemusementpark Aug 21, 2023
621c74c
Improve animations
bemusementpark Aug 22, 2023
58b5815
Simplify
bemusementpark Aug 22, 2023
0ed9731
Make ExpiryMode non-null in config
bemusementpark Aug 23, 2023
5142c45
Move recipient into state
bemusementpark Aug 23, 2023
71b2544
Use compose
bemusementpark Aug 24, 2023
7a70564
Fix fading edge
bemusementpark Aug 26, 2023
cc5cd51
Fix type radio button
bemusementpark Aug 26, 2023
6602f1b
Show correct options for note to self
bemusementpark Aug 26, 2023
97f28fd
Respect option selected in note to self
bemusementpark Aug 26, 2023
b65a383
Reinstate group footer
bemusementpark Aug 27, 2023
c228606
Add event flow
bemusementpark Aug 27, 2023
9f6dd72
Cleanup
bemusementpark Aug 27, 2023
bfd2370
Add disabled group options
bemusementpark Aug 28, 2023
0b11e18
Merge branch 'dev' into disappear-2
bemusementpark Aug 28, 2023
e95c842
Add preview for all states
bemusementpark Aug 31, 2023
bc83c3d
Fix outline button colors
bemusementpark Aug 31, 2023
88223be
Cleanup
bemusementpark Aug 31, 2023
4e42438
Improve routing
bemusementpark Aug 31, 2023
58c4467
Implement default times
bemusementpark Aug 31, 2023
ef24fb0
Fix test
bemusementpark Aug 31, 2023
ee6ce84
Fix TitledRadioButton ripple downstate
bemusementpark Aug 31, 2023
8b320bb
Fix onSetClick
bemusementpark Sep 1, 2023
371d06d
Simplify
bemusementpark Sep 1, 2023
519bf38
Merge branch 'dev' into disappear-2
bemusementpark Sep 1, 2023
cdb7a5f
Fix time option not selecting when type options are off
bemusementpark Sep 2, 2023
ba0ca7d
Remove Storage#setExpirationTimer
bemusementpark Sep 2, 2023
63713ae
Show debug time in 1-1 conversations
bemusementpark Sep 2, 2023
f1d3518
Fix groups
bemusementpark Sep 4, 2023
2d89dda
Fix debug time ordering
bemusementpark Sep 4, 2023
bb36b93
Simplify list
bemusementpark Sep 4, 2023
96afa8d
Fix expiry timer millis conversion
bemusementpark Sep 5, 2023
0c9d050
Fix nts options and add 10 second debug time
bemusementpark Sep 7, 2023
14938d2
Fix note-to-self not disappearing
bemusementpark Sep 14, 2023
349247e
Hide disappearing header for note-to-self
bemusementpark Sep 14, 2023
5ce100a
Select currently persisted time when user toggles back to currently p…
bemusementpark Sep 14, 2023
885df1e
Refactor
bemusementpark Sep 17, 2023
a7111b0
Simplify VM
bemusementpark Sep 19, 2023
92cae9a
Add 1 day after read test
bemusementpark Sep 19, 2023
987bd89
Add off test
bemusementpark Sep 19, 2023
3bf87ff
Add 1 day after read
bemusementpark Sep 19, 2023
e700641
Refactor test
bemusementpark Sep 19, 2023
668bf46
Fix tests
bemusementpark Sep 20, 2023
cd0022e
Add old config tests
bemusementpark Sep 20, 2023
7738b19
Add non admin group test
bemusementpark Sep 20, 2023
c492a74
Hide set button when disabled
bemusementpark Sep 20, 2023
9968b5d
Fix group admin test
bemusementpark Sep 20, 2023
ec8b89b
Minor test refactor
bemusementpark Sep 20, 2023
ebbe928
Sync disappear after read with other devices
bemusementpark Oct 4, 2023
149c817
Fix cards visibility pre API 28
bemusementpark Oct 5, 2023
3566260
Remove sarrays__off
bemusementpark Oct 5, 2023
82a94ee
Fix control message accessibility id
bemusementpark Oct 6, 2023
892e4b7
Merge branch 'dev' into disappear-2
bemusementpark Oct 6, 2023
5986196
Accessibility
bemusementpark Oct 6, 2023
d92e798
feat: add timestamp update based on message merging success
0x330a Oct 6, 2023
b211c8b
Rename ExpirationSettings to DisappearingMessages
bemusementpark Oct 9, 2023
17f41d7
Improve ui vm separation
bemusementpark Oct 9, 2023
3d6c7db
Simplify MarkReadReceiver#process
bemusementpark Oct 9, 2023
c86b229
Add mms and sms table to loki db
bemusementpark Oct 10, 2023
77f951c
Use separate tables for mms and sms in LokiMessageDatabase
bemusementpark Oct 10, 2023
f71c560
Merge branch 'dev' into disappear-2
bemusementpark Oct 10, 2023
e06f9ee
refactor: change storage adding contacts to create one on ones with a…
0x330a Oct 10, 2023
d37e724
Call expire after read DaR messages
bemusementpark Oct 13, 2023
88e7ef1
Fix db typo
bemusementpark Oct 13, 2023
793fe63
Merge branch 'dev' into disappear-2
bemusementpark Oct 13, 2023
008bbd8
Optimise DAR message expiry update & lookup
bemusementpark Oct 14, 2023
c24741a
Remove erroneous disappearing message validations
bemusementpark Oct 15, 2023
f6a736b
Merge remote-tracking branch 'origin/master' into disappear-2
0x330a Oct 15, 2023
acb1181
feat: add more testing functionality for the expected current / updat…
0x330a Oct 15, 2023
73538a4
Remove log
bemusementpark Oct 16, 2023
8145a7d
Merge branch 'disappear-2' of github.com:bemusementpark/session-andro…
bemusementpark Oct 16, 2023
019a864
Fix timestamps
bemusementpark Oct 16, 2023
2d0c439
refactor: use just the storage setExpirationConfiguration function
0x330a Oct 16, 2023
8649420
Fix group disappearing messages not opening
bemusementpark Oct 19, 2023
b2f92bc
Add contentDescriptions to radio buttons
bemusementpark Oct 19, 2023
8399771
Add contentDescription to settingsPager
bemusementpark Oct 19, 2023
a9467c7
[SES-1203] Disable radio buttons
bemusementpark Oct 20, 2023
2228a05
Fix control message text
bemusementpark Oct 26, 2023
617dbc8
Remove unused ConversationItemFooter
bemusementpark Oct 27, 2023
61c51ec
Remove timer from message view
bemusementpark Oct 27, 2023
7b533f3
Fix timer color
bemusementpark Oct 30, 2023
a108e3b
Show timer in status
bemusementpark Oct 31, 2023
e3011c5
Fix padding and ordering
bemusementpark Oct 31, 2023
1b5b7cf
Use animated timer in control message
bemusementpark Oct 31, 2023
555209b
Fix animation
bemusementpark Nov 1, 2023
0493d24
feat: update libsession latest stable
0x330a Nov 1, 2023
1c8612c
Migrate db to autoincrement id for sms and mms
bemusementpark Nov 6, 2023
b0447cf
Fix gap under messages
bemusementpark Nov 6, 2023
2909990
Pick correct config on receive message
bemusementpark Nov 10, 2023
a312ef2
Simplify ExpirationTimerUpdate
bemusementpark Nov 10, 2023
806cb21
Fix disappearing off icon
bemusementpark Nov 10, 2023
d12bce5
feat: add basic last sent legacy message DB migration and creation fo…
0x330a Nov 12, 2023
56878db
refactor: add sender to be the person to trigger the legacy message s…
0x330a Nov 12, 2023
565c92f
fix: clear on updated legacy message from existing legacy thread reci…
0x330a Nov 12, 2023
d3911fb
Fix legacy options
bemusementpark Nov 13, 2023
fc9ea46
Merge branch 'disappear-2' of github.com:bemusementpark/session-andro…
bemusementpark Nov 13, 2023
725ad43
Fix timer icon flashes expired
bemusementpark Nov 15, 2023
4ed5b57
Fix read/write legacy
bemusementpark Nov 15, 2023
d6ba786
fix: activate the banner only if conversation is in expiring mode not…
0x330a Nov 16, 2023
eb97c69
Fix disappearing messages proto OFF message
bemusementpark Nov 20, 2023
8cc26b8
Fix contentDescriptions
bemusementpark Nov 20, 2023
7bd43b1
Fix control messages
bemusementpark Nov 28, 2023
a5a226b
Allow legacy expiration updates when flag is off
bemusementpark Nov 28, 2023
eecea12
Add set button contentDescription
bemusementpark Nov 29, 2023
a4d3fa8
Convert ExpiringMessageManager to Kotlin
bemusementpark Nov 30, 2023
71b2f1e
Hold onto last incoming and outgoing expiration update for 1 on 1 convos
bemusementpark Dec 5, 2023
c60b6d9
Add follow setting button
bemusementpark Dec 6, 2023
cf0dbff
Add follow setting button
bemusementpark Dec 7, 2023
988040b
Hide follow settings button when not applicable
bemusementpark Dec 15, 2023
06c2583
Use new strings for follow setting control message
bemusementpark Dec 15, 2023
a3b6f68
Refactor follow setting dialog
bemusementpark Dec 17, 2023
f921fc4
Remove unused markExpireStarted overload
bemusementpark Dec 18, 2023
7fd036d
Use same dummy hash as ios and desktop in getExpiries()
bemusementpark Dec 18, 2023
5a047da
Remove disappearing messages scheduling from VisibleMessageView
bemusementpark Jan 11, 2024
6b1628d
Use expiration in message instead of config
bemusementpark Jan 11, 2024
2e62bb1
Remove intuit expiry settings from normal messages
bemusementpark Jan 11, 2024
6fbae28
Fix sent messages disappearing when disappear is off
bemusementpark Jan 11, 2024
7b26de5
Fix disappear after read
bemusementpark Jan 11, 2024
12edb9d
Coerce disappear type to DaR for Calls and DataExtraction
bemusementpark Jan 12, 2024
1339c60
Fix received messages deleted instantly
bemusementpark Jan 12, 2024
c8377b0
Fix follow setting visible in groups
bemusementpark Jan 16, 2024
1ada072
Copy expiryMode from proto for all Messages
bemusementpark Jan 16, 2024
106305f
fix: outdated banner showing and updating on messages properly
0x330a Jan 18, 2024
a845d2f
Add Set button contentDescription
bemusementpark Jan 19, 2024
e2e5a36
Merge remote-tracking branch 'refs/remotes/origin/disappear-2' into d…
bemusementpark Jan 19, 2024
848dbd2
Start expiration at end of handling each message type treating call a…
bemusementpark Jan 22, 2024
43745ce
Retrieve expiry config from UpdateMessage for GroupsV1
bemusementpark Jan 23, 2024
97d6c99
Fix contentDescriptions
bemusementpark Jan 23, 2024
cb0327e
Fix follow setting contentDesc
bemusementpark Jan 23, 2024
4c7485f
Fix Message#expiryMode de/serialisation
bemusementpark Jan 30, 2024
e7a5be2
Fix ExpirationTimerUpdate deserialisation
bemusementpark Feb 2, 2024
246e8bf
Fix messages not marked as read onScroll when message count is unchanged
bemusementpark Feb 2, 2024
a326c47
Don't start DaR timer view until it has actually started
bemusementpark Feb 2, 2024
a47bf23
Fix last seen channel being closed by consuming flow
bemusementpark Feb 4, 2024
730851d
Remove erroneous scheduleDeletion in marked read
bemusementpark Feb 4, 2024
c7ffa61
Simplify MarkReadReceiver
bemusementpark Feb 5, 2024
f3bb2e5
Add new call control message UI with timer icon above
bemusementpark Feb 5, 2024
ace7e3b
Don't delete old call messages on new call message
bemusementpark Feb 6, 2024
3fa4122
Tweak call message style
bemusementpark Feb 6, 2024
ac37b2b
Convert ConversationReactionOverlay to Kotlin
bemusementpark Feb 6, 2024
b8aa469
Add auto-delete subtitle to context menu
bemusementpark Feb 6, 2024
b56c3bd
Add expiration subtitle to Delete option in message context menu
bemusementpark Feb 7, 2024
779101d
Close MessageDetailsActivity when message is deleted
bemusementpark Feb 8, 2024
701e3cb
Close message context menu on delete
bemusementpark Feb 8, 2024
84e92e1
Fix context auto delete timer doesn't show if opened before successfu…
bemusementpark Feb 9, 2024
181dd15
Fix non-sms messages not deserialisable by kryo
bemusementpark Feb 9, 2024
637b7f8
Fix expiry mode application to Message
bemusementpark Feb 9, 2024
e4999e3
Merge branch 'dev' into disappear-2
bemusementpark Feb 9, 2024
1176273
Fix accessibility id
bemusementpark Feb 9, 2024
64a2b4a
Fix merge
bemusementpark Feb 9, 2024
610d717
Fix sent status accessibility id
bemusementpark Feb 9, 2024
8e4266d
Fix mms messages delete previous timer messages
bemusementpark Feb 9, 2024
91807db
Set delete in context menu to color destructive
bemusementpark Feb 13, 2024
128ae81
Add 30 seconds to disappearing debug settings
bemusementpark Feb 13, 2024
8293c12
Fix subtitle color
bemusementpark Feb 13, 2024
54b7e11
feat: update libsession-util to latest dev
0x330a Feb 16, 2024
7c4060a
Cleanup closedGroupMessage serialisation
bemusementpark Feb 17, 2024
74d96fa
Fix disappearing messages setting lost on group member change
bemusementpark Feb 17, 2024
9fd244d
Cleanup ConversationActionBarView
bemusementpark Feb 17, 2024
835fa68
Cleanup DisappearingMessagesActivity
bemusementpark Feb 17, 2024
d33de9c
Cleanup ConversationActivityV2
bemusementpark Feb 17, 2024
c5c3365
Cleanup ConversationReactionOverlay
bemusementpark Feb 17, 2024
88dfcee
Cleanup ConversationViewModel
bemusementpark Feb 17, 2024
403058c
Cleanup VisibleMessageView
bemusementpark Feb 17, 2024
4ead21c
Cleanup SmsDatabase
bemusementpark Feb 17, 2024
66dcae0
Cleanup Storage
bemusementpark Feb 17, 2024
2e50dc0
Cleanup MarkReadReceiver
bemusementpark Feb 17, 2024
398b5bf
Cleanup
bemusementpark Feb 18, 2024
ef50d63
Cleanup logs
bemusementpark Feb 18, 2024
c3b416f
Fix Message#isValid
bemusementpark Feb 19, 2024
a1fadcf
Disable closed group control messages disappear
bemusementpark Feb 19, 2024
f512177
Remove erroneous expiration on SharedConfigurationMessage
bemusementpark Feb 20, 2024
39df560
Don't shorten ttl of closedGroupControlMessage
bemusementpark Feb 20, 2024
3cd5ca4
Simplify ClosedGroupControlMessage#fromProto
bemusementpark Feb 20, 2024
affdf1c
Disable disappearing closed group messages
bemusementpark Feb 22, 2024
f6d351f
fix: remove disappearing config overwrite and fix EC key pair's pubke…
0x330a Feb 22, 2024
e8c61d6
fix: remove new group invite clearing flags and handling new configs …
0x330a Feb 22, 2024
19c3b63
Set thread to 14 days old when added from libSessionContacts
bemusementpark Feb 26, 2024
d143d8a
Fix old threads being set to 2 weeks ago
bemusementpark Feb 26, 2024
1a81c72
Set NTS to 14 days ago when created in updateUser
bemusementpark Feb 26, 2024
1c38fc0
Push empty convos to bottom and hide thread date when unknown
bemusementpark Feb 27, 2024
51f2c35
Remove log
bemusementpark Feb 27, 2024
22460df
Fix expiry not added to community invites
bemusementpark Feb 28, 2024
76f8e98
Remove logs in UpdateMessageBuilder
bemusementpark Feb 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -321,9 +321,9 @@ dependencies {
implementation "com.opencsv:opencsv:4.6"
testImplementation "junit:junit:$junitVersion"
testImplementation 'org.assertj:assertj-core:3.11.1'
testImplementation "org.mockito:mockito-inline:4.10.0"
testImplementation "org.mockito:mockito-inline:4.11.0"
testImplementation "org.mockito.kotlin:mockito-kotlin:$mockitoKotlinVersion"
androidTestImplementation "org.mockito:mockito-android:4.10.0"
androidTestImplementation "org.mockito:mockito-android:4.11.0"
androidTestImplementation "org.mockito.kotlin:mockito-kotlin:$mockitoKotlinVersion"
testImplementation "androidx.test:core:$testCoreVersion"
testImplementation "androidx.arch.core:core-testing:2.2.0"
Expand All @@ -343,6 +343,7 @@ dependencies {
// Assertions
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.ext:truth:1.5.0'
testImplementation 'com.google.truth:truth:1.1.3'
androidTestImplementation 'com.google.truth:truth:1.1.3'

// Espresso dependencies
Expand Down
97 changes: 95 additions & 2 deletions app/src/androidTest/java/network/loki/messenger/LibSessionTests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,25 @@ import androidx.test.filters.SmallTest
import androidx.test.platform.app.InstrumentationRegistry
import network.loki.messenger.libsession_util.ConfigBase
import network.loki.messenger.libsession_util.Contacts
import network.loki.messenger.libsession_util.ConversationVolatileConfig
import network.loki.messenger.libsession_util.util.Contact
import network.loki.messenger.libsession_util.util.Conversation
import network.loki.messenger.libsession_util.util.ExpiryMode
import org.hamcrest.CoreMatchers.equalTo
import org.hamcrest.CoreMatchers.instanceOf
import org.hamcrest.MatcherAssert.assertThat
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.kotlin.any
import org.mockito.kotlin.argThat
import org.mockito.kotlin.argWhere
import org.mockito.kotlin.eq
import org.mockito.kotlin.spy
import org.mockito.kotlin.verify
import org.session.libsession.messaging.MessagingModuleConfiguration
import org.session.libsession.snode.SnodeAPI
import org.session.libsession.utilities.Address
import org.session.libsession.utilities.TextSecurePreferences
import org.session.libsignal.utilities.KeyHelper
import org.session.libsignal.utilities.hexEncodedPublicKey
Expand Down Expand Up @@ -50,13 +59,22 @@ class LibSessionTests {

private fun buildContactMessage(contactList: List<Contact>): ByteArray {
val (key,_) = maybeGetUserInfo()!!
val contacts = Contacts.Companion.newInstance(key)
val contacts = Contacts.newInstance(key)
contactList.forEach { contact ->
contacts.set(contact)
}
return contacts.push().config
}

private fun buildVolatileMessage(conversations: List<Conversation>): ByteArray {
val (key, _) = maybeGetUserInfo()!!
val volatile = ConversationVolatileConfig.newInstance(key)
conversations.forEach { conversation ->
volatile.set(conversation)
}
return volatile.push().config
}

private fun fakePollNewConfig(configBase: ConfigBase, toMerge: ByteArray) {
configBase.merge(nextFakeHash to toMerge)
MessagingModuleConfiguration.shared.configFactory.persist(configBase, System.currentTimeMillis())
Expand Down Expand Up @@ -95,8 +113,83 @@ class LibSessionTests {
fakePollNewConfig(contacts, newContactMerge)
verify(storageSpy).addLibSessionContacts(argThat {
first().let { it.id == newContactId && it.approved } && size == 1
})
}, any())
verify(storageSpy).setRecipientApproved(argThat { address.serialize() == newContactId }, eq(true))
}

@Test
fun test_expected_configs() {
val app = InstrumentationRegistry.getInstrumentation().targetContext.applicationContext as ApplicationContext
val storageSpy = spy(app.storage)
app.storage = storageSpy

val randomRecipient = randomSessionId()
val newContact = Contact(
id = randomRecipient,
approved = true,
expiryMode = ExpiryMode.AfterSend(1000)
)
val newConvo = Conversation.OneToOne(
randomRecipient,
SnodeAPI.nowWithOffset,
false
)
val volatiles = MessagingModuleConfiguration.shared.configFactory.convoVolatile!!
val contacts = MessagingModuleConfiguration.shared.configFactory.contacts!!
val newContactMerge = buildContactMessage(listOf(newContact))
val newVolatileMerge = buildVolatileMessage(listOf(newConvo))
fakePollNewConfig(contacts, newContactMerge)
fakePollNewConfig(volatiles, newVolatileMerge)
verify(storageSpy).setExpirationConfiguration(argWhere { config ->
config.expiryMode is ExpiryMode.AfterSend
&& config.expiryMode.expirySeconds == 1000L
})
val threadId = storageSpy.getThreadId(Address.fromSerialized(randomRecipient))!!
val newExpiry = storageSpy.getExpirationConfiguration(threadId)!!
assertThat(newExpiry.expiryMode, instanceOf(ExpiryMode.AfterSend::class.java))
assertThat(newExpiry.expiryMode.expirySeconds, equalTo(1000))
assertThat(newExpiry.expiryMode.expiryMillis, equalTo(1000000))
}

@Test
fun test_overwrite_config() {
val app = InstrumentationRegistry.getInstrumentation().targetContext.applicationContext as ApplicationContext
val storageSpy = spy(app.storage)
app.storage = storageSpy

// Initial state
val randomRecipient = randomSessionId()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may as well be deterministic value for repeatability if easy to do so.

val currentContact = Contact(
id = randomRecipient,
approved = true,
expiryMode = ExpiryMode.NONE
)
val newConvo = Conversation.OneToOne(
randomRecipient,
SnodeAPI.nowWithOffset,
false
)
val volatiles = MessagingModuleConfiguration.shared.configFactory.convoVolatile!!
val contacts = MessagingModuleConfiguration.shared.configFactory.contacts!!
val newContactMerge = buildContactMessage(listOf(currentContact))
val newVolatileMerge = buildVolatileMessage(listOf(newConvo))
fakePollNewConfig(contacts, newContactMerge)
fakePollNewConfig(volatiles, newVolatileMerge)
verify(storageSpy).setExpirationConfiguration(argWhere { config ->
config.expiryMode == ExpiryMode.NONE
})
val threadId = storageSpy.getThreadId(Address.fromSerialized(randomRecipient))!!
val currentExpiryConfig = storageSpy.getExpirationConfiguration(threadId)!!
assertThat(currentExpiryConfig.expiryMode, equalTo(ExpiryMode.NONE))
assertThat(currentExpiryConfig.expiryMode.expirySeconds, equalTo(0))
assertThat(currentExpiryConfig.expiryMode.expiryMillis, equalTo(0))
// Set new state and overwrite
val updatedContact = currentContact.copy(expiryMode = ExpiryMode.AfterSend(1000))
val updateContactMerge = buildContactMessage(listOf(updatedContact))
fakePollNewConfig(contacts, updateContactMerge)
val updatedExpiryConfig = storageSpy.getExpirationConfiguration(threadId)!!
assertThat(updatedExpiryConfig.expiryMode, instanceOf(ExpiryMode.AfterSend::class.java))
assertThat(updatedExpiryConfig.expiryMode.expirySeconds, equalTo(1000))
}

}
3 changes: 3 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@
android:screenOrientation="portrait" />
<activity android:name="org.thoughtcrime.securesms.preferences.appearance.AppearanceSettingsActivity"
android:screenOrientation="portrait"/>
<activity android:name="org.thoughtcrime.securesms.conversation.disappearingmessages.DisappearingMessagesActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.Session.DayNight.NoActionBar" />
bemusementpark marked this conversation as resolved.
Show resolved Hide resolved

<activity
android:exported="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,12 @@ public PersistentLogger getPersistentLogger() {
}

@Override
public void notifyUpdates(@NonNull ConfigBase forConfigObject) {
public void notifyUpdates(@NonNull ConfigBase forConfigObject, long messageTimestamp) {
// forward to the config factory / storage ig
if (forConfigObject instanceof UserProfile && !textSecurePreferences.getConfigurationMessageSynced()) {
textSecurePreferences.setConfigurationMessageSynced(true);
}
storage.notifyConfigUpdates(forConfigObject);
storage.notifyConfigUpdates(forConfigObject, messageTimestamp);
}

@Override
Expand Down
51 changes: 0 additions & 51 deletions app/src/main/java/org/thoughtcrime/securesms/ExpirationDialog.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class SessionDialogBuilder(val context: Context) {

fun destructiveButton(
@StringRes text: Int,
@StringRes contentDescription: Int,
@StringRes contentDescription: Int = text,
listener: () -> Unit = {}
) = button(
text,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class DatabaseAttachmentProvider(context: Context, helper: SQLCipherOpenHelper)
else DatabaseComponent.get(context).mmsDatabase()
messagingDatabase.deleteMessage(messageID)
DatabaseComponent.get(context).lokiMessageDatabase().deleteMessage(messageID, isSms)
DatabaseComponent.get(context).lokiMessageDatabase().deleteMessageServerHash(messageID)
DatabaseComponent.get(context).lokiMessageDatabase().deleteMessageServerHash(messageID, mms = !isSms)
}

override fun deleteMessages(messageIDs: List<Long>, threadId: Long, isSms: Boolean) {
Expand All @@ -195,7 +195,7 @@ class DatabaseAttachmentProvider(context: Context, helper: SQLCipherOpenHelper)

messagingDatabase.deleteMessages(messageIDs.toLongArray(), threadId)
DatabaseComponent.get(context).lokiMessageDatabase().deleteMessages(messageIDs)
DatabaseComponent.get(context).lokiMessageDatabase().deleteMessageServerHashes(messageIDs)
DatabaseComponent.get(context).lokiMessageDatabase().deleteMessageServerHashes(messageIDs, mms = !isSms)
}

override fun updateMessageAsDeleted(timestamp: Long, author: String): Long? {
Expand All @@ -212,15 +212,12 @@ class DatabaseAttachmentProvider(context: Context, helper: SQLCipherOpenHelper)
return message.id
}

override fun getServerHashForMessage(messageID: Long): String? {
val messageDB = DatabaseComponent.get(context).lokiMessageDatabase()
return messageDB.getMessageServerHash(messageID)
}
override fun getServerHashForMessage(messageID: Long, mms: Boolean): String? =
DatabaseComponent.get(context).lokiMessageDatabase().getMessageServerHash(messageID, mms)

override fun getDatabaseAttachment(attachmentId: Long): DatabaseAttachment? {
val attachmentDatabase = DatabaseComponent.get(context).attachmentDatabase()
return attachmentDatabase.getAttachment(AttachmentId(attachmentId, 0))
}
override fun getDatabaseAttachment(attachmentId: Long): DatabaseAttachment? =
DatabaseComponent.get(context).attachmentDatabase()
.getAttachment(AttachmentId(attachmentId, 0))

private fun scaleAndStripExif(attachmentDatabase: AttachmentDatabase, constraints: MediaConstraints, attachment: Attachment): Attachment? {
return try {
Expand Down
Loading