Collapse KnownRecipient / Story into single model.
This commit is contained in:
parent
70c6e9e60f
commit
8e313f8387
25 changed files with 93 additions and 137 deletions
|
@ -79,8 +79,7 @@ class GiftFlowRecipientSelectionFragment : Fragment(R.layout.gift_flow_recipient
|
||||||
override fun onSearchInputFocused() = Unit
|
override fun onSearchInputFocused() = Unit
|
||||||
|
|
||||||
override fun setResult(bundle: Bundle) {
|
override fun setResult(bundle: Bundle) {
|
||||||
val parcelableContacts: List<ContactSearchKey.ParcelableRecipientSearchKey> = bundle.getParcelableArrayList(MultiselectForwardFragment.RESULT_SELECTION)!!
|
val contacts: List<ContactSearchKey.RecipientSearchKey> = bundle.getParcelableArrayList(MultiselectForwardFragment.RESULT_SELECTION)!!
|
||||||
val contacts = parcelableContacts.map { it.asRecipientSearchKey() }
|
|
||||||
|
|
||||||
if (contacts.isNotEmpty()) {
|
if (contacts.isNotEmpty()) {
|
||||||
viewModel.setSelectedContact(contacts.first())
|
viewModel.setSelectedContact(contacts.first())
|
||||||
|
|
|
@ -18,7 +18,7 @@ sealed class ContactSearchData(val contactSearchKey: ContactSearchKey) {
|
||||||
val recipient: Recipient,
|
val recipient: Recipient,
|
||||||
val count: Int,
|
val count: Int,
|
||||||
val privacyMode: DistributionListPrivacyMode
|
val privacyMode: DistributionListPrivacyMode
|
||||||
) : ContactSearchData(ContactSearchKey.RecipientSearchKey.Story(recipient.id))
|
) : ContactSearchData(ContactSearchKey.RecipientSearchKey(recipient.id, true))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A row displaying a known recipient.
|
* A row displaying a known recipient.
|
||||||
|
@ -27,7 +27,7 @@ sealed class ContactSearchData(val contactSearchKey: ContactSearchKey) {
|
||||||
val recipient: Recipient,
|
val recipient: Recipient,
|
||||||
val shortSummary: Boolean = false,
|
val shortSummary: Boolean = false,
|
||||||
val headerLetter: String? = null
|
val headerLetter: String? = null
|
||||||
) : ContactSearchData(ContactSearchKey.RecipientSearchKey.KnownRecipient(recipient.id))
|
) : ContactSearchData(ContactSearchKey.RecipientSearchKey(recipient.id, false))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A row containing a title for a given section
|
* A row containing a title for a given section
|
||||||
|
|
|
@ -12,44 +12,18 @@ sealed class ContactSearchKey {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates a ShareContact object used to display which contacts have been selected. This should *not*
|
* Generates a ShareContact object used to display which contacts have been selected. This should *not*
|
||||||
* be used for the final sharing process, as it is not always truthful about, for example, KnownRecipient of
|
* be used for the final sharing process, as it is not always truthful about, for example,
|
||||||
* a group vs. a group's Story.
|
* a group vs. a group's Story.
|
||||||
*/
|
*/
|
||||||
open fun requireShareContact(): ShareContact = error("This key cannot be converted into a ShareContact")
|
open fun requireShareContact(): ShareContact = error("This key cannot be converted into a ShareContact")
|
||||||
|
|
||||||
open fun requireParcelable(): ParcelableRecipientSearchKey = error("This key cannot be parcelized")
|
open fun requireRecipientSearchKey(): RecipientSearchKey = error("This key cannot be parcelized")
|
||||||
|
|
||||||
sealed class RecipientSearchKey : ContactSearchKey() {
|
@Parcelize
|
||||||
|
data class RecipientSearchKey(val recipientId: RecipientId, val isStory: Boolean) : ContactSearchKey(), Parcelable {
|
||||||
|
override fun requireRecipientSearchKey(): RecipientSearchKey = this
|
||||||
|
|
||||||
abstract val recipientId: RecipientId
|
override fun requireShareContact(): ShareContact = ShareContact(recipientId)
|
||||||
abstract val isStory: Boolean
|
|
||||||
|
|
||||||
data class Story(override val recipientId: RecipientId) : RecipientSearchKey() {
|
|
||||||
override fun requireShareContact(): ShareContact {
|
|
||||||
return ShareContact(recipientId)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun requireParcelable(): ParcelableRecipientSearchKey {
|
|
||||||
return ParcelableRecipientSearchKey(ParcelableType.STORY, recipientId)
|
|
||||||
}
|
|
||||||
|
|
||||||
override val isStory: Boolean = true
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Key to a recipient which already exists in our database
|
|
||||||
*/
|
|
||||||
data class KnownRecipient(override val recipientId: RecipientId) : RecipientSearchKey() {
|
|
||||||
override fun requireShareContact(): ShareContact {
|
|
||||||
return ShareContact(recipientId)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun requireParcelable(): ParcelableRecipientSearchKey {
|
|
||||||
return ParcelableRecipientSearchKey(ParcelableType.KNOWN_RECIPIENT, recipientId)
|
|
||||||
}
|
|
||||||
|
|
||||||
override val isStory: Boolean = false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -61,19 +35,4 @@ sealed class ContactSearchKey {
|
||||||
* Key to an expand button for a given section
|
* Key to an expand button for a given section
|
||||||
*/
|
*/
|
||||||
data class Expand(val sectionKey: ContactSearchConfiguration.SectionKey) : ContactSearchKey()
|
data class Expand(val sectionKey: ContactSearchConfiguration.SectionKey) : ContactSearchKey()
|
||||||
|
|
||||||
@Parcelize
|
|
||||||
data class ParcelableRecipientSearchKey(val type: ParcelableType, val recipientId: RecipientId) : Parcelable {
|
|
||||||
fun asRecipientSearchKey(): RecipientSearchKey {
|
|
||||||
return when (type) {
|
|
||||||
ParcelableType.STORY -> RecipientSearchKey.Story(recipientId)
|
|
||||||
ParcelableType.KNOWN_RECIPIENT -> RecipientSearchKey.KnownRecipient(recipientId)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
enum class ParcelableType {
|
|
||||||
STORY,
|
|
||||||
KNOWN_RECIPIENT
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,7 @@ class ContactSearchMediator(
|
||||||
return viewModel.errorEventsStream.observeOn(AndroidSchedulers.mainThread())
|
return viewModel.errorEventsStream.observeOn(AndroidSchedulers.mainThread())
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addToVisibleGroupStories(groupStories: Set<ContactSearchKey.RecipientSearchKey.Story>) {
|
fun addToVisibleGroupStories(groupStories: Set<ContactSearchKey.RecipientSearchKey>) {
|
||||||
viewModel.addToVisibleGroupStories(groupStories)
|
viewModel.addToVisibleGroupStories(groupStories)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,8 +21,7 @@ class ContactSearchRepository {
|
||||||
val isSelectable = when (it) {
|
val isSelectable = when (it) {
|
||||||
is ContactSearchKey.Expand -> false
|
is ContactSearchKey.Expand -> false
|
||||||
is ContactSearchKey.Header -> false
|
is ContactSearchKey.Header -> false
|
||||||
is ContactSearchKey.RecipientSearchKey.KnownRecipient -> canSelectRecipient(it.recipientId)
|
is ContactSearchKey.RecipientSearchKey -> canSelectRecipient(it.recipientId)
|
||||||
is ContactSearchKey.RecipientSearchKey.Story -> canSelectRecipient(it.recipientId)
|
|
||||||
}
|
}
|
||||||
ContactSearchSelectionResult(it, isSelectable)
|
ContactSearchSelectionResult(it, isSelectable)
|
||||||
}.toSet()
|
}.toSet()
|
||||||
|
|
|
@ -98,7 +98,7 @@ class ContactSearchViewModel(
|
||||||
return selectionStore.state
|
return selectionStore.state
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addToVisibleGroupStories(groupStories: Set<ContactSearchKey.RecipientSearchKey.Story>) {
|
fun addToVisibleGroupStories(groupStories: Set<ContactSearchKey.RecipientSearchKey>) {
|
||||||
disposables += contactSearchRepository.markDisplayAsStory(groupStories.map { it.recipientId }).subscribe {
|
disposables += contactSearchRepository.markDisplayAsStory(groupStories.map { it.recipientId }).subscribe {
|
||||||
configurationStore.update { state ->
|
configurationStore.update { state ->
|
||||||
state.copy(
|
state.copy(
|
||||||
|
|
|
@ -77,8 +77,8 @@ class SafetyNumberRepository(
|
||||||
private fun List<ContactSearchKey>.flattenToRecipientIds(): Set<RecipientId> {
|
private fun List<ContactSearchKey>.flattenToRecipientIds(): Set<RecipientId> {
|
||||||
return this
|
return this
|
||||||
.map {
|
.map {
|
||||||
when (it) {
|
when {
|
||||||
is ContactSearchKey.RecipientSearchKey.KnownRecipient -> {
|
it is ContactSearchKey.RecipientSearchKey && !it.isStory -> {
|
||||||
val recipient = Recipient.resolved(it.recipientId)
|
val recipient = Recipient.resolved(it.recipientId)
|
||||||
if (recipient.isGroup) {
|
if (recipient.isGroup) {
|
||||||
recipient.participantIds
|
recipient.participantIds
|
||||||
|
@ -86,7 +86,7 @@ class SafetyNumberRepository(
|
||||||
listOf(it.recipientId)
|
listOf(it.recipientId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is ContactSearchKey.RecipientSearchKey.Story -> Recipient.resolved(it.recipientId).participantIds
|
it is ContactSearchKey.RecipientSearchKey -> Recipient.resolved(it.recipientId).participantIds
|
||||||
else -> throw AssertionError("Invalid contact selection $it")
|
else -> throw AssertionError("Invalid contact selection $it")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1570,7 +1570,7 @@ public class ConversationParentFragment extends Fragment
|
||||||
SafetyNumberBottomSheet
|
SafetyNumberBottomSheet
|
||||||
.forIdentityRecordsAndDestination(
|
.forIdentityRecordsAndDestination(
|
||||||
records,
|
records,
|
||||||
new ContactSearchKey.RecipientSearchKey.KnownRecipient(recipient.getId())
|
new ContactSearchKey.RecipientSearchKey(recipient.getId(), false)
|
||||||
)
|
)
|
||||||
.show(getChildFragmentManager());
|
.show(getChildFragmentManager());
|
||||||
}
|
}
|
||||||
|
@ -3584,7 +3584,7 @@ public class ConversationParentFragment extends Fragment
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendAnywayAfterSafetyNumberChangedInBottomSheet(@NonNull List<? extends ContactSearchKey.RecipientSearchKey> destinations) {
|
public void sendAnywayAfterSafetyNumberChangedInBottomSheet(@NonNull List<ContactSearchKey.RecipientSearchKey> destinations) {
|
||||||
Log.d(TAG, "onSendAnywayAfterSafetyNumberChange");
|
Log.d(TAG, "onSendAnywayAfterSafetyNumberChange");
|
||||||
initializeIdentityRecords().addListener(new AssertedSuccessListener<Boolean>() {
|
initializeIdentityRecords().addListener(new AssertedSuccessListener<Boolean>() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -73,8 +73,8 @@ open class MultiselectForwardActivity : FragmentWrapperActivity(), MultiselectFo
|
||||||
} else if (intent == null || !intent.hasExtra(RESULT_SELECTION)) {
|
} else if (intent == null || !intent.hasExtra(RESULT_SELECTION)) {
|
||||||
throw IllegalStateException("Selection contract requires a selection.")
|
throw IllegalStateException("Selection contract requires a selection.")
|
||||||
} else {
|
} else {
|
||||||
val selection: List<ContactSearchKey.ParcelableRecipientSearchKey> = intent.getParcelableArrayListExtra(RESULT_SELECTION)!!
|
val selection: List<ContactSearchKey.RecipientSearchKey> = intent.getParcelableArrayListExtra(RESULT_SELECTION)!!
|
||||||
selection.map { it.asRecipientSearchKey() }
|
selection
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -191,7 +191,7 @@ class MultiselectForwardFragment :
|
||||||
|
|
||||||
shareSelectionAdapter.submitList(contactSelection.mapIndexed { index, key -> ShareSelectionMappingModel(key.requireShareContact(), index == 0) })
|
shareSelectionAdapter.submitList(contactSelection.mapIndexed { index, key -> ShareSelectionMappingModel(key.requireShareContact(), index == 0) })
|
||||||
|
|
||||||
addMessage.visible = !args.forceDisableAddMessage && contactSelection.any { key -> key !is ContactSearchKey.RecipientSearchKey.Story } && args.multiShareArgs.isNotEmpty()
|
addMessage.visible = !args.forceDisableAddMessage && contactSelection.any { key -> !key.requireRecipientSearchKey().isStory } && args.multiShareArgs.isNotEmpty()
|
||||||
|
|
||||||
if (contactSelection.isNotEmpty() && !bottomBar.isVisible) {
|
if (contactSelection.isNotEmpty() && !bottomBar.isVisible) {
|
||||||
bottomBar.animation = AnimationUtils.loadAnimation(requireContext(), R.anim.slide_fade_from_bottom)
|
bottomBar.animation = AnimationUtils.loadAnimation(requireContext(), R.anim.slide_fade_from_bottom)
|
||||||
|
@ -237,13 +237,13 @@ class MultiselectForwardFragment :
|
||||||
|
|
||||||
setFragmentResultListener(CreateStoryWithViewersFragment.REQUEST_KEY) { _, bundle ->
|
setFragmentResultListener(CreateStoryWithViewersFragment.REQUEST_KEY) { _, bundle ->
|
||||||
val recipientId: RecipientId = bundle.getParcelable(CreateStoryWithViewersFragment.STORY_RECIPIENT)!!
|
val recipientId: RecipientId = bundle.getParcelable(CreateStoryWithViewersFragment.STORY_RECIPIENT)!!
|
||||||
contactSearchMediator.setKeysSelected(setOf(ContactSearchKey.RecipientSearchKey.Story(recipientId)))
|
contactSearchMediator.setKeysSelected(setOf(ContactSearchKey.RecipientSearchKey(recipientId, true)))
|
||||||
contactFilterView.clear()
|
contactFilterView.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
setFragmentResultListener(ChooseGroupStoryBottomSheet.GROUP_STORY) { _, bundle ->
|
setFragmentResultListener(ChooseGroupStoryBottomSheet.GROUP_STORY) { _, bundle ->
|
||||||
val groups: Set<RecipientId> = bundle.getParcelableArrayList<RecipientId>(ChooseGroupStoryBottomSheet.RESULT_SET)?.toSet() ?: emptySet()
|
val groups: Set<RecipientId> = bundle.getParcelableArrayList<RecipientId>(ChooseGroupStoryBottomSheet.RESULT_SET)?.toSet() ?: emptySet()
|
||||||
val keys: Set<ContactSearchKey.RecipientSearchKey.Story> = groups.map { ContactSearchKey.RecipientSearchKey.Story(it) }.toSet()
|
val keys: Set<ContactSearchKey.RecipientSearchKey> = groups.map { ContactSearchKey.RecipientSearchKey(it, true) }.toSet()
|
||||||
contactSearchMediator.addToVisibleGroupStories(keys)
|
contactSearchMediator.addToVisibleGroupStories(keys)
|
||||||
contactSearchMediator.setKeysSelected(keys)
|
contactSearchMediator.setKeysSelected(keys)
|
||||||
contactFilterView.clear()
|
contactFilterView.clear()
|
||||||
|
@ -350,7 +350,7 @@ class MultiselectForwardFragment :
|
||||||
dismissibleDialog?.dismiss()
|
dismissibleDialog?.dismiss()
|
||||||
|
|
||||||
val resultsBundle = Bundle().apply {
|
val resultsBundle = Bundle().apply {
|
||||||
putParcelableArrayList(RESULT_SELECTION, ArrayList(selectedContacts.map { it.requireParcelable() }))
|
putParcelableArrayList(RESULT_SELECTION, ArrayList(selectedContacts.map { it.requireRecipientSearchKey() }))
|
||||||
}
|
}
|
||||||
|
|
||||||
callback.setResult(resultsBundle)
|
callback.setResult(resultsBundle)
|
||||||
|
@ -489,7 +489,7 @@ class MultiselectForwardFragment :
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onMyStoryConfigured(recipientId: RecipientId) {
|
override fun onMyStoryConfigured(recipientId: RecipientId) {
|
||||||
contactSearchMediator.setKeysSelected(setOf(ContactSearchKey.RecipientSearchKey.Story(recipientId)))
|
contactSearchMediator.setKeysSelected(setOf(ContactSearchKey.RecipientSearchKey(recipientId, true)))
|
||||||
contactSearchMediator.refresh()
|
contactSearchMediator.refresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,14 +62,14 @@ class MultiselectForwardRepository {
|
||||||
SignalExecutors.BOUNDED.execute {
|
SignalExecutors.BOUNDED.execute {
|
||||||
val filteredContacts: Set<ContactSearchKey> = shareContacts
|
val filteredContacts: Set<ContactSearchKey> = shareContacts
|
||||||
.asSequence()
|
.asSequence()
|
||||||
.filter { it is ContactSearchKey.RecipientSearchKey.Story || it is ContactSearchKey.RecipientSearchKey.KnownRecipient }
|
.filter { it is ContactSearchKey.RecipientSearchKey }
|
||||||
.toSet()
|
.toSet()
|
||||||
|
|
||||||
val mappedArgs: List<MultiShareArgs> = multiShareArgs.map { it.buildUpon(filteredContacts).build() }
|
val mappedArgs: List<MultiShareArgs> = multiShareArgs.map { it.buildUpon(filteredContacts).build() }
|
||||||
val results = mappedArgs.sortedBy { it.timestamp }.map { MultiShareSender.sendSync(it) }
|
val results = mappedArgs.sortedBy { it.timestamp }.map { MultiShareSender.sendSync(it) }
|
||||||
|
|
||||||
if (additionalMessage.isNotEmpty()) {
|
if (additionalMessage.isNotEmpty()) {
|
||||||
val additional = MultiShareArgs.Builder(filteredContacts.filterNot { it is ContactSearchKey.RecipientSearchKey.Story }.toSet())
|
val additional = MultiShareArgs.Builder(filteredContacts.filterNot { it is ContactSearchKey.RecipientSearchKey && it.isStory }.toSet())
|
||||||
.withDraftText(additionalMessage)
|
.withDraftText(additionalMessage)
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,7 @@ class GiftSendJob private constructor(parameters: Parameters, private val recipi
|
||||||
Log.i(TAG, "Sending additional message...")
|
Log.i(TAG, "Sending additional message...")
|
||||||
|
|
||||||
val result = MultiShareSender.sendSync(
|
val result = MultiShareSender.sendSync(
|
||||||
MultiShareArgs.Builder(setOf(ContactSearchKey.RecipientSearchKey.KnownRecipient(recipientId)))
|
MultiShareArgs.Builder(setOf(ContactSearchKey.RecipientSearchKey(recipientId, false)))
|
||||||
.withDraftText(trimmedMessage)
|
.withDraftText(trimmedMessage)
|
||||||
.build()
|
.build()
|
||||||
)
|
)
|
||||||
|
|
|
@ -29,7 +29,7 @@ sealed class MediaSelectionDestination {
|
||||||
}
|
}
|
||||||
|
|
||||||
class SingleRecipient(private val id: RecipientId) : MediaSelectionDestination() {
|
class SingleRecipient(private val id: RecipientId) : MediaSelectionDestination() {
|
||||||
override fun getRecipientSearchKey(): ContactSearchKey.RecipientSearchKey = ContactSearchKey.RecipientSearchKey.KnownRecipient(id)
|
override fun getRecipientSearchKey(): ContactSearchKey.RecipientSearchKey = ContactSearchKey.RecipientSearchKey(id, false)
|
||||||
|
|
||||||
override fun toBundle(): Bundle {
|
override fun toBundle(): Bundle {
|
||||||
return Bundle().apply {
|
return Bundle().apply {
|
||||||
|
@ -39,7 +39,7 @@ sealed class MediaSelectionDestination {
|
||||||
}
|
}
|
||||||
|
|
||||||
class SingleStory(private val id: RecipientId) : MediaSelectionDestination() {
|
class SingleStory(private val id: RecipientId) : MediaSelectionDestination() {
|
||||||
override fun getRecipientSearchKey(): ContactSearchKey.RecipientSearchKey = ContactSearchKey.RecipientSearchKey.Story(id)
|
override fun getRecipientSearchKey(): ContactSearchKey.RecipientSearchKey = ContactSearchKey.RecipientSearchKey(id, true)
|
||||||
|
|
||||||
override fun toBundle(): Bundle {
|
override fun toBundle(): Bundle {
|
||||||
return Bundle().apply {
|
return Bundle().apply {
|
||||||
|
@ -51,8 +51,8 @@ sealed class MediaSelectionDestination {
|
||||||
class MultipleRecipients(val recipientSearchKeys: List<ContactSearchKey.RecipientSearchKey>) : MediaSelectionDestination() {
|
class MultipleRecipients(val recipientSearchKeys: List<ContactSearchKey.RecipientSearchKey>) : MediaSelectionDestination() {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun fromParcel(parcelables: List<ContactSearchKey.ParcelableRecipientSearchKey>): MultipleRecipients {
|
fun fromParcel(parcelables: List<ContactSearchKey.RecipientSearchKey>): MultipleRecipients {
|
||||||
return MultipleRecipients(parcelables.map { it.asRecipientSearchKey() }.filterIsInstance(ContactSearchKey.RecipientSearchKey::class.java))
|
return MultipleRecipients(parcelables)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ sealed class MediaSelectionDestination {
|
||||||
|
|
||||||
override fun toBundle(): Bundle {
|
override fun toBundle(): Bundle {
|
||||||
return Bundle().apply {
|
return Bundle().apply {
|
||||||
putParcelableArrayList(RECIPIENT_LIST, ArrayList(recipientSearchKeys.map { it.requireParcelable() }))
|
putParcelableArrayList(RECIPIENT_LIST, ArrayList(recipientSearchKeys.map { it.requireRecipientSearchKey() }))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,7 +86,7 @@ class ChooseGroupStoryBottomSheet : FixedRoundedCornerBottomSheetDialogFragment(
|
||||||
|
|
||||||
mediator.getSelectionState().observe(viewLifecycleOwner) { state ->
|
mediator.getSelectionState().observe(viewLifecycleOwner) { state ->
|
||||||
adapter.submitList(
|
adapter.submitList(
|
||||||
state.filterIsInstance(ContactSearchKey.RecipientSearchKey.KnownRecipient::class.java)
|
state.filterIsInstance(ContactSearchKey.RecipientSearchKey::class.java)
|
||||||
.map { it.recipientId }
|
.map { it.recipientId }
|
||||||
.mapIndexed { index, recipientId ->
|
.mapIndexed { index, recipientId ->
|
||||||
ShareSelectionMappingModel(
|
ShareSelectionMappingModel(
|
||||||
|
@ -146,7 +146,7 @@ class ChooseGroupStoryBottomSheet : FixedRoundedCornerBottomSheetDialogFragment(
|
||||||
RESULT_SET,
|
RESULT_SET,
|
||||||
ArrayList(
|
ArrayList(
|
||||||
mediator.getSelectedContacts()
|
mediator.getSelectedContacts()
|
||||||
.filterIsInstance(ContactSearchKey.RecipientSearchKey.KnownRecipient::class.java)
|
.filterIsInstance(ContactSearchKey.RecipientSearchKey::class.java)
|
||||||
.map { it.recipientId }
|
.map { it.recipientId }
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
@ -64,7 +64,7 @@ class TextStoryPostSendRepository {
|
||||||
|
|
||||||
for (contact in contactSearchKey) {
|
for (contact in contactSearchKey) {
|
||||||
val recipient = Recipient.resolved(contact.requireShareContact().recipientId.get())
|
val recipient = Recipient.resolved(contact.requireShareContact().recipientId.get())
|
||||||
val isStory = contact is ContactSearchKey.RecipientSearchKey.Story || recipient.isDistributionList
|
val isStory = contact.requireRecipientSearchKey().isStory || recipient.isDistributionList
|
||||||
|
|
||||||
if (isStory && !recipient.isMyStory) {
|
if (isStory && !recipient.isMyStory) {
|
||||||
SignalStore.storyValues().setLatestStorySend(StorySend.newSend(recipient))
|
SignalStore.storyValues().setLatestStorySend(StorySend.newSend(recipient))
|
||||||
|
|
|
@ -99,7 +99,7 @@ object SafetyNumberBottomSheet {
|
||||||
fun forIdentityRecordsAndDestinations(identityRecords: List<IdentityRecord>, destinations: List<ContactSearchKey>): Factory {
|
fun forIdentityRecordsAndDestinations(identityRecords: List<IdentityRecord>, destinations: List<ContactSearchKey>): Factory {
|
||||||
val args = SafetyNumberBottomSheetArgs(
|
val args = SafetyNumberBottomSheetArgs(
|
||||||
identityRecords.map { it.recipientId },
|
identityRecords.map { it.recipientId },
|
||||||
destinations.filterIsInstance<ContactSearchKey.RecipientSearchKey>().map { it.requireParcelable() }
|
destinations.filterIsInstance<ContactSearchKey.RecipientSearchKey>().map { it.requireRecipientSearchKey() }
|
||||||
)
|
)
|
||||||
|
|
||||||
return SheetFactory(args)
|
return SheetFactory(args)
|
||||||
|
@ -115,7 +115,7 @@ object SafetyNumberBottomSheet {
|
||||||
fun forIdentityRecordsAndDestination(identityRecords: List<IdentityRecord>, destination: ContactSearchKey): Factory {
|
fun forIdentityRecordsAndDestination(identityRecords: List<IdentityRecord>, destination: ContactSearchKey): Factory {
|
||||||
val args = SafetyNumberBottomSheetArgs(
|
val args = SafetyNumberBottomSheetArgs(
|
||||||
identityRecords.map { it.recipientId },
|
identityRecords.map { it.recipientId },
|
||||||
listOf(destination).filterIsInstance<ContactSearchKey.RecipientSearchKey>().map { it.requireParcelable() }
|
listOf(destination).filterIsInstance<ContactSearchKey.RecipientSearchKey>().map { it.requireRecipientSearchKey() }
|
||||||
)
|
)
|
||||||
|
|
||||||
return SheetFactory(args)
|
return SheetFactory(args)
|
||||||
|
@ -131,14 +131,14 @@ object SafetyNumberBottomSheet {
|
||||||
return args!!
|
return args!!
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getDestinationFromRecord(messageRecord: MessageRecord): List<ContactSearchKey.ParcelableRecipientSearchKey> {
|
private fun getDestinationFromRecord(messageRecord: MessageRecord): List<ContactSearchKey.RecipientSearchKey> {
|
||||||
val key = if ((messageRecord as? MmsMessageRecord)?.storyType?.isStory == true) {
|
val key = if ((messageRecord as? MmsMessageRecord)?.storyType?.isStory == true) {
|
||||||
ContactSearchKey.RecipientSearchKey.Story(messageRecord.recipient.id)
|
ContactSearchKey.RecipientSearchKey(messageRecord.recipient.id, true)
|
||||||
} else {
|
} else {
|
||||||
ContactSearchKey.RecipientSearchKey.KnownRecipient(messageRecord.recipient.id)
|
ContactSearchKey.RecipientSearchKey(messageRecord.recipient.id, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
return listOf(key.requireParcelable())
|
return listOf(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -12,6 +12,6 @@ import org.thoughtcrime.securesms.recipients.RecipientId
|
||||||
@Parcelize
|
@Parcelize
|
||||||
data class SafetyNumberBottomSheetArgs(
|
data class SafetyNumberBottomSheetArgs(
|
||||||
val untrustedRecipients: List<RecipientId>,
|
val untrustedRecipients: List<RecipientId>,
|
||||||
val destinations: List<ContactSearchKey.ParcelableRecipientSearchKey>,
|
val destinations: List<ContactSearchKey.RecipientSearchKey>,
|
||||||
val messageId: MessageId? = null
|
val messageId: MessageId? = null
|
||||||
) : Parcelable
|
) : Parcelable
|
||||||
|
|
|
@ -25,7 +25,7 @@ class SafetyNumberBottomSheetViewModel(
|
||||||
private const val MAX_RECIPIENTS_TO_DISPLAY = 5
|
private const val MAX_RECIPIENTS_TO_DISPLAY = 5
|
||||||
}
|
}
|
||||||
|
|
||||||
private val destinationStore = RxStore(args.destinations.map { it.asRecipientSearchKey() })
|
private val destinationStore = RxStore(args.destinations)
|
||||||
val destinationSnapshot: List<ContactSearchKey.RecipientSearchKey>
|
val destinationSnapshot: List<ContactSearchKey.RecipientSearchKey>
|
||||||
get() = destinationStore.state
|
get() = destinationStore.state
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ import org.thoughtcrime.securesms.util.Util;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
@ -61,11 +62,9 @@ public final class MultiShareArgs implements Parcelable {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected MultiShareArgs(Parcel in) {
|
protected MultiShareArgs(Parcel in) {
|
||||||
List<ContactSearchKey.ParcelableRecipientSearchKey> parcelableRecipientSearchKeys = in.createTypedArrayList(ContactSearchKey.ParcelableRecipientSearchKey.CREATOR);
|
List<ContactSearchKey.RecipientSearchKey> parcelableRecipientSearchKeys = in.createTypedArrayList(ContactSearchKey.RecipientSearchKey.CREATOR);
|
||||||
|
|
||||||
contactSearchKeys = parcelableRecipientSearchKeys.stream()
|
contactSearchKeys = new HashSet<>(parcelableRecipientSearchKeys);
|
||||||
.map(ContactSearchKey.ParcelableRecipientSearchKey::asRecipientSearchKey)
|
|
||||||
.collect(Collectors.toSet());
|
|
||||||
media = in.createTypedArrayList(Media.CREATOR);
|
media = in.createTypedArrayList(Media.CREATOR);
|
||||||
draftText = in.readString();
|
draftText = in.readString();
|
||||||
stickerLocator = in.readParcelable(StickerLocator.class.getClassLoader());
|
stickerLocator = in.readParcelable(StickerLocator.class.getClassLoader());
|
||||||
|
@ -197,7 +196,8 @@ public final class MultiShareArgs implements Parcelable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean allRecipientsAreStories() {
|
public boolean allRecipientsAreStories() {
|
||||||
return !contactSearchKeys.isEmpty() && contactSearchKeys.stream().allMatch(key -> key instanceof ContactSearchKey.RecipientSearchKey.Story);
|
return !contactSearchKeys.isEmpty() && contactSearchKeys.stream()
|
||||||
|
.allMatch(key -> key.requireRecipientSearchKey().isStory());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Creator<MultiShareArgs> CREATOR = new Creator<MultiShareArgs>() {
|
public static final Creator<MultiShareArgs> CREATOR = new Creator<MultiShareArgs>() {
|
||||||
|
@ -219,7 +219,7 @@ public final class MultiShareArgs implements Parcelable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
public void writeToParcel(Parcel dest, int flags) {
|
||||||
dest.writeTypedList(Stream.of(contactSearchKeys).map(ContactSearchKey::requireParcelable).toList());
|
dest.writeTypedList(Stream.of(contactSearchKeys).map(ContactSearchKey::requireRecipientSearchKey).toList());
|
||||||
dest.writeTypedList(media);
|
dest.writeTypedList(media);
|
||||||
dest.writeString(draftText);
|
dest.writeString(draftText);
|
||||||
dest.writeParcelable(stickerLocator, flags);
|
dest.writeParcelable(stickerLocator, flags);
|
||||||
|
@ -267,7 +267,7 @@ public final class MultiShareArgs implements Parcelable {
|
||||||
(!media.isEmpty() ||
|
(!media.isEmpty() ||
|
||||||
!TextUtils.isEmpty(draftText) ||
|
!TextUtils.isEmpty(draftText) ||
|
||||||
MediaUtil.isImageOrVideoType(dataType) ||
|
MediaUtil.isImageOrVideoType(dataType) ||
|
||||||
(!contactSearchKeys.isEmpty() && contactSearchKeys.stream().anyMatch(key -> key instanceof ContactSearchKey.RecipientSearchKey.Story)));
|
(!contactSearchKeys.isEmpty() && contactSearchKeys.stream().anyMatch(key -> key.requireRecipientSearchKey().isStory())));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final class Builder {
|
public static final class Builder {
|
||||||
|
|
|
@ -103,7 +103,7 @@ class ShareActivity : PassphraseRequiredActivity(), MultiselectForwardFragment.C
|
||||||
openConversation(
|
openConversation(
|
||||||
ShareEvent.OpenConversation(
|
ShareEvent.OpenConversation(
|
||||||
shareState.loadState.resolvedShareData,
|
shareState.loadState.resolvedShareData,
|
||||||
ContactSearchKey.RecipientSearchKey.KnownRecipient(directShareTarget)
|
ContactSearchKey.RecipientSearchKey(directShareTarget, false)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
|
@ -134,8 +134,7 @@ class ShareActivity : PassphraseRequiredActivity(), MultiselectForwardFragment.C
|
||||||
throw AssertionError("Expected a recipient selection!")
|
throw AssertionError("Expected a recipient selection!")
|
||||||
}
|
}
|
||||||
|
|
||||||
val parcelizedKeys: List<ContactSearchKey.ParcelableRecipientSearchKey> = bundle.getParcelableArrayList(MultiselectForwardFragment.RESULT_SELECTION)!!
|
val contactSearchKeys: List<ContactSearchKey.RecipientSearchKey> = bundle.getParcelableArrayList(MultiselectForwardFragment.RESULT_SELECTION)!!
|
||||||
val contactSearchKeys = parcelizedKeys.map { it.asRecipientSearchKey() }
|
|
||||||
|
|
||||||
viewModel.onContactSelectionConfirmed(contactSearchKeys)
|
viewModel.onContactSelectionConfirmed(contactSearchKeys)
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,7 +128,7 @@ class AddToGroupStoryDelegate(
|
||||||
private fun sendNonPreUploadedMedia(result: MediaSendActivityResult) {
|
private fun sendNonPreUploadedMedia(result: MediaSendActivityResult) {
|
||||||
Log.d(TAG, "Sending non-preupload media.")
|
Log.d(TAG, "Sending non-preupload media.")
|
||||||
|
|
||||||
val multiShareArgs = MultiShareArgs.Builder(setOf(ContactSearchKey.RecipientSearchKey.Story(result.recipientId)))
|
val multiShareArgs = MultiShareArgs.Builder(setOf(ContactSearchKey.RecipientSearchKey(result.recipientId, true)))
|
||||||
.withMedia(result.nonUploadedMedia.toList())
|
.withMedia(result.nonUploadedMedia.toList())
|
||||||
.withDraftText(result.body)
|
.withDraftText(result.body)
|
||||||
.withMentions(result.mentions.toList())
|
.withMentions(result.mentions.toList())
|
||||||
|
|
|
@ -387,7 +387,7 @@ class StoryGroupReplyFragment :
|
||||||
resendReaction = emoji
|
resendReaction = emoji
|
||||||
|
|
||||||
SafetyNumberBottomSheet
|
SafetyNumberBottomSheet
|
||||||
.forIdentityRecordsAndDestination(error.untrustedRecords, ContactSearchKey.RecipientSearchKey.Story(groupRecipientId))
|
.forIdentityRecordsAndDestination(error.untrustedRecords, ContactSearchKey.RecipientSearchKey(groupRecipientId, true))
|
||||||
.show(childFragmentManager)
|
.show(childFragmentManager)
|
||||||
} else {
|
} else {
|
||||||
Log.w(TAG, "Failed to send reply", error)
|
Log.w(TAG, "Failed to send reply", error)
|
||||||
|
@ -536,7 +536,7 @@ class StoryGroupReplyFragment :
|
||||||
resendMentions = mentions
|
resendMentions = mentions
|
||||||
|
|
||||||
SafetyNumberBottomSheet
|
SafetyNumberBottomSheet
|
||||||
.forIdentityRecordsAndDestination(throwable.untrustedRecords, ContactSearchKey.RecipientSearchKey.Story(groupRecipientId))
|
.forIdentityRecordsAndDestination(throwable.untrustedRecords, ContactSearchKey.RecipientSearchKey(groupRecipientId, true))
|
||||||
.show(childFragmentManager)
|
.show(childFragmentManager)
|
||||||
} else {
|
} else {
|
||||||
Log.w(TAG, "Failed to send reply", throwable)
|
Log.w(TAG, "Failed to send reply", throwable)
|
||||||
|
|
|
@ -36,7 +36,7 @@ object StoryGroupReplySender {
|
||||||
}
|
}
|
||||||
|
|
||||||
return messageAndRecipient.flatMapCompletable { (message, recipient) ->
|
return messageAndRecipient.flatMapCompletable { (message, recipient) ->
|
||||||
UntrustedRecords.checkForBadIdentityRecords(setOf(ContactSearchKey.RecipientSearchKey.KnownRecipient(recipient.id)), System.currentTimeMillis() - IdentityRecordList.DEFAULT_UNTRUSTED_WINDOW)
|
UntrustedRecords.checkForBadIdentityRecords(setOf(ContactSearchKey.RecipientSearchKey(recipient.id, false)), System.currentTimeMillis() - IdentityRecordList.DEFAULT_UNTRUSTED_WINDOW)
|
||||||
.andThen(
|
.andThen(
|
||||||
Completable.create {
|
Completable.create {
|
||||||
MessageSender.send(
|
MessageSender.send(
|
||||||
|
|
|
@ -51,16 +51,16 @@ class ContactSearchPagedDataSourceTest {
|
||||||
|
|
||||||
val expected = listOf(
|
val expected = listOf(
|
||||||
ContactSearchKey.Header(ContactSearchConfiguration.SectionKey.RECENTS),
|
ContactSearchKey.Header(ContactSearchConfiguration.SectionKey.RECENTS),
|
||||||
ContactSearchKey.RecipientSearchKey.KnownRecipient(RecipientId.UNKNOWN),
|
ContactSearchKey.RecipientSearchKey(RecipientId.UNKNOWN, false),
|
||||||
ContactSearchKey.RecipientSearchKey.KnownRecipient(RecipientId.UNKNOWN),
|
ContactSearchKey.RecipientSearchKey(RecipientId.UNKNOWN, false),
|
||||||
ContactSearchKey.RecipientSearchKey.KnownRecipient(RecipientId.UNKNOWN),
|
ContactSearchKey.RecipientSearchKey(RecipientId.UNKNOWN, false),
|
||||||
ContactSearchKey.RecipientSearchKey.KnownRecipient(RecipientId.UNKNOWN),
|
ContactSearchKey.RecipientSearchKey(RecipientId.UNKNOWN, false),
|
||||||
ContactSearchKey.RecipientSearchKey.KnownRecipient(RecipientId.UNKNOWN),
|
ContactSearchKey.RecipientSearchKey(RecipientId.UNKNOWN, false),
|
||||||
ContactSearchKey.RecipientSearchKey.KnownRecipient(RecipientId.UNKNOWN),
|
ContactSearchKey.RecipientSearchKey(RecipientId.UNKNOWN, false),
|
||||||
ContactSearchKey.RecipientSearchKey.KnownRecipient(RecipientId.UNKNOWN),
|
ContactSearchKey.RecipientSearchKey(RecipientId.UNKNOWN, false),
|
||||||
ContactSearchKey.RecipientSearchKey.KnownRecipient(RecipientId.UNKNOWN),
|
ContactSearchKey.RecipientSearchKey(RecipientId.UNKNOWN, false),
|
||||||
ContactSearchKey.RecipientSearchKey.KnownRecipient(RecipientId.UNKNOWN),
|
ContactSearchKey.RecipientSearchKey(RecipientId.UNKNOWN, false),
|
||||||
ContactSearchKey.RecipientSearchKey.KnownRecipient(RecipientId.UNKNOWN),
|
ContactSearchKey.RecipientSearchKey(RecipientId.UNKNOWN, false),
|
||||||
ContactSearchKey.Header(ContactSearchConfiguration.SectionKey.INDIVIDUALS)
|
ContactSearchKey.Header(ContactSearchConfiguration.SectionKey.INDIVIDUALS)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -75,15 +75,15 @@ class ContactSearchPagedDataSourceTest {
|
||||||
val result = testSubject.load(5, 10) { false }
|
val result = testSubject.load(5, 10) { false }
|
||||||
|
|
||||||
val expected = listOf(
|
val expected = listOf(
|
||||||
ContactSearchKey.RecipientSearchKey.KnownRecipient(RecipientId.UNKNOWN),
|
ContactSearchKey.RecipientSearchKey(RecipientId.UNKNOWN, false),
|
||||||
ContactSearchKey.RecipientSearchKey.KnownRecipient(RecipientId.UNKNOWN),
|
ContactSearchKey.RecipientSearchKey(RecipientId.UNKNOWN, false),
|
||||||
ContactSearchKey.RecipientSearchKey.KnownRecipient(RecipientId.UNKNOWN),
|
ContactSearchKey.RecipientSearchKey(RecipientId.UNKNOWN, false),
|
||||||
ContactSearchKey.RecipientSearchKey.KnownRecipient(RecipientId.UNKNOWN),
|
ContactSearchKey.RecipientSearchKey(RecipientId.UNKNOWN, false),
|
||||||
ContactSearchKey.RecipientSearchKey.KnownRecipient(RecipientId.UNKNOWN),
|
ContactSearchKey.RecipientSearchKey(RecipientId.UNKNOWN, false),
|
||||||
ContactSearchKey.RecipientSearchKey.KnownRecipient(RecipientId.UNKNOWN),
|
ContactSearchKey.RecipientSearchKey(RecipientId.UNKNOWN, false),
|
||||||
ContactSearchKey.Header(ContactSearchConfiguration.SectionKey.INDIVIDUALS),
|
ContactSearchKey.Header(ContactSearchConfiguration.SectionKey.INDIVIDUALS),
|
||||||
ContactSearchKey.RecipientSearchKey.KnownRecipient(RecipientId.UNKNOWN),
|
ContactSearchKey.RecipientSearchKey(RecipientId.UNKNOWN, false),
|
||||||
ContactSearchKey.RecipientSearchKey.KnownRecipient(RecipientId.UNKNOWN),
|
ContactSearchKey.RecipientSearchKey(RecipientId.UNKNOWN, false),
|
||||||
ContactSearchKey.Expand(ContactSearchConfiguration.SectionKey.INDIVIDUALS)
|
ContactSearchKey.Expand(ContactSearchConfiguration.SectionKey.INDIVIDUALS)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -99,17 +99,17 @@ class ContactSearchPagedDataSourceTest {
|
||||||
|
|
||||||
val expected = listOf(
|
val expected = listOf(
|
||||||
ContactSearchKey.Header(ContactSearchConfiguration.SectionKey.STORIES),
|
ContactSearchKey.Header(ContactSearchConfiguration.SectionKey.STORIES),
|
||||||
ContactSearchKey.RecipientSearchKey.Story(RecipientId.UNKNOWN),
|
ContactSearchKey.RecipientSearchKey(RecipientId.UNKNOWN, true),
|
||||||
ContactSearchKey.RecipientSearchKey.Story(RecipientId.UNKNOWN),
|
ContactSearchKey.RecipientSearchKey(RecipientId.UNKNOWN, true),
|
||||||
ContactSearchKey.RecipientSearchKey.Story(RecipientId.UNKNOWN),
|
ContactSearchKey.RecipientSearchKey(RecipientId.UNKNOWN, true),
|
||||||
ContactSearchKey.RecipientSearchKey.Story(RecipientId.UNKNOWN),
|
ContactSearchKey.RecipientSearchKey(RecipientId.UNKNOWN, true),
|
||||||
ContactSearchKey.RecipientSearchKey.Story(RecipientId.UNKNOWN),
|
ContactSearchKey.RecipientSearchKey(RecipientId.UNKNOWN, true),
|
||||||
ContactSearchKey.RecipientSearchKey.Story(RecipientId.UNKNOWN),
|
ContactSearchKey.RecipientSearchKey(RecipientId.UNKNOWN, true),
|
||||||
ContactSearchKey.RecipientSearchKey.Story(RecipientId.UNKNOWN),
|
ContactSearchKey.RecipientSearchKey(RecipientId.UNKNOWN, true),
|
||||||
ContactSearchKey.RecipientSearchKey.Story(RecipientId.UNKNOWN),
|
ContactSearchKey.RecipientSearchKey(RecipientId.UNKNOWN, true),
|
||||||
ContactSearchKey.RecipientSearchKey.Story(RecipientId.UNKNOWN),
|
ContactSearchKey.RecipientSearchKey(RecipientId.UNKNOWN, true),
|
||||||
ContactSearchKey.RecipientSearchKey.Story(RecipientId.UNKNOWN),
|
ContactSearchKey.RecipientSearchKey(RecipientId.UNKNOWN, true),
|
||||||
ContactSearchKey.RecipientSearchKey.Story(RecipientId.UNKNOWN),
|
ContactSearchKey.RecipientSearchKey(RecipientId.UNKNOWN, true),
|
||||||
)
|
)
|
||||||
|
|
||||||
val resultKeys = result.map { it.contactSearchKey }
|
val resultKeys = result.map { it.contactSearchKey }
|
||||||
|
|
|
@ -108,7 +108,7 @@ class SafetyNumberRepositoryTest {
|
||||||
@Test
|
@Test
|
||||||
fun batchSafetyNumberCheckSync_batchOf1_noChanges() {
|
fun batchSafetyNumberCheckSync_batchOf1_noChanges() {
|
||||||
val other = recipientPool[1]
|
val other = recipientPool[1]
|
||||||
val keys = listOf(ContactSearchKey.RecipientSearchKey.KnownRecipient(other.id))
|
val keys = listOf(ContactSearchKey.RecipientSearchKey(other.id, false))
|
||||||
|
|
||||||
staticRecipient.`when`<List<Recipient>> { Recipient.resolvedList(argThat { containsAll(keys.map { it.recipientId }) }) }.thenReturn(listOf(other))
|
staticRecipient.`when`<List<Recipient>> { Recipient.resolvedList(argThat { containsAll(keys.map { it.recipientId }) }) }.thenReturn(listOf(other))
|
||||||
whenever(profileService.performIdentityCheck(mapOf(other.requireServiceId() to identityPool[other]!!.identityKey)))
|
whenever(profileService.performIdentityCheck(mapOf(other.requireServiceId() to identityPool[other]!!.identityKey)))
|
||||||
|
@ -127,7 +127,7 @@ class SafetyNumberRepositoryTest {
|
||||||
val other = recipientPool[1]
|
val other = recipientPool[1]
|
||||||
val otherAci = ACI.from(other.requireServiceId())
|
val otherAci = ACI.from(other.requireServiceId())
|
||||||
val otherNewIdentityKey = IdentityKeyUtil.generateIdentityKeyPair().publicKey
|
val otherNewIdentityKey = IdentityKeyUtil.generateIdentityKeyPair().publicKey
|
||||||
val keys = listOf(ContactSearchKey.RecipientSearchKey.KnownRecipient(other.id))
|
val keys = listOf(ContactSearchKey.RecipientSearchKey(other.id, false))
|
||||||
|
|
||||||
staticRecipient.`when`<List<Recipient>> { Recipient.resolvedList(argThat { containsAll(keys.map { it.recipientId }) }) }.thenReturn(listOf(other))
|
staticRecipient.`when`<List<Recipient>> { Recipient.resolvedList(argThat { containsAll(keys.map { it.recipientId }) }) }.thenReturn(listOf(other))
|
||||||
whenever(profileService.performIdentityCheck(mapOf(other.requireServiceId() to identityPool[other]!!.identityKey)))
|
whenever(profileService.performIdentityCheck(mapOf(other.requireServiceId() to identityPool[other]!!.identityKey)))
|
||||||
|
@ -148,7 +148,7 @@ class SafetyNumberRepositoryTest {
|
||||||
val secondOther = recipientPool[2]
|
val secondOther = recipientPool[2]
|
||||||
val otherAci = ACI.from(other.requireServiceId())
|
val otherAci = ACI.from(other.requireServiceId())
|
||||||
val otherNewIdentityKey = IdentityKeyUtil.generateIdentityKeyPair().publicKey
|
val otherNewIdentityKey = IdentityKeyUtil.generateIdentityKeyPair().publicKey
|
||||||
val keys = listOf(ContactSearchKey.RecipientSearchKey.KnownRecipient(other.id), ContactSearchKey.RecipientSearchKey.KnownRecipient(secondOther.id))
|
val keys = listOf(ContactSearchKey.RecipientSearchKey(other.id, false), ContactSearchKey.RecipientSearchKey(secondOther.id, false))
|
||||||
|
|
||||||
staticRecipient.`when`<List<Recipient>> { Recipient.resolvedList(argThat { containsAll(keys.map { it.recipientId }) }) }.thenReturn(listOf(other, secondOther))
|
staticRecipient.`when`<List<Recipient>> { Recipient.resolvedList(argThat { containsAll(keys.map { it.recipientId }) }) }.thenReturn(listOf(other, secondOther))
|
||||||
whenever(profileService.performIdentityCheck(mapOf(other.requireServiceId() to identityPool[other]!!.identityKey, secondOther.requireServiceId() to identityPool[secondOther]!!.identityKey)))
|
whenever(profileService.performIdentityCheck(mapOf(other.requireServiceId() to identityPool[other]!!.identityKey, secondOther.requireServiceId() to identityPool[secondOther]!!.identityKey)))
|
||||||
|
@ -166,7 +166,7 @@ class SafetyNumberRepositoryTest {
|
||||||
@Test
|
@Test
|
||||||
fun batchSafetyNumberCheckSync_batchOf1_abortOnPriorRecentCheck() {
|
fun batchSafetyNumberCheckSync_batchOf1_abortOnPriorRecentCheck() {
|
||||||
val other = recipientPool[1]
|
val other = recipientPool[1]
|
||||||
val keys = listOf(ContactSearchKey.RecipientSearchKey.KnownRecipient(other.id))
|
val keys = listOf(ContactSearchKey.RecipientSearchKey(other.id, false))
|
||||||
|
|
||||||
staticRecipient.`when`<List<Recipient>> { Recipient.resolvedList(argThat { containsAll(keys.map { it.recipientId }) }) }.thenReturn(listOf(other))
|
staticRecipient.`when`<List<Recipient>> { Recipient.resolvedList(argThat { containsAll(keys.map { it.recipientId }) }) }.thenReturn(listOf(other))
|
||||||
whenever(profileService.performIdentityCheck(mapOf(other.requireServiceId() to identityPool[other]!!.identityKey)))
|
whenever(profileService.performIdentityCheck(mapOf(other.requireServiceId() to identityPool[other]!!.identityKey)))
|
||||||
|
@ -187,7 +187,7 @@ class SafetyNumberRepositoryTest {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
fun batchSafetyNumberCheckSync_batchOf10WithSmallBatchSize_noChanges() {
|
fun batchSafetyNumberCheckSync_batchOf10WithSmallBatchSize_noChanges() {
|
||||||
val keys = recipientPool.map { ContactSearchKey.RecipientSearchKey.KnownRecipient(it.id) }
|
val keys = recipientPool.map { ContactSearchKey.RecipientSearchKey(it.id, false) }
|
||||||
val others = recipientPool.subList(1, recipientPool.lastIndex)
|
val others = recipientPool.subList(1, recipientPool.lastIndex)
|
||||||
|
|
||||||
staticRecipient.`when`<List<Recipient>> { Recipient.resolvedList(argThat { containsAll(others.map { it.id }) }) }.thenReturn(others)
|
staticRecipient.`when`<List<Recipient>> { Recipient.resolvedList(argThat { containsAll(others.map { it.id }) }) }.thenReturn(others)
|
||||||
|
@ -205,7 +205,7 @@ class SafetyNumberRepositoryTest {
|
||||||
@Test
|
@Test
|
||||||
fun batchSafetyNumberCheckSync_serverError() {
|
fun batchSafetyNumberCheckSync_serverError() {
|
||||||
val other = recipientPool[1]
|
val other = recipientPool[1]
|
||||||
val keys = listOf(ContactSearchKey.RecipientSearchKey.KnownRecipient(other.id))
|
val keys = listOf(ContactSearchKey.RecipientSearchKey(other.id, false))
|
||||||
|
|
||||||
staticRecipient.`when`<List<Recipient>> { Recipient.resolvedList(argThat { containsAll(keys.map { it.recipientId }) }) }.thenReturn(listOf(other))
|
staticRecipient.`when`<List<Recipient>> { Recipient.resolvedList(argThat { containsAll(keys.map { it.recipientId }) }) }.thenReturn(listOf(other))
|
||||||
whenever(profileService.performIdentityCheck(mapOf(other.requireServiceId() to identityPool[other]!!.identityKey)))
|
whenever(profileService.performIdentityCheck(mapOf(other.requireServiceId() to identityPool[other]!!.identityKey)))
|
||||||
|
@ -219,7 +219,7 @@ class SafetyNumberRepositoryTest {
|
||||||
@Test
|
@Test
|
||||||
fun batchSafetyNumberCheckSync_networkError() {
|
fun batchSafetyNumberCheckSync_networkError() {
|
||||||
val other = recipientPool[1]
|
val other = recipientPool[1]
|
||||||
val keys = listOf(ContactSearchKey.RecipientSearchKey.KnownRecipient(other.id))
|
val keys = listOf(ContactSearchKey.RecipientSearchKey(other.id, false))
|
||||||
|
|
||||||
staticRecipient.`when`<List<Recipient>> { Recipient.resolvedList(argThat { containsAll(keys.map { it.recipientId }) }) }.thenReturn(listOf(other))
|
staticRecipient.`when`<List<Recipient>> { Recipient.resolvedList(argThat { containsAll(keys.map { it.recipientId }) }) }.thenReturn(listOf(other))
|
||||||
whenever(profileService.performIdentityCheck(mapOf(other.requireServiceId() to identityPool[other]!!.identityKey)))
|
whenever(profileService.performIdentityCheck(mapOf(other.requireServiceId() to identityPool[other]!!.identityKey)))
|
||||||
|
@ -233,7 +233,7 @@ class SafetyNumberRepositoryTest {
|
||||||
@Test
|
@Test
|
||||||
fun batchSafetyNumberCheckSync_badJson() {
|
fun batchSafetyNumberCheckSync_badJson() {
|
||||||
val other = recipientPool[1]
|
val other = recipientPool[1]
|
||||||
val keys = listOf(ContactSearchKey.RecipientSearchKey.KnownRecipient(other.id))
|
val keys = listOf(ContactSearchKey.RecipientSearchKey(other.id, false))
|
||||||
|
|
||||||
staticRecipient.`when`<List<Recipient>> { Recipient.resolvedList(argThat { containsAll(keys.map { it.recipientId }) }) }.thenReturn(listOf(other))
|
staticRecipient.`when`<List<Recipient>> { Recipient.resolvedList(argThat { containsAll(keys.map { it.recipientId }) }) }.thenReturn(listOf(other))
|
||||||
whenever(profileService.performIdentityCheck(mapOf(other.requireServiceId() to identityPool[other]!!.identityKey)))
|
whenever(profileService.performIdentityCheck(mapOf(other.requireServiceId() to identityPool[other]!!.identityKey)))
|
||||||
|
|
Loading…
Add table
Reference in a new issue