2021-01-13 07:11:30 +01:00
|
|
|
package org.thoughtcrime.securesms.database
|
|
|
|
|
|
|
|
import android.content.Context
|
|
|
|
import android.net.Uri
|
2022-10-05 01:05:26 +02:00
|
|
|
import org.session.libsession.avatars.AvatarHelper
|
2021-05-18 08:03:47 +02:00
|
|
|
import org.session.libsession.database.StorageProtocol
|
2022-08-10 10:17:48 +02:00
|
|
|
import org.session.libsession.messaging.BlindedIdMapping
|
Add one on one calls over clearnet (#864)
* feat: adding basic webrtc deps and test activity
* more testing code
* feat: add protos and bump version
* feat: added basic call functionality
* feat: adding UI and flipping cameras
* feat: add stats and starting call bottom sheet
* feat: hanging up and bottom sheet behaviors should work now
* feat: add call stats report on frontend
* feat: add relay toggle for answer and offer
* fix: add keep screen on and more end call message on back pressed / on finish
* refactor: removing and replacing dagger 1 dep with android hilt
* feat: include latest proto
* feat: update to utilise call ID
* feat: add stun and turn
* refactor: playing around with deps and transport types
* feat: adding call service functionality and permissions for calls
* feat: add call manager and more static intent building functions for WebRtcCallService.kt
* feat: adding ringers and more audio boilerplate
* feat: audio manager call service boilerplate
* feat: update kotlin and add in call view model and more management functions
* refactor: moving call code around to service and viewmodel interactions
* feat: plugging CallManager.kt into view model and service, fixing up dependencies
* feat: implementing more WebRtcCallService.kt functions and handlers for actions as well as lifecycle
* feat: adding more lifecycle vm and callmanager / call service functionality
* feat: adding more command handlers in WebRtcCallService.kt
* feat: more commands handled, adding lock manager and bluetooth permissions
* feat: adding remainder of basic functionality to services and CallManager.kt
* feat: hooking up calls and fixing broken dependencies and compile errors
* fix: add timestamp to incoming call
* feat: some connection and service launching / ring lifecycle
* feat: call establishing and displaying
* fix: fixing call connect flows
* feat: ringers and better state handling
* feat: updating call layout
* feat: add fixes to bluetooth and begin the network renegotiation
* feat: add call related permissions and more network handover tests
* fix: don't display call option in conversation and don't show notification if option not enabled
* fix: incoming ringer fix on receiving call, call notification priorities and notification channel update
* build: update build number for testing
* fix: bluetooth auto-connection and re-connection fixes, removing finished todos, allowing self-send call messages for deduping answers
* feat: add pre-offer information and action handling in web rtc call service
* refactor: discard offer messages from non-matching pre-offers we are already expecting
* build: build numbers and version name update
* feat: handle discarding pending calls from linked devices
* feat: add signing props to release config build
* docs: fix comment on time being 300s (5m) instead of 30s
* feat: adding call messages for incoming/outgoing/missed
* refactor: handle in-thread call notifications better and replace deny button intent with denyCallIntent instead of hangup
* feat: add a hangup via data channel message
* feat: process microphone enabled events and remove debuggable from build.gradle
* feat: add first call notification
* refactor: set the buttons to match iOS in terms of enable disable and colours
* refactor: change the call logos in control messages
* refactor: more bluetooth improvements
* refactor: move start ringer and init of audio manager to CallManager.kt and string fix up
* build: remove debuggable for release build
* refactor: replace call icons
* feat: adding a call time display
* refactor: change the call time to update every second
* refactor: testing out the full screen intents
* refactor: wrapper use corrected session description, set title to recipient displayName, indicate session calls
* fix: crash on view with a parent already attached
* refactor: aspect ratio fit preserved
* refactor: add wantsToAnswer ability in pre-init for fullscreenintent
* refactor: prevent calls from non hasSent participants
* build: update gradle code
* refactor: replace timeout schedule with a seconds count
* fix: various bug fixes for calls
* fix: remove end call from busy
* refactor: use answerCall instead of manual intent building again
* build: new version
* feat: add silenced notifications for call notification builder. check pre-offer and connecting state for pending connection
* build: update build number
* fix: text color uses overridden style value
* fix: remove wrap content for renderers and look more at recovering from network switches
* build: update build number
* refactor: remove whitespace
* build: update build number
* refactor: used shared number for BatchMessageReceiveJob.kt parameter across pollers
* fix: glide in update crash
* fix: bug fixes for self-send answer / hangup messages
* build: update build number
* build: update build.gradle number
* refactor: compile errors and refactoring to view binding
* fix: set the content to binding.root view
* build: increase build number
* build: update build numbers
* feat: adding base for rotation and picking random subset of turn servers
* feat: starting the screen rotation processing
* feat: setting up rotation for the remote render view
* refactor: applying rotation and mirroring based on front / rear cameras that wraps nicely, only scale reworking needed
* refactor: calls video stretching but consistent
* refactor: state machine and tests for the transition events
* feat: new call state processing
* refactor: adding reconnecting logic and visuals
* feat: state machine reconnect logic wip
* feat: add reconnecting and merge fixes
* feat: check new session based off current state
* feat: reconnection logic works correctly now
* refactor: reduce TIMEOUT_SECONDS to 30 from 90
* feat: reset peer connection on DC to prevent ICE messages from old connection or stale state in reconnecting
* refactor: add null case
* fix: set approved on new outgoing threads, use approved more deeply and invalidate the options menu on recipient modified. Add approvedMe flag toggles for visible message receive
* fix: add name update in action bar on modified, change where approvedMe is set
* build: increment build number
* build: update build number
* fix: merge compile errors and increment build number
* refactor: remove negotiation based on which party dropped connection
* refactor: call reconnection improvement tested cross platform to re-establish
* refactor: failed and disconnect events only handled if either the reconnect or the timeout runnables are not set
* build: update version number
* fix: reduce timeout
* fix: fixes the incoming hangup logic for linked devices
* refactor: match iOS styling for call activity closer
* chore: upgrade build numbers
* feat: add in call settings dialog for if calls is disabled in conversation
* feat: add a first call missed control message and info popup with link to privacy settings
* fix: looking at crash for specific large transaction in NotificationManager
* refactor: removing the people in case transaction size reduces to fix notif crash
* fix: comment out the entire send multiple to see if it fixes the issue
* refactor: revert to including the full notification process in a try/catch to handle weird responses from NotificationManager
* fix: add in notification settings prompt for calls and try to fall back to dirty full screen intent / start activity if we're allowed
* build: upgrade build number
2022-04-19 06:25:40 +02:00
|
|
|
import org.session.libsession.messaging.calls.CallMessageType
|
2021-05-07 08:31:46 +02:00
|
|
|
import org.session.libsession.messaging.contacts.Contact
|
2022-12-19 01:29:05 +01:00
|
|
|
import org.session.libsession.messaging.jobs.*
|
2022-09-04 13:03:32 +02:00
|
|
|
import org.session.libsession.messaging.messages.Message
|
2021-03-30 07:23:12 +02:00
|
|
|
import org.session.libsession.messaging.messages.control.ConfigurationMessage
|
2022-03-04 07:46:39 +01:00
|
|
|
import org.session.libsession.messaging.messages.control.MessageRequestResponse
|
2022-12-19 01:29:05 +01:00
|
|
|
import org.session.libsession.messaging.messages.signal.*
|
2021-01-13 07:11:30 +01:00
|
|
|
import org.session.libsession.messaging.messages.visible.Attachment
|
2022-10-04 09:31:20 +02:00
|
|
|
import org.session.libsession.messaging.messages.visible.Profile
|
2022-09-04 13:03:32 +02:00
|
|
|
import org.session.libsession.messaging.messages.visible.Reaction
|
2021-01-13 07:11:30 +01:00
|
|
|
import org.session.libsession.messaging.messages.visible.VisibleMessage
|
2022-08-10 10:17:48 +02:00
|
|
|
import org.session.libsession.messaging.open_groups.GroupMember
|
|
|
|
import org.session.libsession.messaging.open_groups.OpenGroup
|
2023-01-13 06:16:52 +01:00
|
|
|
import org.session.libsession.messaging.open_groups.OpenGroupApi
|
2021-01-13 07:11:30 +01:00
|
|
|
import org.session.libsession.messaging.sending_receiving.attachments.AttachmentId
|
2021-03-15 03:35:05 +01:00
|
|
|
import org.session.libsession.messaging.sending_receiving.attachments.DatabaseAttachment
|
2021-04-26 03:23:09 +02:00
|
|
|
import org.session.libsession.messaging.sending_receiving.data_extraction.DataExtractionNotificationInfoMessage
|
|
|
|
import org.session.libsession.messaging.sending_receiving.link_preview.LinkPreview
|
2021-01-13 07:11:30 +01:00
|
|
|
import org.session.libsession.messaging.sending_receiving.quotes.QuoteModel
|
2022-08-10 10:17:48 +02:00
|
|
|
import org.session.libsession.messaging.utilities.SessionId
|
|
|
|
import org.session.libsession.messaging.utilities.SodiumUtilities
|
2021-05-27 07:00:16 +02:00
|
|
|
import org.session.libsession.messaging.utilities.UpdateMessageData
|
2021-07-13 01:58:22 +02:00
|
|
|
import org.session.libsession.snode.OnionRequestAPI
|
2022-12-19 01:29:05 +01:00
|
|
|
import org.session.libsession.utilities.*
|
2021-05-18 08:11:38 +02:00
|
|
|
import org.session.libsession.utilities.Address.Companion.fromSerialized
|
2022-03-09 23:54:18 +01:00
|
|
|
import org.session.libsession.utilities.GroupRecord
|
|
|
|
import org.session.libsession.utilities.GroupUtil
|
|
|
|
import org.session.libsession.utilities.ProfileKeyUtil
|
2022-10-05 01:05:26 +02:00
|
|
|
import org.session.libsession.utilities.SSKEnvironment
|
2022-03-09 23:54:18 +01:00
|
|
|
import org.session.libsession.utilities.TextSecurePreferences
|
2021-05-18 08:03:47 +02:00
|
|
|
import org.session.libsession.utilities.recipients.Recipient
|
2021-05-18 01:21:56 +02:00
|
|
|
import org.session.libsignal.crypto.ecc.ECKeyPair
|
2021-05-18 01:50:16 +02:00
|
|
|
import org.session.libsignal.messages.SignalServiceAttachmentPointer
|
|
|
|
import org.session.libsignal.messages.SignalServiceGroup
|
2022-08-10 10:17:48 +02:00
|
|
|
import org.session.libsignal.utilities.IdPrefix
|
2021-05-27 07:00:16 +02:00
|
|
|
import org.session.libsignal.utilities.KeyHelper
|
|
|
|
import org.session.libsignal.utilities.guava.Optional
|
2021-01-14 03:26:53 +01:00
|
|
|
import org.thoughtcrime.securesms.database.helpers.SQLCipherOpenHelper
|
2022-09-04 13:03:32 +02:00
|
|
|
import org.thoughtcrime.securesms.database.model.MessageId
|
|
|
|
import org.thoughtcrime.securesms.database.model.ReactionRecord
|
2021-10-04 09:51:19 +02:00
|
|
|
import org.thoughtcrime.securesms.dependencies.DatabaseComponent
|
2021-07-09 05:25:57 +02:00
|
|
|
import org.thoughtcrime.securesms.groups.OpenGroupManager
|
2023-05-08 09:12:20 +02:00
|
|
|
import org.session.libsession.messaging.jobs.RetrieveProfileAvatarJob
|
2021-01-13 07:11:30 +01:00
|
|
|
import org.thoughtcrime.securesms.mms.PartAuthority
|
2021-07-23 08:04:18 +02:00
|
|
|
import org.thoughtcrime.securesms.util.SessionMetaProtocol
|
2022-10-05 01:05:26 +02:00
|
|
|
import java.security.MessageDigest
|
2021-01-13 07:11:30 +01:00
|
|
|
|
2021-01-14 03:26:53 +01:00
|
|
|
class Storage(context: Context, helper: SQLCipherOpenHelper) : Database(context, helper), StorageProtocol {
|
2021-05-21 07:09:50 +02:00
|
|
|
|
2021-01-13 07:11:30 +01:00
|
|
|
override fun getUserPublicKey(): String? {
|
|
|
|
return TextSecurePreferences.getLocalNumber(context)
|
|
|
|
}
|
|
|
|
|
2021-01-14 01:42:26 +01:00
|
|
|
override fun getUserX25519KeyPair(): ECKeyPair {
|
2021-10-04 09:51:19 +02:00
|
|
|
return DatabaseComponent.get(context).lokiAPIDatabase().getUserX25519KeyPair()
|
2021-01-14 01:42:26 +01:00
|
|
|
}
|
|
|
|
|
2022-10-04 09:31:20 +02:00
|
|
|
override fun getUserProfile(): Profile {
|
|
|
|
val displayName = TextSecurePreferences.getProfileName(context)!!
|
|
|
|
val profileKey = ProfileKeyUtil.getProfileKey(context)
|
|
|
|
val profilePictureUrl = TextSecurePreferences.getProfilePictureURL(context)
|
|
|
|
return Profile(displayName, profileKey, profilePictureUrl)
|
2021-01-13 07:11:30 +01:00
|
|
|
}
|
|
|
|
|
2023-05-30 04:43:51 +02:00
|
|
|
override fun setProfileAvatar(recipient: Recipient, profileAvatar: String?) {
|
2023-05-09 06:14:49 +02:00
|
|
|
val database = DatabaseComponent.get(context).recipientDatabase()
|
|
|
|
database.setProfileAvatar(recipient, profileAvatar)
|
|
|
|
}
|
|
|
|
|
2021-01-13 07:11:30 +01:00
|
|
|
override fun getOrGenerateRegistrationID(): Int {
|
|
|
|
var registrationID = TextSecurePreferences.getLocalRegistrationId(context)
|
2021-03-09 03:54:15 +01:00
|
|
|
if (registrationID == 0) {
|
2021-01-13 07:11:30 +01:00
|
|
|
registrationID = KeyHelper.generateRegistrationId(false)
|
|
|
|
TextSecurePreferences.setLocalRegistrationId(context, registrationID)
|
|
|
|
}
|
|
|
|
return registrationID
|
|
|
|
}
|
|
|
|
|
2021-05-21 07:02:34 +02:00
|
|
|
override fun persistAttachments(messageID: Long, attachments: List<Attachment>): List<Long> {
|
2021-10-04 09:51:19 +02:00
|
|
|
val database = DatabaseComponent.get(context).attachmentDatabase()
|
2021-03-02 07:22:56 +01:00
|
|
|
val databaseAttachments = attachments.mapNotNull { it.toSignalAttachment() }
|
2021-05-21 07:02:34 +02:00
|
|
|
return database.insertAttachments(messageID, databaseAttachments)
|
2021-01-13 07:11:30 +01:00
|
|
|
}
|
|
|
|
|
2021-05-21 07:02:34 +02:00
|
|
|
override fun getAttachmentsForMessage(messageID: Long): List<DatabaseAttachment> {
|
2021-10-04 09:51:19 +02:00
|
|
|
val database = DatabaseComponent.get(context).attachmentDatabase()
|
2021-05-21 07:02:34 +02:00
|
|
|
return database.getAttachmentsForMessage(messageID)
|
2021-03-15 03:35:05 +01:00
|
|
|
}
|
|
|
|
|
Performance improvements and bug fixes (#869)
* refactor: fail on testSnode instead of recursively using up snode list. add call timeout on http client
* refactor: refactoring batch message receives and pollers
* refactor: reduce thread utils pool count to a 2 thread fixed pool. Do a check against pubkey instead of room names for oxenHostedOpenGroup
* refactor: caching lib with potential loader fixes and no-cache for giphy
* refactor: remove store and instead use ConcurrentHashMap with a backing update coroutine
* refactor: queue trim thread jobs instead of add every message processed
* fix: wrapping auth token and initial sync for open groups in a threadutils queued runnable, getting initial sync times down
* fix: fixing the user contacts cache in ConversationAdapter.kt
* refactor: improve polling and initial sync, move group joins from config messages into a background job fetching image.
* refactor: improving the job queuing for open groups, replacing placeholder avatar generation with a custom glide loader and archiving initial sync of open groups
* feat: add OpenGroupDeleteJob.kt
* feat: add open group delete job to process deletions after batch adding
* feat: add vacuum and fix job queue re-adding jobs forever, only try to set message hash values in DB if they have changed
* refactor: remove redundant inflation for profile image views throughout app
* refactor(wip): reducing layout inflation and starting to refactor the open group deletion issues taking a long time
* refactor(wip): refactoring group deletion to not iterate through and delete messages individually
* refactor(wip): refactoring group deletion to not iterate through and delete messages individually
* fix: group deletion optimisation
* build: bump build number
* build: bump build number and fix batch message receive retry logic
* fix: clear out open group deletes
* fix: update visible ConversationAdapter.kt binding for initial contact fetching and better traces for debugging background jobs
* fix: add in check for / force sync latest encryption key pair from linked devices if we already have that closed group
* Rename .java to .kt
* refactor: change MmsDatabase to kotlin to make list operations easier
* fix: nullable type
* fix: compilation issues and constants in .kt instead of .java
* fix: bug fix expiration timer on closed group recipient
* feat: use the job queue properly across executors
* feat: start on open group dispatcher-specific logic, probably a queue factory based on openGroupId if that is the same across new message and deletion jobs to ensure consistent entry and removal
* refactor: removing redundant code and fixing jobqueue per opengroup
* fix: allow attachments in note to self
* fix: make the minWidth in quote view bind max of text / title and body, wrapped ?
* fix: fixing up layouts and code view layouts
* fix: remove TODO, remove timestamp binding
* feat: fix view logic, avatars and padding, downloading attachments lazily (on bind), fixing potential crash, add WindowDebouncer.kt
* fix: NPE on viewModel recipient from removed thread while tearing down the Recipient observer in ConversationActivityV2.kt
* refactor: replace conversation notification debouncer handler with handlerthread, same as conversation list debouncer
* refactor: UI for groups and poller improvements
* fix: revert some changes in poller
* feat: add header back in for message requests
* refactor: remove Trace calls, add more conditions to the HomeDiffUtil for updating more efficiently
* feat: try update the home adapter if we get a profile picture modified event
* feat: bump build numbers
* fix: try to start with list in homeViewModel if we don't have already, render quotes to be width of attachment slide view instead of fixed
* fix: set channel to be conflated instead of no buffer
* fix: set unreads based off last local user message vs incrementing unreads to be all amount
* feat: add profile update flag, update build number
* fix: link preview thumbnails download on bind
* fix: centercrop placeholder in glide request
* feat: recycle the contact selection list and profile image in unbind
* fix: try to prevent user KP crash at weird times
* fix: remove additional log, improve attachment download success rate, fix share logs dialog issue
2022-06-08 09:12:34 +02:00
|
|
|
override fun markConversationAsRead(threadId: Long, updateLastSeen: Boolean) {
|
|
|
|
val threadDb = DatabaseComponent.get(context).threadDatabase()
|
|
|
|
threadDb.setRead(threadId, updateLastSeen)
|
|
|
|
}
|
|
|
|
|
2023-01-17 06:30:05 +01:00
|
|
|
override fun incrementUnread(threadId: Long, amount: Int, unreadMentionAmount: Int) {
|
Performance improvements and bug fixes (#869)
* refactor: fail on testSnode instead of recursively using up snode list. add call timeout on http client
* refactor: refactoring batch message receives and pollers
* refactor: reduce thread utils pool count to a 2 thread fixed pool. Do a check against pubkey instead of room names for oxenHostedOpenGroup
* refactor: caching lib with potential loader fixes and no-cache for giphy
* refactor: remove store and instead use ConcurrentHashMap with a backing update coroutine
* refactor: queue trim thread jobs instead of add every message processed
* fix: wrapping auth token and initial sync for open groups in a threadutils queued runnable, getting initial sync times down
* fix: fixing the user contacts cache in ConversationAdapter.kt
* refactor: improve polling and initial sync, move group joins from config messages into a background job fetching image.
* refactor: improving the job queuing for open groups, replacing placeholder avatar generation with a custom glide loader and archiving initial sync of open groups
* feat: add OpenGroupDeleteJob.kt
* feat: add open group delete job to process deletions after batch adding
* feat: add vacuum and fix job queue re-adding jobs forever, only try to set message hash values in DB if they have changed
* refactor: remove redundant inflation for profile image views throughout app
* refactor(wip): reducing layout inflation and starting to refactor the open group deletion issues taking a long time
* refactor(wip): refactoring group deletion to not iterate through and delete messages individually
* refactor(wip): refactoring group deletion to not iterate through and delete messages individually
* fix: group deletion optimisation
* build: bump build number
* build: bump build number and fix batch message receive retry logic
* fix: clear out open group deletes
* fix: update visible ConversationAdapter.kt binding for initial contact fetching and better traces for debugging background jobs
* fix: add in check for / force sync latest encryption key pair from linked devices if we already have that closed group
* Rename .java to .kt
* refactor: change MmsDatabase to kotlin to make list operations easier
* fix: nullable type
* fix: compilation issues and constants in .kt instead of .java
* fix: bug fix expiration timer on closed group recipient
* feat: use the job queue properly across executors
* feat: start on open group dispatcher-specific logic, probably a queue factory based on openGroupId if that is the same across new message and deletion jobs to ensure consistent entry and removal
* refactor: removing redundant code and fixing jobqueue per opengroup
* fix: allow attachments in note to self
* fix: make the minWidth in quote view bind max of text / title and body, wrapped ?
* fix: fixing up layouts and code view layouts
* fix: remove TODO, remove timestamp binding
* feat: fix view logic, avatars and padding, downloading attachments lazily (on bind), fixing potential crash, add WindowDebouncer.kt
* fix: NPE on viewModel recipient from removed thread while tearing down the Recipient observer in ConversationActivityV2.kt
* refactor: replace conversation notification debouncer handler with handlerthread, same as conversation list debouncer
* refactor: UI for groups and poller improvements
* fix: revert some changes in poller
* feat: add header back in for message requests
* refactor: remove Trace calls, add more conditions to the HomeDiffUtil for updating more efficiently
* feat: try update the home adapter if we get a profile picture modified event
* feat: bump build numbers
* fix: try to start with list in homeViewModel if we don't have already, render quotes to be width of attachment slide view instead of fixed
* fix: set channel to be conflated instead of no buffer
* fix: set unreads based off last local user message vs incrementing unreads to be all amount
* feat: add profile update flag, update build number
* fix: link preview thumbnails download on bind
* fix: centercrop placeholder in glide request
* feat: recycle the contact selection list and profile image in unbind
* fix: try to prevent user KP crash at weird times
* fix: remove additional log, improve attachment download success rate, fix share logs dialog issue
2022-06-08 09:12:34 +02:00
|
|
|
val threadDb = DatabaseComponent.get(context).threadDatabase()
|
2023-01-17 06:30:05 +01:00
|
|
|
threadDb.incrementUnread(threadId, amount, unreadMentionAmount)
|
Performance improvements and bug fixes (#869)
* refactor: fail on testSnode instead of recursively using up snode list. add call timeout on http client
* refactor: refactoring batch message receives and pollers
* refactor: reduce thread utils pool count to a 2 thread fixed pool. Do a check against pubkey instead of room names for oxenHostedOpenGroup
* refactor: caching lib with potential loader fixes and no-cache for giphy
* refactor: remove store and instead use ConcurrentHashMap with a backing update coroutine
* refactor: queue trim thread jobs instead of add every message processed
* fix: wrapping auth token and initial sync for open groups in a threadutils queued runnable, getting initial sync times down
* fix: fixing the user contacts cache in ConversationAdapter.kt
* refactor: improve polling and initial sync, move group joins from config messages into a background job fetching image.
* refactor: improving the job queuing for open groups, replacing placeholder avatar generation with a custom glide loader and archiving initial sync of open groups
* feat: add OpenGroupDeleteJob.kt
* feat: add open group delete job to process deletions after batch adding
* feat: add vacuum and fix job queue re-adding jobs forever, only try to set message hash values in DB if they have changed
* refactor: remove redundant inflation for profile image views throughout app
* refactor(wip): reducing layout inflation and starting to refactor the open group deletion issues taking a long time
* refactor(wip): refactoring group deletion to not iterate through and delete messages individually
* refactor(wip): refactoring group deletion to not iterate through and delete messages individually
* fix: group deletion optimisation
* build: bump build number
* build: bump build number and fix batch message receive retry logic
* fix: clear out open group deletes
* fix: update visible ConversationAdapter.kt binding for initial contact fetching and better traces for debugging background jobs
* fix: add in check for / force sync latest encryption key pair from linked devices if we already have that closed group
* Rename .java to .kt
* refactor: change MmsDatabase to kotlin to make list operations easier
* fix: nullable type
* fix: compilation issues and constants in .kt instead of .java
* fix: bug fix expiration timer on closed group recipient
* feat: use the job queue properly across executors
* feat: start on open group dispatcher-specific logic, probably a queue factory based on openGroupId if that is the same across new message and deletion jobs to ensure consistent entry and removal
* refactor: removing redundant code and fixing jobqueue per opengroup
* fix: allow attachments in note to self
* fix: make the minWidth in quote view bind max of text / title and body, wrapped ?
* fix: fixing up layouts and code view layouts
* fix: remove TODO, remove timestamp binding
* feat: fix view logic, avatars and padding, downloading attachments lazily (on bind), fixing potential crash, add WindowDebouncer.kt
* fix: NPE on viewModel recipient from removed thread while tearing down the Recipient observer in ConversationActivityV2.kt
* refactor: replace conversation notification debouncer handler with handlerthread, same as conversation list debouncer
* refactor: UI for groups and poller improvements
* fix: revert some changes in poller
* feat: add header back in for message requests
* refactor: remove Trace calls, add more conditions to the HomeDiffUtil for updating more efficiently
* feat: try update the home adapter if we get a profile picture modified event
* feat: bump build numbers
* fix: try to start with list in homeViewModel if we don't have already, render quotes to be width of attachment slide view instead of fixed
* fix: set channel to be conflated instead of no buffer
* fix: set unreads based off last local user message vs incrementing unreads to be all amount
* feat: add profile update flag, update build number
* fix: link preview thumbnails download on bind
* fix: centercrop placeholder in glide request
* feat: recycle the contact selection list and profile image in unbind
* fix: try to prevent user KP crash at weird times
* fix: remove additional log, improve attachment download success rate, fix share logs dialog issue
2022-06-08 09:12:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
override fun updateThread(threadId: Long, unarchive: Boolean) {
|
|
|
|
val threadDb = DatabaseComponent.get(context).threadDatabase()
|
|
|
|
threadDb.update(threadId, unarchive)
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun persist(message: VisibleMessage,
|
|
|
|
quotes: QuoteModel?,
|
|
|
|
linkPreview: List<LinkPreview?>,
|
|
|
|
groupPublicKey: String?,
|
|
|
|
openGroupID: String?,
|
|
|
|
attachments: List<Attachment>,
|
|
|
|
runIncrement: Boolean,
|
|
|
|
runThreadUpdate: Boolean): Long? {
|
2021-01-19 07:06:02 +01:00
|
|
|
var messageID: Long? = null
|
2022-08-10 10:17:48 +02:00
|
|
|
val senderAddress = fromSerialized(message.sender!!)
|
2021-05-27 07:00:16 +02:00
|
|
|
val isUserSender = (message.sender!! == getUserPublicKey())
|
2022-08-10 10:17:48 +02:00
|
|
|
val isUserBlindedSender = message.threadID?.takeIf { it >= 0 }?.let { getOpenGroup(it)?.publicKey }
|
|
|
|
?.let { SodiumUtilities.sessionId(getUserPublicKey()!!, message.sender!!, it) } ?: false
|
2021-03-15 03:35:05 +01:00
|
|
|
val group: Optional<SignalServiceGroup> = when {
|
|
|
|
openGroupID != null -> Optional.of(SignalServiceGroup(openGroupID.toByteArray(), SignalServiceGroup.GroupType.PUBLIC_CHAT))
|
2021-03-19 07:08:31 +01:00
|
|
|
groupPublicKey != null -> {
|
|
|
|
val doubleEncoded = GroupUtil.doubleEncodeGroupID(groupPublicKey)
|
|
|
|
Optional.of(SignalServiceGroup(GroupUtil.getDecodedGroupIDAsData(doubleEncoded), SignalServiceGroup.GroupType.SIGNAL))
|
|
|
|
}
|
2021-03-15 03:35:05 +01:00
|
|
|
else -> Optional.absent()
|
|
|
|
}
|
2021-06-30 05:15:39 +02:00
|
|
|
val pointers = attachments.mapNotNull {
|
2021-03-15 03:35:05 +01:00
|
|
|
it.toSignalAttachment()
|
2021-01-19 07:06:02 +01:00
|
|
|
}
|
2022-08-10 10:17:48 +02:00
|
|
|
val targetAddress = if ((isUserSender || isUserBlindedSender) && !message.syncTarget.isNullOrEmpty()) {
|
|
|
|
fromSerialized(message.syncTarget!!)
|
2021-03-25 05:12:55 +01:00
|
|
|
} else if (group.isPresent) {
|
2022-08-10 10:17:48 +02:00
|
|
|
fromSerialized(GroupUtil.getEncodedId(group.get()))
|
2021-03-25 05:12:55 +01:00
|
|
|
} else {
|
|
|
|
senderAddress
|
|
|
|
}
|
|
|
|
val targetRecipient = Recipient.from(context, targetAddress, false)
|
2022-03-09 23:54:18 +01:00
|
|
|
if (!targetRecipient.isGroupRecipient) {
|
|
|
|
val recipientDb = DatabaseComponent.get(context).recipientDatabase()
|
2022-08-10 10:17:48 +02:00
|
|
|
if (isUserSender || isUserBlindedSender) {
|
2022-03-09 23:54:18 +01:00
|
|
|
recipientDb.setApproved(targetRecipient, true)
|
|
|
|
} else {
|
|
|
|
recipientDb.setApprovedMe(targetRecipient, true)
|
|
|
|
}
|
|
|
|
}
|
2021-03-15 03:35:05 +01:00
|
|
|
if (message.isMediaMessage() || attachments.isNotEmpty()) {
|
2021-01-19 07:06:02 +01:00
|
|
|
val quote: Optional<QuoteModel> = if (quotes != null) Optional.of(quotes) else Optional.absent()
|
|
|
|
val linkPreviews: Optional<List<LinkPreview>> = if (linkPreview.isEmpty()) Optional.absent() else Optional.of(linkPreview.mapNotNull { it!! })
|
2021-10-04 09:51:19 +02:00
|
|
|
val mmsDatabase = DatabaseComponent.get(context).mmsDatabase()
|
2022-08-10 10:17:48 +02:00
|
|
|
val insertResult = if (isUserSender || isUserBlindedSender) {
|
2021-06-30 05:15:39 +02:00
|
|
|
val mediaMessage = OutgoingMediaMessage.from(message, targetRecipient, pointers, quote.orNull(), linkPreviews.orNull()?.firstOrNull())
|
Performance improvements and bug fixes (#869)
* refactor: fail on testSnode instead of recursively using up snode list. add call timeout on http client
* refactor: refactoring batch message receives and pollers
* refactor: reduce thread utils pool count to a 2 thread fixed pool. Do a check against pubkey instead of room names for oxenHostedOpenGroup
* refactor: caching lib with potential loader fixes and no-cache for giphy
* refactor: remove store and instead use ConcurrentHashMap with a backing update coroutine
* refactor: queue trim thread jobs instead of add every message processed
* fix: wrapping auth token and initial sync for open groups in a threadutils queued runnable, getting initial sync times down
* fix: fixing the user contacts cache in ConversationAdapter.kt
* refactor: improve polling and initial sync, move group joins from config messages into a background job fetching image.
* refactor: improving the job queuing for open groups, replacing placeholder avatar generation with a custom glide loader and archiving initial sync of open groups
* feat: add OpenGroupDeleteJob.kt
* feat: add open group delete job to process deletions after batch adding
* feat: add vacuum and fix job queue re-adding jobs forever, only try to set message hash values in DB if they have changed
* refactor: remove redundant inflation for profile image views throughout app
* refactor(wip): reducing layout inflation and starting to refactor the open group deletion issues taking a long time
* refactor(wip): refactoring group deletion to not iterate through and delete messages individually
* refactor(wip): refactoring group deletion to not iterate through and delete messages individually
* fix: group deletion optimisation
* build: bump build number
* build: bump build number and fix batch message receive retry logic
* fix: clear out open group deletes
* fix: update visible ConversationAdapter.kt binding for initial contact fetching and better traces for debugging background jobs
* fix: add in check for / force sync latest encryption key pair from linked devices if we already have that closed group
* Rename .java to .kt
* refactor: change MmsDatabase to kotlin to make list operations easier
* fix: nullable type
* fix: compilation issues and constants in .kt instead of .java
* fix: bug fix expiration timer on closed group recipient
* feat: use the job queue properly across executors
* feat: start on open group dispatcher-specific logic, probably a queue factory based on openGroupId if that is the same across new message and deletion jobs to ensure consistent entry and removal
* refactor: removing redundant code and fixing jobqueue per opengroup
* fix: allow attachments in note to self
* fix: make the minWidth in quote view bind max of text / title and body, wrapped ?
* fix: fixing up layouts and code view layouts
* fix: remove TODO, remove timestamp binding
* feat: fix view logic, avatars and padding, downloading attachments lazily (on bind), fixing potential crash, add WindowDebouncer.kt
* fix: NPE on viewModel recipient from removed thread while tearing down the Recipient observer in ConversationActivityV2.kt
* refactor: replace conversation notification debouncer handler with handlerthread, same as conversation list debouncer
* refactor: UI for groups and poller improvements
* fix: revert some changes in poller
* feat: add header back in for message requests
* refactor: remove Trace calls, add more conditions to the HomeDiffUtil for updating more efficiently
* feat: try update the home adapter if we get a profile picture modified event
* feat: bump build numbers
* fix: try to start with list in homeViewModel if we don't have already, render quotes to be width of attachment slide view instead of fixed
* fix: set channel to be conflated instead of no buffer
* fix: set unreads based off last local user message vs incrementing unreads to be all amount
* feat: add profile update flag, update build number
* fix: link preview thumbnails download on bind
* fix: centercrop placeholder in glide request
* feat: recycle the contact selection list and profile image in unbind
* fix: try to prevent user KP crash at weird times
* fix: remove additional log, improve attachment download success rate, fix share logs dialog issue
2022-06-08 09:12:34 +02:00
|
|
|
mmsDatabase.insertSecureDecryptedMessageOutbox(mediaMessage, message.threadID ?: -1, message.sentTimestamp!!, runThreadUpdate)
|
2021-01-19 07:06:02 +01:00
|
|
|
} else {
|
2021-02-11 05:00:27 +01:00
|
|
|
// It seems like we have replaced SignalServiceAttachment with SessionServiceAttachment
|
2021-03-15 03:35:05 +01:00
|
|
|
val signalServiceAttachments = attachments.mapNotNull {
|
|
|
|
it.toSignalPointer()
|
|
|
|
}
|
2021-03-25 05:12:55 +01:00
|
|
|
val mediaMessage = IncomingMediaMessage.from(message, senderAddress, targetRecipient.expireMessages * 1000L, group, signalServiceAttachments, quote, linkPreviews)
|
Performance improvements and bug fixes (#869)
* refactor: fail on testSnode instead of recursively using up snode list. add call timeout on http client
* refactor: refactoring batch message receives and pollers
* refactor: reduce thread utils pool count to a 2 thread fixed pool. Do a check against pubkey instead of room names for oxenHostedOpenGroup
* refactor: caching lib with potential loader fixes and no-cache for giphy
* refactor: remove store and instead use ConcurrentHashMap with a backing update coroutine
* refactor: queue trim thread jobs instead of add every message processed
* fix: wrapping auth token and initial sync for open groups in a threadutils queued runnable, getting initial sync times down
* fix: fixing the user contacts cache in ConversationAdapter.kt
* refactor: improve polling and initial sync, move group joins from config messages into a background job fetching image.
* refactor: improving the job queuing for open groups, replacing placeholder avatar generation with a custom glide loader and archiving initial sync of open groups
* feat: add OpenGroupDeleteJob.kt
* feat: add open group delete job to process deletions after batch adding
* feat: add vacuum and fix job queue re-adding jobs forever, only try to set message hash values in DB if they have changed
* refactor: remove redundant inflation for profile image views throughout app
* refactor(wip): reducing layout inflation and starting to refactor the open group deletion issues taking a long time
* refactor(wip): refactoring group deletion to not iterate through and delete messages individually
* refactor(wip): refactoring group deletion to not iterate through and delete messages individually
* fix: group deletion optimisation
* build: bump build number
* build: bump build number and fix batch message receive retry logic
* fix: clear out open group deletes
* fix: update visible ConversationAdapter.kt binding for initial contact fetching and better traces for debugging background jobs
* fix: add in check for / force sync latest encryption key pair from linked devices if we already have that closed group
* Rename .java to .kt
* refactor: change MmsDatabase to kotlin to make list operations easier
* fix: nullable type
* fix: compilation issues and constants in .kt instead of .java
* fix: bug fix expiration timer on closed group recipient
* feat: use the job queue properly across executors
* feat: start on open group dispatcher-specific logic, probably a queue factory based on openGroupId if that is the same across new message and deletion jobs to ensure consistent entry and removal
* refactor: removing redundant code and fixing jobqueue per opengroup
* fix: allow attachments in note to self
* fix: make the minWidth in quote view bind max of text / title and body, wrapped ?
* fix: fixing up layouts and code view layouts
* fix: remove TODO, remove timestamp binding
* feat: fix view logic, avatars and padding, downloading attachments lazily (on bind), fixing potential crash, add WindowDebouncer.kt
* fix: NPE on viewModel recipient from removed thread while tearing down the Recipient observer in ConversationActivityV2.kt
* refactor: replace conversation notification debouncer handler with handlerthread, same as conversation list debouncer
* refactor: UI for groups and poller improvements
* fix: revert some changes in poller
* feat: add header back in for message requests
* refactor: remove Trace calls, add more conditions to the HomeDiffUtil for updating more efficiently
* feat: try update the home adapter if we get a profile picture modified event
* feat: bump build numbers
* fix: try to start with list in homeViewModel if we don't have already, render quotes to be width of attachment slide view instead of fixed
* fix: set channel to be conflated instead of no buffer
* fix: set unreads based off last local user message vs incrementing unreads to be all amount
* feat: add profile update flag, update build number
* fix: link preview thumbnails download on bind
* fix: centercrop placeholder in glide request
* feat: recycle the contact selection list and profile image in unbind
* fix: try to prevent user KP crash at weird times
* fix: remove additional log, improve attachment download success rate, fix share logs dialog issue
2022-06-08 09:12:34 +02:00
|
|
|
mmsDatabase.insertSecureDecryptedMessageInbox(mediaMessage, message.threadID ?: -1, message.receivedTimestamp ?: 0, runIncrement, runThreadUpdate)
|
2021-01-19 07:06:02 +01:00
|
|
|
}
|
|
|
|
if (insertResult.isPresent) {
|
|
|
|
messageID = insertResult.get().messageId
|
|
|
|
}
|
|
|
|
} else {
|
2021-10-04 09:51:19 +02:00
|
|
|
val smsDatabase = DatabaseComponent.get(context).smsDatabase()
|
2021-05-17 07:18:41 +02:00
|
|
|
val isOpenGroupInvitation = (message.openGroupInvitation != null)
|
2021-05-12 00:40:10 +02:00
|
|
|
|
2022-08-10 10:17:48 +02:00
|
|
|
val insertResult = if (isUserSender || isUserBlindedSender) {
|
2021-05-12 00:40:10 +02:00
|
|
|
val textMessage = if (isOpenGroupInvitation) OutgoingTextMessage.fromOpenGroupInvitation(message.openGroupInvitation, targetRecipient, message.sentTimestamp)
|
|
|
|
else OutgoingTextMessage.from(message, targetRecipient)
|
Performance improvements and bug fixes (#869)
* refactor: fail on testSnode instead of recursively using up snode list. add call timeout on http client
* refactor: refactoring batch message receives and pollers
* refactor: reduce thread utils pool count to a 2 thread fixed pool. Do a check against pubkey instead of room names for oxenHostedOpenGroup
* refactor: caching lib with potential loader fixes and no-cache for giphy
* refactor: remove store and instead use ConcurrentHashMap with a backing update coroutine
* refactor: queue trim thread jobs instead of add every message processed
* fix: wrapping auth token and initial sync for open groups in a threadutils queued runnable, getting initial sync times down
* fix: fixing the user contacts cache in ConversationAdapter.kt
* refactor: improve polling and initial sync, move group joins from config messages into a background job fetching image.
* refactor: improving the job queuing for open groups, replacing placeholder avatar generation with a custom glide loader and archiving initial sync of open groups
* feat: add OpenGroupDeleteJob.kt
* feat: add open group delete job to process deletions after batch adding
* feat: add vacuum and fix job queue re-adding jobs forever, only try to set message hash values in DB if they have changed
* refactor: remove redundant inflation for profile image views throughout app
* refactor(wip): reducing layout inflation and starting to refactor the open group deletion issues taking a long time
* refactor(wip): refactoring group deletion to not iterate through and delete messages individually
* refactor(wip): refactoring group deletion to not iterate through and delete messages individually
* fix: group deletion optimisation
* build: bump build number
* build: bump build number and fix batch message receive retry logic
* fix: clear out open group deletes
* fix: update visible ConversationAdapter.kt binding for initial contact fetching and better traces for debugging background jobs
* fix: add in check for / force sync latest encryption key pair from linked devices if we already have that closed group
* Rename .java to .kt
* refactor: change MmsDatabase to kotlin to make list operations easier
* fix: nullable type
* fix: compilation issues and constants in .kt instead of .java
* fix: bug fix expiration timer on closed group recipient
* feat: use the job queue properly across executors
* feat: start on open group dispatcher-specific logic, probably a queue factory based on openGroupId if that is the same across new message and deletion jobs to ensure consistent entry and removal
* refactor: removing redundant code and fixing jobqueue per opengroup
* fix: allow attachments in note to self
* fix: make the minWidth in quote view bind max of text / title and body, wrapped ?
* fix: fixing up layouts and code view layouts
* fix: remove TODO, remove timestamp binding
* feat: fix view logic, avatars and padding, downloading attachments lazily (on bind), fixing potential crash, add WindowDebouncer.kt
* fix: NPE on viewModel recipient from removed thread while tearing down the Recipient observer in ConversationActivityV2.kt
* refactor: replace conversation notification debouncer handler with handlerthread, same as conversation list debouncer
* refactor: UI for groups and poller improvements
* fix: revert some changes in poller
* feat: add header back in for message requests
* refactor: remove Trace calls, add more conditions to the HomeDiffUtil for updating more efficiently
* feat: try update the home adapter if we get a profile picture modified event
* feat: bump build numbers
* fix: try to start with list in homeViewModel if we don't have already, render quotes to be width of attachment slide view instead of fixed
* fix: set channel to be conflated instead of no buffer
* fix: set unreads based off last local user message vs incrementing unreads to be all amount
* feat: add profile update flag, update build number
* fix: link preview thumbnails download on bind
* fix: centercrop placeholder in glide request
* feat: recycle the contact selection list and profile image in unbind
* fix: try to prevent user KP crash at weird times
* fix: remove additional log, improve attachment download success rate, fix share logs dialog issue
2022-06-08 09:12:34 +02:00
|
|
|
smsDatabase.insertMessageOutbox(message.threadID ?: -1, textMessage, message.sentTimestamp!!, runThreadUpdate)
|
2021-02-11 05:00:27 +01:00
|
|
|
} else {
|
2021-05-12 00:40:10 +02:00
|
|
|
val textMessage = if (isOpenGroupInvitation) IncomingTextMessage.fromOpenGroupInvitation(message.openGroupInvitation, senderAddress, message.sentTimestamp)
|
|
|
|
else IncomingTextMessage.from(message, senderAddress, group, targetRecipient.expireMessages * 1000L)
|
2021-03-15 05:03:23 +01:00
|
|
|
val encrypted = IncomingEncryptedMessage(textMessage, textMessage.messageBody)
|
Performance improvements and bug fixes (#869)
* refactor: fail on testSnode instead of recursively using up snode list. add call timeout on http client
* refactor: refactoring batch message receives and pollers
* refactor: reduce thread utils pool count to a 2 thread fixed pool. Do a check against pubkey instead of room names for oxenHostedOpenGroup
* refactor: caching lib with potential loader fixes and no-cache for giphy
* refactor: remove store and instead use ConcurrentHashMap with a backing update coroutine
* refactor: queue trim thread jobs instead of add every message processed
* fix: wrapping auth token and initial sync for open groups in a threadutils queued runnable, getting initial sync times down
* fix: fixing the user contacts cache in ConversationAdapter.kt
* refactor: improve polling and initial sync, move group joins from config messages into a background job fetching image.
* refactor: improving the job queuing for open groups, replacing placeholder avatar generation with a custom glide loader and archiving initial sync of open groups
* feat: add OpenGroupDeleteJob.kt
* feat: add open group delete job to process deletions after batch adding
* feat: add vacuum and fix job queue re-adding jobs forever, only try to set message hash values in DB if they have changed
* refactor: remove redundant inflation for profile image views throughout app
* refactor(wip): reducing layout inflation and starting to refactor the open group deletion issues taking a long time
* refactor(wip): refactoring group deletion to not iterate through and delete messages individually
* refactor(wip): refactoring group deletion to not iterate through and delete messages individually
* fix: group deletion optimisation
* build: bump build number
* build: bump build number and fix batch message receive retry logic
* fix: clear out open group deletes
* fix: update visible ConversationAdapter.kt binding for initial contact fetching and better traces for debugging background jobs
* fix: add in check for / force sync latest encryption key pair from linked devices if we already have that closed group
* Rename .java to .kt
* refactor: change MmsDatabase to kotlin to make list operations easier
* fix: nullable type
* fix: compilation issues and constants in .kt instead of .java
* fix: bug fix expiration timer on closed group recipient
* feat: use the job queue properly across executors
* feat: start on open group dispatcher-specific logic, probably a queue factory based on openGroupId if that is the same across new message and deletion jobs to ensure consistent entry and removal
* refactor: removing redundant code and fixing jobqueue per opengroup
* fix: allow attachments in note to self
* fix: make the minWidth in quote view bind max of text / title and body, wrapped ?
* fix: fixing up layouts and code view layouts
* fix: remove TODO, remove timestamp binding
* feat: fix view logic, avatars and padding, downloading attachments lazily (on bind), fixing potential crash, add WindowDebouncer.kt
* fix: NPE on viewModel recipient from removed thread while tearing down the Recipient observer in ConversationActivityV2.kt
* refactor: replace conversation notification debouncer handler with handlerthread, same as conversation list debouncer
* refactor: UI for groups and poller improvements
* fix: revert some changes in poller
* feat: add header back in for message requests
* refactor: remove Trace calls, add more conditions to the HomeDiffUtil for updating more efficiently
* feat: try update the home adapter if we get a profile picture modified event
* feat: bump build numbers
* fix: try to start with list in homeViewModel if we don't have already, render quotes to be width of attachment slide view instead of fixed
* fix: set channel to be conflated instead of no buffer
* fix: set unreads based off last local user message vs incrementing unreads to be all amount
* feat: add profile update flag, update build number
* fix: link preview thumbnails download on bind
* fix: centercrop placeholder in glide request
* feat: recycle the contact selection list and profile image in unbind
* fix: try to prevent user KP crash at weird times
* fix: remove additional log, improve attachment download success rate, fix share logs dialog issue
2022-06-08 09:12:34 +02:00
|
|
|
smsDatabase.insertMessageInbox(encrypted, message.receivedTimestamp ?: 0, runIncrement, runThreadUpdate)
|
2021-02-11 05:00:27 +01:00
|
|
|
}
|
2021-03-15 05:03:23 +01:00
|
|
|
insertResult.orNull()?.let { result ->
|
|
|
|
messageID = result.messageId
|
2021-01-19 07:06:02 +01:00
|
|
|
}
|
|
|
|
}
|
2021-08-17 06:34:49 +02:00
|
|
|
message.serverHash?.let { serverHash ->
|
|
|
|
messageID?.let { id ->
|
2021-10-04 09:51:19 +02:00
|
|
|
DatabaseComponent.get(context).lokiMessageDatabase().setMessageServerHash(id, serverHash)
|
2021-08-17 06:34:49 +02:00
|
|
|
}
|
|
|
|
}
|
2021-01-19 07:06:02 +01:00
|
|
|
return messageID
|
2021-01-13 07:11:30 +01:00
|
|
|
}
|
|
|
|
|
2021-01-29 01:16:53 +01:00
|
|
|
override fun persistJob(job: Job) {
|
2021-10-04 09:51:19 +02:00
|
|
|
DatabaseComponent.get(context).sessionJobDatabase().persistJob(job)
|
2021-01-28 05:24:27 +01:00
|
|
|
}
|
|
|
|
|
2021-05-07 03:48:03 +02:00
|
|
|
override fun markJobAsSucceeded(jobId: String) {
|
2021-10-04 09:51:19 +02:00
|
|
|
DatabaseComponent.get(context).sessionJobDatabase().markJobAsSucceeded(jobId)
|
2021-01-13 07:11:30 +01:00
|
|
|
}
|
|
|
|
|
2021-05-13 01:38:39 +02:00
|
|
|
override fun markJobAsFailedPermanently(jobId: String) {
|
2021-10-04 09:51:19 +02:00
|
|
|
DatabaseComponent.get(context).sessionJobDatabase().markJobAsFailedPermanently(jobId)
|
2021-01-13 07:11:30 +01:00
|
|
|
}
|
|
|
|
|
2021-05-07 03:48:03 +02:00
|
|
|
override fun getAllPendingJobs(type: String): Map<String, Job?> {
|
2023-05-04 07:30:09 +02:00
|
|
|
return DatabaseComponent.get(context).sessionJobDatabase().getAllJobs(type)
|
2021-01-13 07:11:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
override fun getAttachmentUploadJob(attachmentID: Long): AttachmentUploadJob? {
|
2021-10-04 09:51:19 +02:00
|
|
|
return DatabaseComponent.get(context).sessionJobDatabase().getAttachmentUploadJob(attachmentID)
|
2021-01-13 07:11:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
override fun getMessageSendJob(messageSendJobID: String): MessageSendJob? {
|
2021-10-04 09:51:19 +02:00
|
|
|
return DatabaseComponent.get(context).sessionJobDatabase().getMessageSendJob(messageSendJobID)
|
2021-01-13 07:11:30 +01:00
|
|
|
}
|
|
|
|
|
2021-05-24 08:21:24 +02:00
|
|
|
override fun getMessageReceiveJob(messageReceiveJobID: String): MessageReceiveJob? {
|
2021-10-04 09:51:19 +02:00
|
|
|
return DatabaseComponent.get(context).sessionJobDatabase().getMessageReceiveJob(messageReceiveJobID)
|
2021-05-21 06:55:06 +02:00
|
|
|
}
|
|
|
|
|
2023-02-08 03:42:35 +01:00
|
|
|
override fun getGroupAvatarDownloadJob(server: String, room: String, imageId: String?): GroupAvatarDownloadJob? {
|
|
|
|
return DatabaseComponent.get(context).sessionJobDatabase().getGroupAvatarDownloadJob(server, room, imageId)
|
2021-12-15 07:11:55 +01:00
|
|
|
}
|
|
|
|
|
2021-01-13 07:11:30 +01:00
|
|
|
override fun resumeMessageSendJobIfNeeded(messageSendJobID: String) {
|
2021-10-04 09:51:19 +02:00
|
|
|
val job = DatabaseComponent.get(context).sessionJobDatabase().getMessageSendJob(messageSendJobID) ?: return
|
2021-07-05 07:00:32 +02:00
|
|
|
JobQueue.shared.resumePendingSendMessage(job)
|
2021-01-13 07:11:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
override fun isJobCanceled(job: Job): Boolean {
|
2021-10-04 09:51:19 +02:00
|
|
|
return DatabaseComponent.get(context).sessionJobDatabase().isJobCanceled(job)
|
2021-01-13 07:11:30 +01:00
|
|
|
}
|
|
|
|
|
2021-04-13 09:17:16 +02:00
|
|
|
override fun getAuthToken(room: String, server: String): String? {
|
|
|
|
val id = "$server.$room"
|
2021-10-04 09:51:19 +02:00
|
|
|
return DatabaseComponent.get(context).lokiAPIDatabase().getAuthToken(id)
|
2021-04-13 09:17:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
override fun setAuthToken(room: String, server: String, newValue: String) {
|
|
|
|
val id = "$server.$room"
|
2021-10-04 09:51:19 +02:00
|
|
|
DatabaseComponent.get(context).lokiAPIDatabase().setAuthToken(id, newValue)
|
2021-04-13 09:17:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
override fun removeAuthToken(room: String, server: String) {
|
|
|
|
val id = "$server.$room"
|
2021-10-04 09:51:19 +02:00
|
|
|
DatabaseComponent.get(context).lokiAPIDatabase().setAuthToken(id, null)
|
2021-04-13 09:17:16 +02:00
|
|
|
}
|
|
|
|
|
2022-08-10 10:17:48 +02:00
|
|
|
override fun getOpenGroup(threadId: Long): OpenGroup? {
|
2021-04-13 09:17:16 +02:00
|
|
|
if (threadId.toInt() < 0) { return null }
|
|
|
|
val database = databaseHelper.readableDatabase
|
2021-05-21 07:02:34 +02:00
|
|
|
return database.get(LokiThreadDatabase.publicChatTable, "${LokiThreadDatabase.threadID} = ?", arrayOf( threadId.toString() )) { cursor ->
|
2021-04-13 09:17:16 +02:00
|
|
|
val publicChatAsJson = cursor.getString(LokiThreadDatabase.publicChat)
|
2022-08-10 10:17:48 +02:00
|
|
|
OpenGroup.fromJSON(publicChatAsJson)
|
2021-04-13 09:17:16 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-13 07:11:30 +01:00
|
|
|
override fun getOpenGroupPublicKey(server: String): String? {
|
2021-10-04 09:51:19 +02:00
|
|
|
return DatabaseComponent.get(context).lokiAPIDatabase().getOpenGroupPublicKey(server)
|
2021-01-13 07:11:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
override fun setOpenGroupPublicKey(server: String, newValue: String) {
|
2021-10-04 09:51:19 +02:00
|
|
|
DatabaseComponent.get(context).lokiAPIDatabase().setOpenGroupPublicKey(server, newValue)
|
2021-01-13 07:11:30 +01:00
|
|
|
}
|
|
|
|
|
2021-05-21 07:02:34 +02:00
|
|
|
override fun getLastMessageServerID(room: String, server: String): Long? {
|
2021-10-04 09:51:19 +02:00
|
|
|
return DatabaseComponent.get(context).lokiAPIDatabase().getLastMessageServerID(room, server)
|
2021-04-13 09:17:16 +02:00
|
|
|
}
|
|
|
|
|
2021-05-21 07:02:34 +02:00
|
|
|
override fun setLastMessageServerID(room: String, server: String, newValue: Long) {
|
2021-10-04 09:51:19 +02:00
|
|
|
DatabaseComponent.get(context).lokiAPIDatabase().setLastMessageServerID(room, server, newValue)
|
2021-04-13 09:17:16 +02:00
|
|
|
}
|
|
|
|
|
2021-05-21 07:02:34 +02:00
|
|
|
override fun removeLastMessageServerID(room: String, server: String) {
|
2021-10-04 09:51:19 +02:00
|
|
|
DatabaseComponent.get(context).lokiAPIDatabase().removeLastMessageServerID(room, server)
|
2021-04-13 09:17:16 +02:00
|
|
|
}
|
|
|
|
|
2021-05-21 07:02:34 +02:00
|
|
|
override fun getLastDeletionServerID(room: String, server: String): Long? {
|
2021-10-04 09:51:19 +02:00
|
|
|
return DatabaseComponent.get(context).lokiAPIDatabase().getLastDeletionServerID(room, server)
|
2021-04-13 09:17:16 +02:00
|
|
|
}
|
|
|
|
|
2021-05-21 07:02:34 +02:00
|
|
|
override fun setLastDeletionServerID(room: String, server: String, newValue: Long) {
|
2021-10-04 09:51:19 +02:00
|
|
|
DatabaseComponent.get(context).lokiAPIDatabase().setLastDeletionServerID(room, server, newValue)
|
2021-04-13 09:17:16 +02:00
|
|
|
}
|
|
|
|
|
2021-05-21 07:02:34 +02:00
|
|
|
override fun removeLastDeletionServerID(room: String, server: String) {
|
2021-10-04 09:51:19 +02:00
|
|
|
DatabaseComponent.get(context).lokiAPIDatabase().removeLastDeletionServerID(room, server)
|
2021-04-19 02:16:38 +02:00
|
|
|
}
|
|
|
|
|
2021-05-05 05:52:15 +02:00
|
|
|
override fun setUserCount(room: String, server: String, newValue: Int) {
|
2021-10-04 09:51:19 +02:00
|
|
|
DatabaseComponent.get(context).lokiAPIDatabase().setUserCount(room, server, newValue)
|
2021-04-13 09:17:16 +02:00
|
|
|
}
|
|
|
|
|
2021-05-21 07:02:34 +02:00
|
|
|
override fun setOpenGroupServerMessageID(messageID: Long, serverID: Long, threadID: Long, isSms: Boolean) {
|
2021-10-04 09:51:19 +02:00
|
|
|
DatabaseComponent.get(context).lokiMessageDatabase().setServerID(messageID, serverID, isSms)
|
|
|
|
DatabaseComponent.get(context).lokiMessageDatabase().setOriginalThreadID(messageID, serverID, threadID)
|
2021-01-13 07:11:30 +01:00
|
|
|
}
|
|
|
|
|
2022-08-10 10:17:48 +02:00
|
|
|
override fun getOpenGroup(room: String, server: String): OpenGroup? {
|
|
|
|
return getAllOpenGroups().values.firstOrNull { it.server == server && it.room == room }
|
|
|
|
}
|
|
|
|
|
2022-09-26 03:44:59 +02:00
|
|
|
override fun setGroupMemberRoles(members: List<GroupMember>) {
|
|
|
|
DatabaseComponent.get(context).groupMemberDatabase().setGroupMembers(members)
|
2022-08-10 10:17:48 +02:00
|
|
|
}
|
|
|
|
|
2021-05-19 00:56:44 +02:00
|
|
|
override fun isDuplicateMessage(timestamp: Long): Boolean {
|
2021-03-23 05:56:15 +01:00
|
|
|
return getReceivedMessageTimestamps().contains(timestamp)
|
2021-02-16 05:24:21 +01:00
|
|
|
}
|
|
|
|
|
2021-01-13 07:11:30 +01:00
|
|
|
override fun updateTitle(groupID: String, newValue: String) {
|
2021-10-04 09:51:19 +02:00
|
|
|
DatabaseComponent.get(context).groupDatabase().updateTitle(groupID, newValue)
|
2021-01-13 07:11:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
override fun updateProfilePicture(groupID: String, newValue: ByteArray) {
|
2021-10-04 09:51:19 +02:00
|
|
|
DatabaseComponent.get(context).groupDatabase().updateProfilePicture(groupID, newValue)
|
2021-01-13 07:11:30 +01:00
|
|
|
}
|
|
|
|
|
2023-02-10 00:05:28 +01:00
|
|
|
override fun removeProfilePicture(groupID: String) {
|
|
|
|
DatabaseComponent.get(context).groupDatabase().removeProfilePicture(groupID)
|
|
|
|
}
|
|
|
|
|
2023-01-20 07:42:46 +01:00
|
|
|
override fun hasDownloadedProfilePicture(groupID: String): Boolean {
|
|
|
|
return DatabaseComponent.get(context).groupDatabase().hasDownloadedProfilePicture(groupID)
|
|
|
|
}
|
|
|
|
|
2021-01-13 07:11:30 +01:00
|
|
|
override fun getReceivedMessageTimestamps(): Set<Long> {
|
2021-02-16 05:24:21 +01:00
|
|
|
return SessionMetaProtocol.getTimestamps()
|
2021-01-13 07:11:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
override fun addReceivedMessageTimestamp(timestamp: Long) {
|
2021-02-16 05:24:21 +01:00
|
|
|
SessionMetaProtocol.addTimestamp(timestamp)
|
2021-01-13 07:11:30 +01:00
|
|
|
}
|
|
|
|
|
2021-05-06 05:28:58 +02:00
|
|
|
override fun removeReceivedMessageTimestamps(timestamps: Set<Long>) {
|
|
|
|
SessionMetaProtocol.removeTimestamps(timestamps)
|
|
|
|
}
|
2021-02-11 06:09:59 +01:00
|
|
|
|
2021-01-20 06:29:52 +01:00
|
|
|
override fun getMessageIdInDatabase(timestamp: Long, author: String): Long? {
|
2021-10-04 09:51:19 +02:00
|
|
|
val database = DatabaseComponent.get(context).mmsSmsDatabase()
|
2022-08-10 10:17:48 +02:00
|
|
|
val address = fromSerialized(author)
|
2021-01-20 06:29:52 +01:00
|
|
|
return database.getMessageFor(timestamp, address)?.getId()
|
2021-01-13 07:11:30 +01:00
|
|
|
}
|
|
|
|
|
2021-07-23 08:04:18 +02:00
|
|
|
override fun updateSentTimestamp(
|
|
|
|
messageID: Long,
|
|
|
|
isMms: Boolean,
|
|
|
|
openGroupSentTimestamp: Long,
|
|
|
|
threadId: Long
|
|
|
|
) {
|
|
|
|
if (isMms) {
|
2021-10-04 09:51:19 +02:00
|
|
|
val mmsDb = DatabaseComponent.get(context).mmsDatabase()
|
2021-07-23 08:04:18 +02:00
|
|
|
mmsDb.updateSentTimestamp(messageID, openGroupSentTimestamp, threadId)
|
|
|
|
} else {
|
2021-10-04 09:51:19 +02:00
|
|
|
val smsDb = DatabaseComponent.get(context).smsDatabase()
|
2021-07-23 08:04:18 +02:00
|
|
|
smsDb.updateSentTimestamp(messageID, openGroupSentTimestamp, threadId)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-02 02:24:09 +01:00
|
|
|
override fun markAsSent(timestamp: Long, author: String) {
|
2021-10-04 09:51:19 +02:00
|
|
|
val database = DatabaseComponent.get(context).mmsSmsDatabase()
|
2021-03-02 02:24:09 +01:00
|
|
|
val messageRecord = database.getMessageFor(timestamp, author) ?: return
|
2021-01-20 06:29:52 +01:00
|
|
|
if (messageRecord.isMms) {
|
2021-10-04 09:51:19 +02:00
|
|
|
val mmsDatabase = DatabaseComponent.get(context).mmsDatabase()
|
2021-01-20 06:29:52 +01:00
|
|
|
mmsDatabase.markAsSent(messageRecord.getId(), true)
|
|
|
|
} else {
|
2021-10-04 09:51:19 +02:00
|
|
|
val smsDatabase = DatabaseComponent.get(context).smsDatabase()
|
2021-01-20 06:29:52 +01:00
|
|
|
smsDatabase.markAsSent(messageRecord.getId(), true)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-04 07:20:51 +02:00
|
|
|
override fun markAsSyncing(timestamp: Long, author: String) {
|
|
|
|
DatabaseComponent.get(context).mmsSmsDatabase()
|
|
|
|
.getMessageFor(timestamp, author)
|
|
|
|
?.run { getMmsDatabaseElseSms(isMms).markAsSyncing(id) }
|
|
|
|
}
|
|
|
|
|
|
|
|
private fun getMmsDatabaseElseSms(isMms: Boolean) =
|
|
|
|
if (isMms) DatabaseComponent.get(context).mmsDatabase()
|
|
|
|
else DatabaseComponent.get(context).smsDatabase()
|
|
|
|
|
|
|
|
override fun markAsResyncing(timestamp: Long, author: String) {
|
|
|
|
DatabaseComponent.get(context).mmsSmsDatabase()
|
|
|
|
.getMessageFor(timestamp, author)
|
|
|
|
?.run { getMmsDatabaseElseSms(isMms).markAsResyncing(id) }
|
|
|
|
}
|
|
|
|
|
2021-07-01 03:06:11 +02:00
|
|
|
override fun markAsSending(timestamp: Long, author: String) {
|
2021-10-04 09:51:19 +02:00
|
|
|
val database = DatabaseComponent.get(context).mmsSmsDatabase()
|
2021-07-01 03:06:11 +02:00
|
|
|
val messageRecord = database.getMessageFor(timestamp, author) ?: return
|
|
|
|
if (messageRecord.isMms) {
|
2021-10-04 09:51:19 +02:00
|
|
|
val mmsDatabase = DatabaseComponent.get(context).mmsDatabase()
|
2021-07-01 03:06:11 +02:00
|
|
|
mmsDatabase.markAsSending(messageRecord.getId())
|
|
|
|
} else {
|
2021-10-04 09:51:19 +02:00
|
|
|
val smsDatabase = DatabaseComponent.get(context).smsDatabase()
|
2021-07-01 03:06:11 +02:00
|
|
|
smsDatabase.markAsSending(messageRecord.getId())
|
|
|
|
messageRecord.isPending
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-02 02:24:09 +01:00
|
|
|
override fun markUnidentified(timestamp: Long, author: String) {
|
2021-10-04 09:51:19 +02:00
|
|
|
val database = DatabaseComponent.get(context).mmsSmsDatabase()
|
2021-03-02 02:24:09 +01:00
|
|
|
val messageRecord = database.getMessageFor(timestamp, author) ?: return
|
2021-01-20 06:29:52 +01:00
|
|
|
if (messageRecord.isMms) {
|
2021-10-04 09:51:19 +02:00
|
|
|
val mmsDatabase = DatabaseComponent.get(context).mmsDatabase()
|
2021-01-20 06:29:52 +01:00
|
|
|
mmsDatabase.markUnidentified(messageRecord.getId(), true)
|
|
|
|
} else {
|
2021-10-04 09:51:19 +02:00
|
|
|
val smsDatabase = DatabaseComponent.get(context).smsDatabase()
|
2021-01-20 06:29:52 +01:00
|
|
|
smsDatabase.markUnidentified(messageRecord.getId(), true)
|
|
|
|
}
|
2021-01-13 07:11:30 +01:00
|
|
|
}
|
|
|
|
|
2023-05-04 07:20:51 +02:00
|
|
|
override fun markAsSentFailed(timestamp: Long, author: String, error: Exception) {
|
2021-10-04 09:51:19 +02:00
|
|
|
val database = DatabaseComponent.get(context).mmsSmsDatabase()
|
2021-03-02 04:13:12 +01:00
|
|
|
val messageRecord = database.getMessageFor(timestamp, author) ?: return
|
2021-01-20 06:37:02 +01:00
|
|
|
if (messageRecord.isMms) {
|
2021-10-04 09:51:19 +02:00
|
|
|
val mmsDatabase = DatabaseComponent.get(context).mmsDatabase()
|
2021-03-02 04:13:12 +01:00
|
|
|
mmsDatabase.markAsSentFailed(messageRecord.getId())
|
2021-01-20 06:37:02 +01:00
|
|
|
} else {
|
2021-10-04 09:51:19 +02:00
|
|
|
val smsDatabase = DatabaseComponent.get(context).smsDatabase()
|
2021-03-02 04:13:12 +01:00
|
|
|
smsDatabase.markAsSentFailed(messageRecord.getId())
|
2021-01-20 06:37:02 +01:00
|
|
|
}
|
2021-03-16 06:31:52 +01:00
|
|
|
if (error.localizedMessage != null) {
|
2021-07-13 01:58:22 +02:00
|
|
|
val message: String
|
|
|
|
if (error is OnionRequestAPI.HTTPRequestFailedAtDestinationException && error.statusCode == 429) {
|
2021-07-14 02:59:14 +02:00
|
|
|
message = "429: Rate limited."
|
2021-07-13 01:58:22 +02:00
|
|
|
} else {
|
|
|
|
message = error.localizedMessage!!
|
|
|
|
}
|
2021-10-04 09:51:19 +02:00
|
|
|
DatabaseComponent.get(context).lokiMessageDatabase().setErrorMessage(messageRecord.getId(), message)
|
2021-03-16 06:31:52 +01:00
|
|
|
} else {
|
2021-10-04 09:51:19 +02:00
|
|
|
DatabaseComponent.get(context).lokiMessageDatabase().setErrorMessage(messageRecord.getId(), error.javaClass.simpleName)
|
2021-03-16 06:31:52 +01:00
|
|
|
}
|
2021-01-13 07:11:30 +01:00
|
|
|
}
|
|
|
|
|
2023-05-04 07:20:51 +02:00
|
|
|
override fun markAsSyncFailed(timestamp: Long, author: String, error: Exception) {
|
|
|
|
val database = DatabaseComponent.get(context).mmsSmsDatabase()
|
|
|
|
val messageRecord = database.getMessageFor(timestamp, author) ?: return
|
|
|
|
|
|
|
|
database.getMessageFor(timestamp, author)
|
|
|
|
?.run { getMmsDatabaseElseSms(isMms).markAsSyncFailed(id) }
|
|
|
|
|
|
|
|
if (error.localizedMessage != null) {
|
|
|
|
val message: String
|
|
|
|
if (error is OnionRequestAPI.HTTPRequestFailedAtDestinationException && error.statusCode == 429) {
|
|
|
|
message = "429: Rate limited."
|
|
|
|
} else {
|
|
|
|
message = error.localizedMessage!!
|
|
|
|
}
|
|
|
|
DatabaseComponent.get(context).lokiMessageDatabase().setErrorMessage(messageRecord.getId(), message)
|
|
|
|
} else {
|
|
|
|
DatabaseComponent.get(context).lokiMessageDatabase().setErrorMessage(messageRecord.getId(), error.javaClass.simpleName)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-19 01:29:05 +01:00
|
|
|
override fun clearErrorMessage(messageID: Long) {
|
|
|
|
val db = DatabaseComponent.get(context).lokiMessageDatabase()
|
|
|
|
db.clearErrorMessage(messageID)
|
|
|
|
}
|
|
|
|
|
2021-08-10 08:42:15 +02:00
|
|
|
override fun setMessageServerHash(messageID: Long, serverHash: String) {
|
2021-10-04 09:51:19 +02:00
|
|
|
DatabaseComponent.get(context).lokiMessageDatabase().setMessageServerHash(messageID, serverHash)
|
2021-08-10 08:42:15 +02:00
|
|
|
}
|
|
|
|
|
2021-01-13 07:11:30 +01:00
|
|
|
override fun getGroup(groupID: String): GroupRecord? {
|
2021-10-04 09:51:19 +02:00
|
|
|
val group = DatabaseComponent.get(context).groupDatabase().getGroup(groupID)
|
2021-01-13 07:11:30 +01:00
|
|
|
return if (group.isPresent) { group.get() } else null
|
|
|
|
}
|
|
|
|
|
2021-02-16 01:14:27 +01:00
|
|
|
override fun createGroup(groupId: String, title: String?, members: List<Address>, avatar: SignalServiceAttachmentPointer?, relay: String?, admins: List<Address>, formationTimestamp: Long) {
|
2021-10-04 09:51:19 +02:00
|
|
|
DatabaseComponent.get(context).groupDatabase().create(groupId, title, members, avatar, relay, admins, formationTimestamp)
|
2021-01-13 07:11:30 +01:00
|
|
|
}
|
|
|
|
|
2021-03-23 00:00:51 +01:00
|
|
|
override fun isGroupActive(groupPublicKey: String): Boolean {
|
2021-10-04 09:51:19 +02:00
|
|
|
return DatabaseComponent.get(context).groupDatabase().getGroup(GroupUtil.doubleEncodeGroupID(groupPublicKey)).orNull()?.isActive == true
|
2021-03-23 00:00:51 +01:00
|
|
|
}
|
|
|
|
|
2021-01-13 07:11:30 +01:00
|
|
|
override fun setActive(groupID: String, value: Boolean) {
|
2021-10-04 09:51:19 +02:00
|
|
|
DatabaseComponent.get(context).groupDatabase().setActive(groupID, value)
|
2021-01-13 07:11:30 +01:00
|
|
|
}
|
|
|
|
|
2021-05-21 07:02:34 +02:00
|
|
|
override fun getZombieMembers(groupID: String): Set<String> {
|
2021-10-04 09:51:19 +02:00
|
|
|
return DatabaseComponent.get(context).groupDatabase().getGroupZombieMembers(groupID).map { it.address.serialize() }.toHashSet()
|
2021-04-23 06:07:10 +02:00
|
|
|
}
|
|
|
|
|
2021-01-13 07:11:30 +01:00
|
|
|
override fun removeMember(groupID: String, member: Address) {
|
2021-10-04 09:51:19 +02:00
|
|
|
DatabaseComponent.get(context).groupDatabase().removeMember(groupID, member)
|
2021-01-13 07:11:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
override fun updateMembers(groupID: String, members: List<Address>) {
|
2021-10-04 09:51:19 +02:00
|
|
|
DatabaseComponent.get(context).groupDatabase().updateMembers(groupID, members)
|
2021-01-13 07:11:30 +01:00
|
|
|
}
|
|
|
|
|
2021-05-21 07:02:34 +02:00
|
|
|
override fun setZombieMembers(groupID: String, members: List<Address>) {
|
2021-10-04 09:51:19 +02:00
|
|
|
DatabaseComponent.get(context).groupDatabase().updateZombieMembers(groupID, members)
|
2021-04-23 06:07:10 +02:00
|
|
|
}
|
|
|
|
|
2021-04-14 08:37:04 +02:00
|
|
|
override fun insertIncomingInfoMessage(context: Context, senderPublicKey: String, groupID: String, type: SignalServiceGroup.Type, name: String, members: Collection<String>, admins: Collection<String>, sentTimestamp: Long) {
|
|
|
|
val group = SignalServiceGroup(type, GroupUtil.getDecodedGroupIDAsData(groupID), SignalServiceGroup.GroupType.SIGNAL, name, members.toList(), null, admins.toList())
|
2023-01-17 06:30:05 +01:00
|
|
|
val m = IncomingTextMessage(fromSerialized(senderPublicKey), 1, sentTimestamp, "", Optional.of(group), 0, true, false)
|
2021-05-12 00:40:10 +02:00
|
|
|
val updateData = UpdateMessageData.buildGroupUpdate(type, name, members)?.toJSON()
|
2021-04-15 06:41:29 +02:00
|
|
|
val infoMessage = IncomingGroupMessage(m, groupID, updateData, true)
|
2021-10-04 09:51:19 +02:00
|
|
|
val smsDB = DatabaseComponent.get(context).smsDatabase()
|
Performance improvements and bug fixes (#869)
* refactor: fail on testSnode instead of recursively using up snode list. add call timeout on http client
* refactor: refactoring batch message receives and pollers
* refactor: reduce thread utils pool count to a 2 thread fixed pool. Do a check against pubkey instead of room names for oxenHostedOpenGroup
* refactor: caching lib with potential loader fixes and no-cache for giphy
* refactor: remove store and instead use ConcurrentHashMap with a backing update coroutine
* refactor: queue trim thread jobs instead of add every message processed
* fix: wrapping auth token and initial sync for open groups in a threadutils queued runnable, getting initial sync times down
* fix: fixing the user contacts cache in ConversationAdapter.kt
* refactor: improve polling and initial sync, move group joins from config messages into a background job fetching image.
* refactor: improving the job queuing for open groups, replacing placeholder avatar generation with a custom glide loader and archiving initial sync of open groups
* feat: add OpenGroupDeleteJob.kt
* feat: add open group delete job to process deletions after batch adding
* feat: add vacuum and fix job queue re-adding jobs forever, only try to set message hash values in DB if they have changed
* refactor: remove redundant inflation for profile image views throughout app
* refactor(wip): reducing layout inflation and starting to refactor the open group deletion issues taking a long time
* refactor(wip): refactoring group deletion to not iterate through and delete messages individually
* refactor(wip): refactoring group deletion to not iterate through and delete messages individually
* fix: group deletion optimisation
* build: bump build number
* build: bump build number and fix batch message receive retry logic
* fix: clear out open group deletes
* fix: update visible ConversationAdapter.kt binding for initial contact fetching and better traces for debugging background jobs
* fix: add in check for / force sync latest encryption key pair from linked devices if we already have that closed group
* Rename .java to .kt
* refactor: change MmsDatabase to kotlin to make list operations easier
* fix: nullable type
* fix: compilation issues and constants in .kt instead of .java
* fix: bug fix expiration timer on closed group recipient
* feat: use the job queue properly across executors
* feat: start on open group dispatcher-specific logic, probably a queue factory based on openGroupId if that is the same across new message and deletion jobs to ensure consistent entry and removal
* refactor: removing redundant code and fixing jobqueue per opengroup
* fix: allow attachments in note to self
* fix: make the minWidth in quote view bind max of text / title and body, wrapped ?
* fix: fixing up layouts and code view layouts
* fix: remove TODO, remove timestamp binding
* feat: fix view logic, avatars and padding, downloading attachments lazily (on bind), fixing potential crash, add WindowDebouncer.kt
* fix: NPE on viewModel recipient from removed thread while tearing down the Recipient observer in ConversationActivityV2.kt
* refactor: replace conversation notification debouncer handler with handlerthread, same as conversation list debouncer
* refactor: UI for groups and poller improvements
* fix: revert some changes in poller
* feat: add header back in for message requests
* refactor: remove Trace calls, add more conditions to the HomeDiffUtil for updating more efficiently
* feat: try update the home adapter if we get a profile picture modified event
* feat: bump build numbers
* fix: try to start with list in homeViewModel if we don't have already, render quotes to be width of attachment slide view instead of fixed
* fix: set channel to be conflated instead of no buffer
* fix: set unreads based off last local user message vs incrementing unreads to be all amount
* feat: add profile update flag, update build number
* fix: link preview thumbnails download on bind
* fix: centercrop placeholder in glide request
* feat: recycle the contact selection list and profile image in unbind
* fix: try to prevent user KP crash at weird times
* fix: remove additional log, improve attachment download success rate, fix share logs dialog issue
2022-06-08 09:12:34 +02:00
|
|
|
smsDB.insertMessageInbox(infoMessage, true, true)
|
2021-01-13 07:11:30 +01:00
|
|
|
}
|
|
|
|
|
2021-04-14 08:37:04 +02:00
|
|
|
override fun insertOutgoingInfoMessage(context: Context, groupID: String, type: SignalServiceGroup.Type, name: String, members: Collection<String>, admins: Collection<String>, threadID: Long, sentTimestamp: Long) {
|
2021-03-11 05:31:14 +01:00
|
|
|
val userPublicKey = getUserPublicKey()
|
2022-08-10 10:17:48 +02:00
|
|
|
val recipient = Recipient.from(context, fromSerialized(groupID), false)
|
2021-04-14 08:37:04 +02:00
|
|
|
|
2021-05-12 00:40:10 +02:00
|
|
|
val updateData = UpdateMessageData.buildGroupUpdate(type, name, members)?.toJSON() ?: ""
|
2021-04-15 06:41:29 +02:00
|
|
|
val infoMessage = OutgoingGroupMediaMessage(recipient, updateData, groupID, null, sentTimestamp, 0, true, null, listOf(), listOf())
|
2021-10-04 09:51:19 +02:00
|
|
|
val mmsDB = DatabaseComponent.get(context).mmsDatabase()
|
|
|
|
val mmsSmsDB = DatabaseComponent.get(context).mmsSmsDatabase()
|
2021-03-16 04:56:47 +01:00
|
|
|
if (mmsSmsDB.getMessageFor(sentTimestamp, userPublicKey) != null) return
|
Performance improvements and bug fixes (#869)
* refactor: fail on testSnode instead of recursively using up snode list. add call timeout on http client
* refactor: refactoring batch message receives and pollers
* refactor: reduce thread utils pool count to a 2 thread fixed pool. Do a check against pubkey instead of room names for oxenHostedOpenGroup
* refactor: caching lib with potential loader fixes and no-cache for giphy
* refactor: remove store and instead use ConcurrentHashMap with a backing update coroutine
* refactor: queue trim thread jobs instead of add every message processed
* fix: wrapping auth token and initial sync for open groups in a threadutils queued runnable, getting initial sync times down
* fix: fixing the user contacts cache in ConversationAdapter.kt
* refactor: improve polling and initial sync, move group joins from config messages into a background job fetching image.
* refactor: improving the job queuing for open groups, replacing placeholder avatar generation with a custom glide loader and archiving initial sync of open groups
* feat: add OpenGroupDeleteJob.kt
* feat: add open group delete job to process deletions after batch adding
* feat: add vacuum and fix job queue re-adding jobs forever, only try to set message hash values in DB if they have changed
* refactor: remove redundant inflation for profile image views throughout app
* refactor(wip): reducing layout inflation and starting to refactor the open group deletion issues taking a long time
* refactor(wip): refactoring group deletion to not iterate through and delete messages individually
* refactor(wip): refactoring group deletion to not iterate through and delete messages individually
* fix: group deletion optimisation
* build: bump build number
* build: bump build number and fix batch message receive retry logic
* fix: clear out open group deletes
* fix: update visible ConversationAdapter.kt binding for initial contact fetching and better traces for debugging background jobs
* fix: add in check for / force sync latest encryption key pair from linked devices if we already have that closed group
* Rename .java to .kt
* refactor: change MmsDatabase to kotlin to make list operations easier
* fix: nullable type
* fix: compilation issues and constants in .kt instead of .java
* fix: bug fix expiration timer on closed group recipient
* feat: use the job queue properly across executors
* feat: start on open group dispatcher-specific logic, probably a queue factory based on openGroupId if that is the same across new message and deletion jobs to ensure consistent entry and removal
* refactor: removing redundant code and fixing jobqueue per opengroup
* fix: allow attachments in note to self
* fix: make the minWidth in quote view bind max of text / title and body, wrapped ?
* fix: fixing up layouts and code view layouts
* fix: remove TODO, remove timestamp binding
* feat: fix view logic, avatars and padding, downloading attachments lazily (on bind), fixing potential crash, add WindowDebouncer.kt
* fix: NPE on viewModel recipient from removed thread while tearing down the Recipient observer in ConversationActivityV2.kt
* refactor: replace conversation notification debouncer handler with handlerthread, same as conversation list debouncer
* refactor: UI for groups and poller improvements
* fix: revert some changes in poller
* feat: add header back in for message requests
* refactor: remove Trace calls, add more conditions to the HomeDiffUtil for updating more efficiently
* feat: try update the home adapter if we get a profile picture modified event
* feat: bump build numbers
* fix: try to start with list in homeViewModel if we don't have already, render quotes to be width of attachment slide view instead of fixed
* fix: set channel to be conflated instead of no buffer
* fix: set unreads based off last local user message vs incrementing unreads to be all amount
* feat: add profile update flag, update build number
* fix: link preview thumbnails download on bind
* fix: centercrop placeholder in glide request
* feat: recycle the contact selection list and profile image in unbind
* fix: try to prevent user KP crash at weird times
* fix: remove additional log, improve attachment download success rate, fix share logs dialog issue
2022-06-08 09:12:34 +02:00
|
|
|
val infoMessageID = mmsDB.insertMessageOutbox(infoMessage, threadID, false, null, runThreadUpdate = true)
|
2021-01-13 07:11:30 +01:00
|
|
|
mmsDB.markAsSent(infoMessageID, true)
|
|
|
|
}
|
|
|
|
|
2021-01-14 01:42:26 +01:00
|
|
|
override fun isClosedGroup(publicKey: String): Boolean {
|
2021-10-04 09:51:19 +02:00
|
|
|
val isClosedGroup = DatabaseComponent.get(context).lokiAPIDatabase().isClosedGroup(publicKey)
|
2022-08-10 10:17:48 +02:00
|
|
|
val address = fromSerialized(publicKey)
|
2021-02-18 04:14:05 +01:00
|
|
|
return address.isClosedGroup || isClosedGroup
|
2021-01-14 01:42:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
override fun getClosedGroupEncryptionKeyPairs(groupPublicKey: String): MutableList<ECKeyPair> {
|
2021-10-04 09:51:19 +02:00
|
|
|
return DatabaseComponent.get(context).lokiAPIDatabase().getClosedGroupEncryptionKeyPairs(groupPublicKey).toMutableList()
|
2021-01-14 01:42:26 +01:00
|
|
|
}
|
|
|
|
|
2021-01-20 01:18:00 +01:00
|
|
|
override fun getLatestClosedGroupEncryptionKeyPair(groupPublicKey: String): ECKeyPair? {
|
2021-10-04 09:51:19 +02:00
|
|
|
return DatabaseComponent.get(context).lokiAPIDatabase().getLatestClosedGroupEncryptionKeyPair(groupPublicKey)
|
2021-01-14 03:20:18 +01:00
|
|
|
}
|
|
|
|
|
2021-02-08 06:44:26 +01:00
|
|
|
override fun getAllClosedGroupPublicKeys(): Set<String> {
|
2021-10-04 09:51:19 +02:00
|
|
|
return DatabaseComponent.get(context).lokiAPIDatabase().getAllClosedGroupPublicKeys()
|
2021-02-08 06:44:26 +01:00
|
|
|
}
|
|
|
|
|
2021-03-23 00:00:51 +01:00
|
|
|
override fun getAllActiveClosedGroupPublicKeys(): Set<String> {
|
2021-10-04 09:51:19 +02:00
|
|
|
return DatabaseComponent.get(context).lokiAPIDatabase().getAllClosedGroupPublicKeys().filter {
|
2021-03-23 00:00:51 +01:00
|
|
|
getGroup(GroupUtil.doubleEncodeGroupID(it))?.isActive == true
|
|
|
|
}.toSet()
|
|
|
|
}
|
|
|
|
|
2021-02-09 01:45:38 +01:00
|
|
|
override fun addClosedGroupPublicKey(groupPublicKey: String) {
|
2021-10-04 09:51:19 +02:00
|
|
|
DatabaseComponent.get(context).lokiAPIDatabase().addClosedGroupPublicKey(groupPublicKey)
|
2021-02-09 01:45:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
override fun removeClosedGroupPublicKey(groupPublicKey: String) {
|
2021-10-04 09:51:19 +02:00
|
|
|
DatabaseComponent.get(context).lokiAPIDatabase().removeClosedGroupPublicKey(groupPublicKey)
|
2021-02-09 01:45:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
override fun addClosedGroupEncryptionKeyPair(encryptionKeyPair: ECKeyPair, groupPublicKey: String) {
|
2021-10-04 09:51:19 +02:00
|
|
|
DatabaseComponent.get(context).lokiAPIDatabase().addClosedGroupEncryptionKeyPair(encryptionKeyPair, groupPublicKey)
|
2021-02-09 01:45:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
override fun removeAllClosedGroupEncryptionKeyPairs(groupPublicKey: String) {
|
2021-10-04 09:51:19 +02:00
|
|
|
DatabaseComponent.get(context).lokiAPIDatabase().removeAllClosedGroupEncryptionKeyPairs(groupPublicKey)
|
2021-02-09 01:45:38 +01:00
|
|
|
}
|
|
|
|
|
2021-06-10 09:34:48 +02:00
|
|
|
override fun updateFormationTimestamp(groupID: String, formationTimestamp: Long) {
|
2021-10-04 09:51:19 +02:00
|
|
|
DatabaseComponent.get(context).groupDatabase()
|
2021-06-15 03:21:55 +02:00
|
|
|
.updateFormationTimestamp(groupID, formationTimestamp)
|
|
|
|
}
|
|
|
|
|
2021-12-15 07:11:55 +01:00
|
|
|
override fun updateTimestampUpdated(groupID: String, updatedTimestamp: Long) {
|
|
|
|
DatabaseComponent.get(context).groupDatabase()
|
|
|
|
.updateTimestampUpdated(groupID, updatedTimestamp)
|
|
|
|
}
|
|
|
|
|
2021-06-09 06:31:05 +02:00
|
|
|
override fun setExpirationTimer(groupID: String, duration: Int) {
|
|
|
|
val recipient = Recipient.from(context, fromSerialized(groupID), false)
|
2021-10-04 09:51:19 +02:00
|
|
|
DatabaseComponent.get(context).recipientDatabase().setExpireMessages(recipient, duration);
|
2021-06-10 09:34:48 +02:00
|
|
|
}
|
|
|
|
|
2022-08-10 10:17:48 +02:00
|
|
|
override fun setServerCapabilities(server: String, capabilities: List<String>) {
|
|
|
|
return DatabaseComponent.get(context).lokiAPIDatabase().setServerCapabilities(server, capabilities)
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun getServerCapabilities(server: String): List<String> {
|
|
|
|
return DatabaseComponent.get(context).lokiAPIDatabase().getServerCapabilities(server)
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun getAllOpenGroups(): Map<Long, OpenGroup> {
|
|
|
|
return DatabaseComponent.get(context).lokiThreadDatabase().getAllOpenGroups()
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun updateOpenGroup(openGroup: OpenGroup) {
|
|
|
|
OpenGroupManager.updateOpenGroup(openGroup, context)
|
2021-04-13 09:17:16 +02:00
|
|
|
}
|
|
|
|
|
2021-02-05 06:35:15 +01:00
|
|
|
override fun getAllGroups(): List<GroupRecord> {
|
2021-10-04 09:51:19 +02:00
|
|
|
return DatabaseComponent.get(context).groupDatabase().allGroups
|
2021-02-05 06:35:15 +01:00
|
|
|
}
|
|
|
|
|
2023-01-13 06:16:52 +01:00
|
|
|
override fun addOpenGroup(urlAsString: String): OpenGroupApi.RoomInfo? {
|
|
|
|
return OpenGroupManager.addOpenGroup(urlAsString, context)
|
2021-05-21 07:02:34 +02:00
|
|
|
}
|
|
|
|
|
2022-09-04 13:03:32 +02:00
|
|
|
override fun onOpenGroupAdded(server: String) {
|
|
|
|
OpenGroupManager.restartPollerForServer(server.removeSuffix("/"))
|
Performance improvements and bug fixes (#869)
* refactor: fail on testSnode instead of recursively using up snode list. add call timeout on http client
* refactor: refactoring batch message receives and pollers
* refactor: reduce thread utils pool count to a 2 thread fixed pool. Do a check against pubkey instead of room names for oxenHostedOpenGroup
* refactor: caching lib with potential loader fixes and no-cache for giphy
* refactor: remove store and instead use ConcurrentHashMap with a backing update coroutine
* refactor: queue trim thread jobs instead of add every message processed
* fix: wrapping auth token and initial sync for open groups in a threadutils queued runnable, getting initial sync times down
* fix: fixing the user contacts cache in ConversationAdapter.kt
* refactor: improve polling and initial sync, move group joins from config messages into a background job fetching image.
* refactor: improving the job queuing for open groups, replacing placeholder avatar generation with a custom glide loader and archiving initial sync of open groups
* feat: add OpenGroupDeleteJob.kt
* feat: add open group delete job to process deletions after batch adding
* feat: add vacuum and fix job queue re-adding jobs forever, only try to set message hash values in DB if they have changed
* refactor: remove redundant inflation for profile image views throughout app
* refactor(wip): reducing layout inflation and starting to refactor the open group deletion issues taking a long time
* refactor(wip): refactoring group deletion to not iterate through and delete messages individually
* refactor(wip): refactoring group deletion to not iterate through and delete messages individually
* fix: group deletion optimisation
* build: bump build number
* build: bump build number and fix batch message receive retry logic
* fix: clear out open group deletes
* fix: update visible ConversationAdapter.kt binding for initial contact fetching and better traces for debugging background jobs
* fix: add in check for / force sync latest encryption key pair from linked devices if we already have that closed group
* Rename .java to .kt
* refactor: change MmsDatabase to kotlin to make list operations easier
* fix: nullable type
* fix: compilation issues and constants in .kt instead of .java
* fix: bug fix expiration timer on closed group recipient
* feat: use the job queue properly across executors
* feat: start on open group dispatcher-specific logic, probably a queue factory based on openGroupId if that is the same across new message and deletion jobs to ensure consistent entry and removal
* refactor: removing redundant code and fixing jobqueue per opengroup
* fix: allow attachments in note to self
* fix: make the minWidth in quote view bind max of text / title and body, wrapped ?
* fix: fixing up layouts and code view layouts
* fix: remove TODO, remove timestamp binding
* feat: fix view logic, avatars and padding, downloading attachments lazily (on bind), fixing potential crash, add WindowDebouncer.kt
* fix: NPE on viewModel recipient from removed thread while tearing down the Recipient observer in ConversationActivityV2.kt
* refactor: replace conversation notification debouncer handler with handlerthread, same as conversation list debouncer
* refactor: UI for groups and poller improvements
* fix: revert some changes in poller
* feat: add header back in for message requests
* refactor: remove Trace calls, add more conditions to the HomeDiffUtil for updating more efficiently
* feat: try update the home adapter if we get a profile picture modified event
* feat: bump build numbers
* fix: try to start with list in homeViewModel if we don't have already, render quotes to be width of attachment slide view instead of fixed
* fix: set channel to be conflated instead of no buffer
* fix: set unreads based off last local user message vs incrementing unreads to be all amount
* feat: add profile update flag, update build number
* fix: link preview thumbnails download on bind
* fix: centercrop placeholder in glide request
* feat: recycle the contact selection list and profile image in unbind
* fix: try to prevent user KP crash at weird times
* fix: remove additional log, improve attachment download success rate, fix share logs dialog issue
2022-06-08 09:12:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
override fun hasBackgroundGroupAddJob(groupJoinUrl: String): Boolean {
|
|
|
|
val jobDb = DatabaseComponent.get(context).sessionJobDatabase()
|
|
|
|
return jobDb.hasBackgroundGroupAddJob(groupJoinUrl)
|
|
|
|
}
|
|
|
|
|
2021-01-13 07:11:30 +01:00
|
|
|
override fun setProfileSharing(address: Address, value: Boolean) {
|
|
|
|
val recipient = Recipient.from(context, address, false)
|
2021-10-04 09:51:19 +02:00
|
|
|
DatabaseComponent.get(context).recipientDatabase().setProfileSharing(recipient, value)
|
2021-01-13 07:11:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
override fun getOrCreateThreadIdFor(address: Address): Long {
|
|
|
|
val recipient = Recipient.from(context, address, false)
|
2021-10-04 09:51:19 +02:00
|
|
|
return DatabaseComponent.get(context).threadDatabase().getOrCreateThreadIdFor(recipient)
|
2021-01-13 07:11:30 +01:00
|
|
|
}
|
|
|
|
|
2021-01-20 00:04:14 +01:00
|
|
|
override fun getOrCreateThreadIdFor(publicKey: String, groupPublicKey: String?, openGroupID: String?): Long {
|
2021-10-04 09:51:19 +02:00
|
|
|
val database = DatabaseComponent.get(context).threadDatabase()
|
2022-08-10 10:17:48 +02:00
|
|
|
return if (!openGroupID.isNullOrEmpty()) {
|
|
|
|
val recipient = Recipient.from(context, fromSerialized(GroupUtil.getEncodedOpenGroupID(openGroupID.toByteArray())), false)
|
|
|
|
database.getThreadIdIfExistsFor(recipient)
|
2021-01-19 07:06:02 +01:00
|
|
|
} else if (!groupPublicKey.isNullOrEmpty()) {
|
2022-08-10 10:17:48 +02:00
|
|
|
val recipient = Recipient.from(context, fromSerialized(GroupUtil.doubleEncodeGroupID(groupPublicKey)), false)
|
|
|
|
database.getOrCreateThreadIdFor(recipient)
|
2021-01-19 07:06:02 +01:00
|
|
|
} else {
|
2022-08-10 10:17:48 +02:00
|
|
|
val recipient = Recipient.from(context, fromSerialized(publicKey), false)
|
|
|
|
database.getOrCreateThreadIdFor(recipient)
|
2021-01-19 07:06:02 +01:00
|
|
|
}
|
2021-01-13 07:11:30 +01:00
|
|
|
}
|
|
|
|
|
2021-05-21 07:02:34 +02:00
|
|
|
override fun getThreadId(publicKeyOrOpenGroupID: String): Long? {
|
2022-08-10 10:17:48 +02:00
|
|
|
val address = fromSerialized(publicKeyOrOpenGroupID)
|
2021-05-21 07:02:34 +02:00
|
|
|
return getThreadId(address)
|
2021-01-13 07:11:30 +01:00
|
|
|
}
|
|
|
|
|
2021-05-21 07:02:34 +02:00
|
|
|
override fun getThreadId(address: Address): Long? {
|
|
|
|
val recipient = Recipient.from(context, address, false)
|
|
|
|
return getThreadId(recipient)
|
|
|
|
}
|
2021-05-21 03:09:03 +02:00
|
|
|
|
2021-05-21 07:02:34 +02:00
|
|
|
override fun getThreadId(recipient: Recipient): Long? {
|
2021-10-04 09:51:19 +02:00
|
|
|
val threadID = DatabaseComponent.get(context).threadDatabase().getThreadIdIfExistsFor(recipient)
|
2021-05-21 07:02:34 +02:00
|
|
|
return if (threadID < 0) null else threadID
|
2021-05-21 03:09:03 +02:00
|
|
|
}
|
|
|
|
|
2021-04-26 06:30:51 +02:00
|
|
|
override fun getThreadIdForMms(mmsId: Long): Long {
|
2021-10-04 09:51:19 +02:00
|
|
|
val mmsDb = DatabaseComponent.get(context).mmsDatabase()
|
2021-04-26 06:30:51 +02:00
|
|
|
val cursor = mmsDb.getMessage(mmsId)
|
|
|
|
val reader = mmsDb.readerFor(cursor)
|
2021-07-09 07:13:43 +02:00
|
|
|
val threadId = reader.next?.threadId
|
2021-04-28 06:46:50 +02:00
|
|
|
cursor.close()
|
2021-07-09 07:13:43 +02:00
|
|
|
return threadId ?: -1
|
2021-04-26 06:30:51 +02:00
|
|
|
}
|
|
|
|
|
2021-05-07 08:31:46 +02:00
|
|
|
override fun getContactWithSessionID(sessionID: String): Contact? {
|
2021-10-04 09:51:19 +02:00
|
|
|
return DatabaseComponent.get(context).sessionContactDatabase().getContactWithSessionID(sessionID)
|
2021-01-13 07:11:30 +01:00
|
|
|
}
|
|
|
|
|
2021-05-07 08:31:46 +02:00
|
|
|
override fun getAllContacts(): Set<Contact> {
|
2021-10-04 09:51:19 +02:00
|
|
|
return DatabaseComponent.get(context).sessionContactDatabase().getAllContacts()
|
2021-03-30 07:23:12 +02:00
|
|
|
}
|
|
|
|
|
2021-05-07 08:31:46 +02:00
|
|
|
override fun setContact(contact: Contact) {
|
2021-10-04 09:51:19 +02:00
|
|
|
DatabaseComponent.get(context).sessionContactDatabase().setContact(contact)
|
2021-01-13 07:11:30 +01:00
|
|
|
}
|
|
|
|
|
2021-07-09 07:13:43 +02:00
|
|
|
override fun getRecipientForThread(threadId: Long): Recipient? {
|
2021-10-04 09:51:19 +02:00
|
|
|
return DatabaseComponent.get(context).threadDatabase().getRecipientForThreadId(threadId)
|
2021-07-09 07:13:43 +02:00
|
|
|
}
|
|
|
|
|
2021-01-13 07:11:30 +01:00
|
|
|
override fun getRecipientSettings(address: Address): Recipient.RecipientSettings? {
|
2021-10-04 09:51:19 +02:00
|
|
|
val recipientSettings = DatabaseComponent.get(context).recipientDatabase().getRecipientSettings(address)
|
2021-01-13 07:11:30 +01:00
|
|
|
return if (recipientSettings.isPresent) { recipientSettings.get() } else null
|
|
|
|
}
|
|
|
|
|
2021-03-30 07:23:12 +02:00
|
|
|
override fun addContacts(contacts: List<ConfigurationMessage.Contact>) {
|
2021-10-04 09:51:19 +02:00
|
|
|
val recipientDatabase = DatabaseComponent.get(context).recipientDatabase()
|
|
|
|
val threadDatabase = DatabaseComponent.get(context).threadDatabase()
|
2022-08-10 10:17:48 +02:00
|
|
|
val mappingDb = DatabaseComponent.get(context).blindedIdMappingDatabase()
|
|
|
|
val moreContacts = contacts.filter { contact ->
|
|
|
|
val id = SessionId(contact.publicKey)
|
|
|
|
id.prefix != IdPrefix.BLINDED || mappingDb.getBlindedIdMapping(contact.publicKey).none { it.sessionId != null }
|
|
|
|
}
|
|
|
|
for (contact in moreContacts) {
|
|
|
|
val address = fromSerialized(contact.publicKey)
|
2021-03-30 07:23:12 +02:00
|
|
|
val recipient = Recipient.from(context, address, true)
|
|
|
|
if (!contact.profilePicture.isNullOrEmpty()) {
|
|
|
|
recipientDatabase.setProfileAvatar(recipient, contact.profilePicture)
|
|
|
|
}
|
|
|
|
if (contact.profileKey?.isNotEmpty() == true) {
|
|
|
|
recipientDatabase.setProfileKey(recipient, contact.profileKey)
|
|
|
|
}
|
|
|
|
if (contact.name.isNotEmpty()) {
|
|
|
|
recipientDatabase.setProfileName(recipient, contact.name)
|
|
|
|
}
|
|
|
|
recipientDatabase.setProfileSharing(recipient, true)
|
|
|
|
recipientDatabase.setRegistered(recipient, Recipient.RegisteredState.REGISTERED)
|
|
|
|
// create Thread if needed
|
2022-03-04 07:46:39 +01:00
|
|
|
val threadId = threadDatabase.getOrCreateThreadIdFor(recipient)
|
|
|
|
if (contact.didApproveMe == true) {
|
2022-03-09 23:54:18 +01:00
|
|
|
recipientDatabase.setApprovedMe(recipient, true)
|
2022-03-04 07:46:39 +01:00
|
|
|
}
|
|
|
|
if (contact.isApproved == true) {
|
|
|
|
recipientDatabase.setApproved(recipient, true)
|
|
|
|
threadDatabase.setHasSent(threadId, true)
|
|
|
|
}
|
|
|
|
if (contact.isBlocked == true) {
|
|
|
|
recipientDatabase.setBlocked(recipient, true)
|
|
|
|
threadDatabase.deleteConversation(threadId)
|
|
|
|
}
|
2021-03-30 07:23:12 +02:00
|
|
|
}
|
|
|
|
if (contacts.isNotEmpty()) {
|
2021-05-21 03:09:03 +02:00
|
|
|
threadDatabase.notifyConversationListListeners()
|
2021-03-30 07:23:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-21 03:09:03 +02:00
|
|
|
override fun getLastUpdated(threadID: Long): Long {
|
2021-10-04 09:51:19 +02:00
|
|
|
val threadDB = DatabaseComponent.get(context).threadDatabase()
|
2021-05-21 03:09:03 +02:00
|
|
|
return threadDB.getLastUpdated(threadID)
|
|
|
|
}
|
|
|
|
|
2021-05-26 07:22:19 +02:00
|
|
|
override fun trimThread(threadID: Long, threadLimit: Int) {
|
2021-10-04 09:51:19 +02:00
|
|
|
val threadDB = DatabaseComponent.get(context).threadDatabase()
|
2021-05-26 07:22:19 +02:00
|
|
|
threadDB.trimThread(threadID, threadLimit)
|
|
|
|
}
|
|
|
|
|
2022-09-13 07:01:15 +02:00
|
|
|
override fun trimThreadBefore(threadID: Long, timestamp: Long) {
|
|
|
|
val threadDB = DatabaseComponent.get(context).threadDatabase()
|
|
|
|
threadDB.trimThreadBefore(threadID, timestamp)
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun getMessageCount(threadID: Long): Long {
|
|
|
|
val mmsSmsDb = DatabaseComponent.get(context).mmsSmsDatabase()
|
|
|
|
return mmsSmsDb.getConversationCount(threadID)
|
|
|
|
}
|
|
|
|
|
2023-06-02 09:00:20 +02:00
|
|
|
override fun deleteConversation(threadId: Long) {
|
|
|
|
val threadDB = DatabaseComponent.get(context).threadDatabase()
|
|
|
|
threadDB.deleteConversation(threadId)
|
|
|
|
}
|
|
|
|
|
2022-09-13 07:01:15 +02:00
|
|
|
|
|
|
|
|
2021-01-13 07:11:30 +01:00
|
|
|
override fun getAttachmentDataUri(attachmentId: AttachmentId): Uri {
|
|
|
|
return PartAuthority.getAttachmentDataUri(attachmentId)
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun getAttachmentThumbnailUri(attachmentId: AttachmentId): Uri {
|
|
|
|
return PartAuthority.getAttachmentThumbnailUri(attachmentId)
|
|
|
|
}
|
2021-03-16 04:56:47 +01:00
|
|
|
|
2021-04-09 08:06:12 +02:00
|
|
|
override fun insertDataExtractionNotificationMessage(senderPublicKey: String, message: DataExtractionNotificationInfoMessage, sentTimestamp: Long) {
|
2021-10-04 09:51:19 +02:00
|
|
|
val database = DatabaseComponent.get(context).mmsDatabase()
|
2021-03-16 04:56:47 +01:00
|
|
|
val address = fromSerialized(senderPublicKey)
|
|
|
|
val recipient = Recipient.from(context, address, false)
|
|
|
|
|
|
|
|
if (recipient.isBlocked) return
|
|
|
|
|
2022-03-04 07:46:39 +01:00
|
|
|
val mediaMessage = IncomingMediaMessage(
|
|
|
|
address,
|
|
|
|
sentTimestamp,
|
|
|
|
-1,
|
|
|
|
0,
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
false,
|
2023-01-17 06:30:05 +01:00
|
|
|
false,
|
2022-03-04 07:46:39 +01:00
|
|
|
Optional.absent(),
|
|
|
|
Optional.absent(),
|
|
|
|
Optional.absent(),
|
|
|
|
Optional.absent(),
|
|
|
|
Optional.absent(),
|
|
|
|
Optional.absent(),
|
|
|
|
Optional.of(message)
|
|
|
|
)
|
|
|
|
|
Performance improvements and bug fixes (#869)
* refactor: fail on testSnode instead of recursively using up snode list. add call timeout on http client
* refactor: refactoring batch message receives and pollers
* refactor: reduce thread utils pool count to a 2 thread fixed pool. Do a check against pubkey instead of room names for oxenHostedOpenGroup
* refactor: caching lib with potential loader fixes and no-cache for giphy
* refactor: remove store and instead use ConcurrentHashMap with a backing update coroutine
* refactor: queue trim thread jobs instead of add every message processed
* fix: wrapping auth token and initial sync for open groups in a threadutils queued runnable, getting initial sync times down
* fix: fixing the user contacts cache in ConversationAdapter.kt
* refactor: improve polling and initial sync, move group joins from config messages into a background job fetching image.
* refactor: improving the job queuing for open groups, replacing placeholder avatar generation with a custom glide loader and archiving initial sync of open groups
* feat: add OpenGroupDeleteJob.kt
* feat: add open group delete job to process deletions after batch adding
* feat: add vacuum and fix job queue re-adding jobs forever, only try to set message hash values in DB if they have changed
* refactor: remove redundant inflation for profile image views throughout app
* refactor(wip): reducing layout inflation and starting to refactor the open group deletion issues taking a long time
* refactor(wip): refactoring group deletion to not iterate through and delete messages individually
* refactor(wip): refactoring group deletion to not iterate through and delete messages individually
* fix: group deletion optimisation
* build: bump build number
* build: bump build number and fix batch message receive retry logic
* fix: clear out open group deletes
* fix: update visible ConversationAdapter.kt binding for initial contact fetching and better traces for debugging background jobs
* fix: add in check for / force sync latest encryption key pair from linked devices if we already have that closed group
* Rename .java to .kt
* refactor: change MmsDatabase to kotlin to make list operations easier
* fix: nullable type
* fix: compilation issues and constants in .kt instead of .java
* fix: bug fix expiration timer on closed group recipient
* feat: use the job queue properly across executors
* feat: start on open group dispatcher-specific logic, probably a queue factory based on openGroupId if that is the same across new message and deletion jobs to ensure consistent entry and removal
* refactor: removing redundant code and fixing jobqueue per opengroup
* fix: allow attachments in note to self
* fix: make the minWidth in quote view bind max of text / title and body, wrapped ?
* fix: fixing up layouts and code view layouts
* fix: remove TODO, remove timestamp binding
* feat: fix view logic, avatars and padding, downloading attachments lazily (on bind), fixing potential crash, add WindowDebouncer.kt
* fix: NPE on viewModel recipient from removed thread while tearing down the Recipient observer in ConversationActivityV2.kt
* refactor: replace conversation notification debouncer handler with handlerthread, same as conversation list debouncer
* refactor: UI for groups and poller improvements
* fix: revert some changes in poller
* feat: add header back in for message requests
* refactor: remove Trace calls, add more conditions to the HomeDiffUtil for updating more efficiently
* feat: try update the home adapter if we get a profile picture modified event
* feat: bump build numbers
* fix: try to start with list in homeViewModel if we don't have already, render quotes to be width of attachment slide view instead of fixed
* fix: set channel to be conflated instead of no buffer
* fix: set unreads based off last local user message vs incrementing unreads to be all amount
* feat: add profile update flag, update build number
* fix: link preview thumbnails download on bind
* fix: centercrop placeholder in glide request
* feat: recycle the contact selection list and profile image in unbind
* fix: try to prevent user KP crash at weird times
* fix: remove additional log, improve attachment download success rate, fix share logs dialog issue
2022-06-08 09:12:34 +02:00
|
|
|
database.insertSecureDecryptedMessageInbox(mediaMessage, -1, runIncrement = true, runThreadUpdate = true)
|
2022-03-04 07:46:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
override fun insertMessageRequestResponse(response: MessageRequestResponse) {
|
|
|
|
val userPublicKey = getUserPublicKey()
|
|
|
|
val senderPublicKey = response.sender!!
|
|
|
|
val recipientPublicKey = response.recipient!!
|
|
|
|
if (userPublicKey == null || (userPublicKey != recipientPublicKey && userPublicKey != senderPublicKey)) return
|
|
|
|
val recipientDb = DatabaseComponent.get(context).recipientDatabase()
|
|
|
|
val threadDB = DatabaseComponent.get(context).threadDatabase()
|
|
|
|
if (userPublicKey == senderPublicKey) {
|
|
|
|
val requestRecipient = Recipient.from(context, fromSerialized(recipientPublicKey), false)
|
|
|
|
recipientDb.setApproved(requestRecipient, true)
|
|
|
|
val threadId = threadDB.getOrCreateThreadIdFor(requestRecipient)
|
|
|
|
threadDB.setHasSent(threadId, true)
|
|
|
|
} else {
|
|
|
|
val mmsDb = DatabaseComponent.get(context).mmsDatabase()
|
2022-08-10 10:17:48 +02:00
|
|
|
val smsDb = DatabaseComponent.get(context).smsDatabase()
|
|
|
|
val sender = Recipient.from(context, fromSerialized(senderPublicKey), false)
|
|
|
|
val threadId = threadDB.getOrCreateThreadIdFor(sender)
|
2022-10-05 01:05:26 +02:00
|
|
|
val profile = response.profile
|
|
|
|
if (profile != null) {
|
|
|
|
val profileManager = SSKEnvironment.shared.profileManager
|
|
|
|
val name = profile.displayName!!
|
|
|
|
if (name.isNotEmpty()) {
|
|
|
|
profileManager.setName(context, sender, name)
|
|
|
|
}
|
|
|
|
val newProfileKey = profile.profileKey
|
|
|
|
|
|
|
|
val needsProfilePicture = !AvatarHelper.avatarFileExists(context, sender.address)
|
|
|
|
val profileKeyValid = newProfileKey?.isNotEmpty() == true && (newProfileKey.size == 16 || newProfileKey.size == 32) && profile.profilePictureURL?.isNotEmpty() == true
|
|
|
|
val profileKeyChanged = (sender.profileKey == null || !MessageDigest.isEqual(sender.profileKey, newProfileKey))
|
|
|
|
|
|
|
|
if ((profileKeyValid && profileKeyChanged) || (profileKeyValid && needsProfilePicture)) {
|
|
|
|
profileManager.setProfileKey(context, sender, newProfileKey!!)
|
|
|
|
profileManager.setUnidentifiedAccessMode(context, sender, Recipient.UnidentifiedAccessMode.UNKNOWN)
|
|
|
|
profileManager.setProfilePictureURL(context, sender, profile.profilePictureURL!!)
|
|
|
|
}
|
|
|
|
}
|
2022-08-10 10:17:48 +02:00
|
|
|
threadDB.setHasSent(threadId, true)
|
|
|
|
val mappingDb = DatabaseComponent.get(context).blindedIdMappingDatabase()
|
|
|
|
val mappings = mutableMapOf<String, BlindedIdMapping>()
|
|
|
|
threadDB.readerFor(threadDB.conversationList).use { reader ->
|
|
|
|
while (reader.next != null) {
|
|
|
|
val recipient = reader.current.recipient
|
|
|
|
val address = recipient.address.serialize()
|
|
|
|
val blindedId = when {
|
|
|
|
recipient.isGroupRecipient -> null
|
|
|
|
recipient.isOpenGroupInboxRecipient -> {
|
|
|
|
GroupUtil.getDecodedOpenGroupInbox(address)
|
|
|
|
}
|
|
|
|
else -> {
|
|
|
|
if (SessionId(address).prefix == IdPrefix.BLINDED) {
|
|
|
|
address
|
|
|
|
} else null
|
|
|
|
}
|
|
|
|
} ?: continue
|
|
|
|
mappingDb.getBlindedIdMapping(blindedId).firstOrNull()?.let {
|
|
|
|
mappings[address] = it
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (mapping in mappings) {
|
|
|
|
if (!SodiumUtilities.sessionId(senderPublicKey, mapping.value.blindedId, mapping.value.serverId)) {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
mappingDb.addBlindedIdMapping(mapping.value.copy(sessionId = senderPublicKey))
|
|
|
|
|
|
|
|
val blindedThreadId = threadDB.getOrCreateThreadIdFor(Recipient.from(context, fromSerialized(mapping.key), false))
|
|
|
|
mmsDb.updateThreadId(blindedThreadId, threadId)
|
|
|
|
smsDb.updateThreadId(blindedThreadId, threadId)
|
|
|
|
threadDB.deleteConversation(blindedThreadId)
|
|
|
|
}
|
|
|
|
recipientDb.setApproved(sender, true)
|
|
|
|
recipientDb.setApprovedMe(sender, true)
|
2022-03-04 07:46:39 +01:00
|
|
|
|
|
|
|
val message = IncomingMediaMessage(
|
2022-08-10 10:17:48 +02:00
|
|
|
sender.address,
|
2022-03-04 07:46:39 +01:00
|
|
|
response.sentTimestamp!!,
|
|
|
|
-1,
|
|
|
|
0,
|
|
|
|
false,
|
2021-03-16 04:56:47 +01:00
|
|
|
false,
|
2022-03-04 07:46:39 +01:00
|
|
|
true,
|
2023-01-17 06:30:05 +01:00
|
|
|
false,
|
2021-03-16 04:56:47 +01:00
|
|
|
Optional.absent(),
|
2021-04-09 08:06:12 +02:00
|
|
|
Optional.absent(),
|
2021-03-16 04:56:47 +01:00
|
|
|
Optional.absent(),
|
|
|
|
Optional.absent(),
|
|
|
|
Optional.absent(),
|
|
|
|
Optional.absent(),
|
2022-03-04 07:46:39 +01:00
|
|
|
Optional.absent()
|
|
|
|
)
|
Performance improvements and bug fixes (#869)
* refactor: fail on testSnode instead of recursively using up snode list. add call timeout on http client
* refactor: refactoring batch message receives and pollers
* refactor: reduce thread utils pool count to a 2 thread fixed pool. Do a check against pubkey instead of room names for oxenHostedOpenGroup
* refactor: caching lib with potential loader fixes and no-cache for giphy
* refactor: remove store and instead use ConcurrentHashMap with a backing update coroutine
* refactor: queue trim thread jobs instead of add every message processed
* fix: wrapping auth token and initial sync for open groups in a threadutils queued runnable, getting initial sync times down
* fix: fixing the user contacts cache in ConversationAdapter.kt
* refactor: improve polling and initial sync, move group joins from config messages into a background job fetching image.
* refactor: improving the job queuing for open groups, replacing placeholder avatar generation with a custom glide loader and archiving initial sync of open groups
* feat: add OpenGroupDeleteJob.kt
* feat: add open group delete job to process deletions after batch adding
* feat: add vacuum and fix job queue re-adding jobs forever, only try to set message hash values in DB if they have changed
* refactor: remove redundant inflation for profile image views throughout app
* refactor(wip): reducing layout inflation and starting to refactor the open group deletion issues taking a long time
* refactor(wip): refactoring group deletion to not iterate through and delete messages individually
* refactor(wip): refactoring group deletion to not iterate through and delete messages individually
* fix: group deletion optimisation
* build: bump build number
* build: bump build number and fix batch message receive retry logic
* fix: clear out open group deletes
* fix: update visible ConversationAdapter.kt binding for initial contact fetching and better traces for debugging background jobs
* fix: add in check for / force sync latest encryption key pair from linked devices if we already have that closed group
* Rename .java to .kt
* refactor: change MmsDatabase to kotlin to make list operations easier
* fix: nullable type
* fix: compilation issues and constants in .kt instead of .java
* fix: bug fix expiration timer on closed group recipient
* feat: use the job queue properly across executors
* feat: start on open group dispatcher-specific logic, probably a queue factory based on openGroupId if that is the same across new message and deletion jobs to ensure consistent entry and removal
* refactor: removing redundant code and fixing jobqueue per opengroup
* fix: allow attachments in note to self
* fix: make the minWidth in quote view bind max of text / title and body, wrapped ?
* fix: fixing up layouts and code view layouts
* fix: remove TODO, remove timestamp binding
* feat: fix view logic, avatars and padding, downloading attachments lazily (on bind), fixing potential crash, add WindowDebouncer.kt
* fix: NPE on viewModel recipient from removed thread while tearing down the Recipient observer in ConversationActivityV2.kt
* refactor: replace conversation notification debouncer handler with handlerthread, same as conversation list debouncer
* refactor: UI for groups and poller improvements
* fix: revert some changes in poller
* feat: add header back in for message requests
* refactor: remove Trace calls, add more conditions to the HomeDiffUtil for updating more efficiently
* feat: try update the home adapter if we get a profile picture modified event
* feat: bump build numbers
* fix: try to start with list in homeViewModel if we don't have already, render quotes to be width of attachment slide view instead of fixed
* fix: set channel to be conflated instead of no buffer
* fix: set unreads based off last local user message vs incrementing unreads to be all amount
* feat: add profile update flag, update build number
* fix: link preview thumbnails download on bind
* fix: centercrop placeholder in glide request
* feat: recycle the contact selection list and profile image in unbind
* fix: try to prevent user KP crash at weird times
* fix: remove additional log, improve attachment download success rate, fix share logs dialog issue
2022-06-08 09:12:34 +02:00
|
|
|
mmsDb.insertSecureDecryptedMessageInbox(message, threadId, runIncrement = true, runThreadUpdate = true)
|
2022-03-04 07:46:39 +01:00
|
|
|
}
|
2021-03-16 04:56:47 +01:00
|
|
|
}
|
2022-03-04 07:46:39 +01:00
|
|
|
|
2022-03-09 23:54:18 +01:00
|
|
|
override fun setRecipientApproved(recipient: Recipient, approved: Boolean) {
|
|
|
|
DatabaseComponent.get(context).recipientDatabase().setApproved(recipient, approved)
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun setRecipientApprovedMe(recipient: Recipient, approvedMe: Boolean) {
|
|
|
|
DatabaseComponent.get(context).recipientDatabase().setApprovedMe(recipient, approvedMe)
|
|
|
|
}
|
|
|
|
|
Add one on one calls over clearnet (#864)
* feat: adding basic webrtc deps and test activity
* more testing code
* feat: add protos and bump version
* feat: added basic call functionality
* feat: adding UI and flipping cameras
* feat: add stats and starting call bottom sheet
* feat: hanging up and bottom sheet behaviors should work now
* feat: add call stats report on frontend
* feat: add relay toggle for answer and offer
* fix: add keep screen on and more end call message on back pressed / on finish
* refactor: removing and replacing dagger 1 dep with android hilt
* feat: include latest proto
* feat: update to utilise call ID
* feat: add stun and turn
* refactor: playing around with deps and transport types
* feat: adding call service functionality and permissions for calls
* feat: add call manager and more static intent building functions for WebRtcCallService.kt
* feat: adding ringers and more audio boilerplate
* feat: audio manager call service boilerplate
* feat: update kotlin and add in call view model and more management functions
* refactor: moving call code around to service and viewmodel interactions
* feat: plugging CallManager.kt into view model and service, fixing up dependencies
* feat: implementing more WebRtcCallService.kt functions and handlers for actions as well as lifecycle
* feat: adding more lifecycle vm and callmanager / call service functionality
* feat: adding more command handlers in WebRtcCallService.kt
* feat: more commands handled, adding lock manager and bluetooth permissions
* feat: adding remainder of basic functionality to services and CallManager.kt
* feat: hooking up calls and fixing broken dependencies and compile errors
* fix: add timestamp to incoming call
* feat: some connection and service launching / ring lifecycle
* feat: call establishing and displaying
* fix: fixing call connect flows
* feat: ringers and better state handling
* feat: updating call layout
* feat: add fixes to bluetooth and begin the network renegotiation
* feat: add call related permissions and more network handover tests
* fix: don't display call option in conversation and don't show notification if option not enabled
* fix: incoming ringer fix on receiving call, call notification priorities and notification channel update
* build: update build number for testing
* fix: bluetooth auto-connection and re-connection fixes, removing finished todos, allowing self-send call messages for deduping answers
* feat: add pre-offer information and action handling in web rtc call service
* refactor: discard offer messages from non-matching pre-offers we are already expecting
* build: build numbers and version name update
* feat: handle discarding pending calls from linked devices
* feat: add signing props to release config build
* docs: fix comment on time being 300s (5m) instead of 30s
* feat: adding call messages for incoming/outgoing/missed
* refactor: handle in-thread call notifications better and replace deny button intent with denyCallIntent instead of hangup
* feat: add a hangup via data channel message
* feat: process microphone enabled events and remove debuggable from build.gradle
* feat: add first call notification
* refactor: set the buttons to match iOS in terms of enable disable and colours
* refactor: change the call logos in control messages
* refactor: more bluetooth improvements
* refactor: move start ringer and init of audio manager to CallManager.kt and string fix up
* build: remove debuggable for release build
* refactor: replace call icons
* feat: adding a call time display
* refactor: change the call time to update every second
* refactor: testing out the full screen intents
* refactor: wrapper use corrected session description, set title to recipient displayName, indicate session calls
* fix: crash on view with a parent already attached
* refactor: aspect ratio fit preserved
* refactor: add wantsToAnswer ability in pre-init for fullscreenintent
* refactor: prevent calls from non hasSent participants
* build: update gradle code
* refactor: replace timeout schedule with a seconds count
* fix: various bug fixes for calls
* fix: remove end call from busy
* refactor: use answerCall instead of manual intent building again
* build: new version
* feat: add silenced notifications for call notification builder. check pre-offer and connecting state for pending connection
* build: update build number
* fix: text color uses overridden style value
* fix: remove wrap content for renderers and look more at recovering from network switches
* build: update build number
* refactor: remove whitespace
* build: update build number
* refactor: used shared number for BatchMessageReceiveJob.kt parameter across pollers
* fix: glide in update crash
* fix: bug fixes for self-send answer / hangup messages
* build: update build number
* build: update build.gradle number
* refactor: compile errors and refactoring to view binding
* fix: set the content to binding.root view
* build: increase build number
* build: update build numbers
* feat: adding base for rotation and picking random subset of turn servers
* feat: starting the screen rotation processing
* feat: setting up rotation for the remote render view
* refactor: applying rotation and mirroring based on front / rear cameras that wraps nicely, only scale reworking needed
* refactor: calls video stretching but consistent
* refactor: state machine and tests for the transition events
* feat: new call state processing
* refactor: adding reconnecting logic and visuals
* feat: state machine reconnect logic wip
* feat: add reconnecting and merge fixes
* feat: check new session based off current state
* feat: reconnection logic works correctly now
* refactor: reduce TIMEOUT_SECONDS to 30 from 90
* feat: reset peer connection on DC to prevent ICE messages from old connection or stale state in reconnecting
* refactor: add null case
* fix: set approved on new outgoing threads, use approved more deeply and invalidate the options menu on recipient modified. Add approvedMe flag toggles for visible message receive
* fix: add name update in action bar on modified, change where approvedMe is set
* build: increment build number
* build: update build number
* fix: merge compile errors and increment build number
* refactor: remove negotiation based on which party dropped connection
* refactor: call reconnection improvement tested cross platform to re-establish
* refactor: failed and disconnect events only handled if either the reconnect or the timeout runnables are not set
* build: update version number
* fix: reduce timeout
* fix: fixes the incoming hangup logic for linked devices
* refactor: match iOS styling for call activity closer
* chore: upgrade build numbers
* feat: add in call settings dialog for if calls is disabled in conversation
* feat: add a first call missed control message and info popup with link to privacy settings
* fix: looking at crash for specific large transaction in NotificationManager
* refactor: removing the people in case transaction size reduces to fix notif crash
* fix: comment out the entire send multiple to see if it fixes the issue
* refactor: revert to including the full notification process in a try/catch to handle weird responses from NotificationManager
* fix: add in notification settings prompt for calls and try to fall back to dirty full screen intent / start activity if we're allowed
* build: upgrade build number
2022-04-19 06:25:40 +02:00
|
|
|
override fun insertCallMessage(senderPublicKey: String, callMessageType: CallMessageType, sentTimestamp: Long) {
|
|
|
|
val database = DatabaseComponent.get(context).smsDatabase()
|
|
|
|
val address = fromSerialized(senderPublicKey)
|
|
|
|
val callMessage = IncomingTextMessage.fromCallInfo(callMessageType, address, Optional.absent(), sentTimestamp)
|
|
|
|
database.insertCallMessage(callMessage)
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun conversationHasOutgoing(userPublicKey: String): Boolean {
|
|
|
|
val database = DatabaseComponent.get(context).threadDatabase()
|
|
|
|
val threadId = database.getThreadIdIfExistsFor(userPublicKey)
|
|
|
|
|
|
|
|
if (threadId == -1L) return false
|
|
|
|
|
|
|
|
return database.getLastSeenAndHasSent(threadId).second() ?: false
|
|
|
|
}
|
2022-08-10 10:17:48 +02:00
|
|
|
|
|
|
|
override fun getLastInboxMessageId(server: String): Long? {
|
|
|
|
return DatabaseComponent.get(context).lokiAPIDatabase().getLastInboxMessageId(server)
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun setLastInboxMessageId(server: String, messageId: Long) {
|
|
|
|
DatabaseComponent.get(context).lokiAPIDatabase().setLastInboxMessageId(server, messageId)
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun removeLastInboxMessageId(server: String) {
|
|
|
|
DatabaseComponent.get(context).lokiAPIDatabase().removeLastInboxMessageId(server)
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun getLastOutboxMessageId(server: String): Long? {
|
|
|
|
return DatabaseComponent.get(context).lokiAPIDatabase().getLastOutboxMessageId(server)
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun setLastOutboxMessageId(server: String, messageId: Long) {
|
|
|
|
DatabaseComponent.get(context).lokiAPIDatabase().setLastOutboxMessageId(server, messageId)
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun removeLastOutboxMessageId(server: String) {
|
|
|
|
DatabaseComponent.get(context).lokiAPIDatabase().removeLastOutboxMessageId(server)
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun getOrCreateBlindedIdMapping(
|
|
|
|
blindedId: String,
|
|
|
|
server: String,
|
|
|
|
serverPublicKey: String,
|
|
|
|
fromOutbox: Boolean
|
|
|
|
): BlindedIdMapping {
|
|
|
|
val db = DatabaseComponent.get(context).blindedIdMappingDatabase()
|
|
|
|
val mapping = db.getBlindedIdMapping(blindedId).firstOrNull() ?: BlindedIdMapping(blindedId, null, server, serverPublicKey)
|
|
|
|
if (mapping.sessionId != null) {
|
|
|
|
return mapping
|
|
|
|
}
|
|
|
|
val threadDb = DatabaseComponent.get(context).threadDatabase()
|
|
|
|
threadDb.readerFor(threadDb.conversationList).use { reader ->
|
|
|
|
while (reader.next != null) {
|
|
|
|
val recipient = reader.current.recipient
|
|
|
|
val sessionId = recipient.address.serialize()
|
|
|
|
if (!recipient.isGroupRecipient && SodiumUtilities.sessionId(sessionId, blindedId, serverPublicKey)) {
|
|
|
|
val contactMapping = mapping.copy(sessionId = sessionId)
|
|
|
|
db.addBlindedIdMapping(contactMapping)
|
|
|
|
return contactMapping
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
db.getBlindedIdMappingsExceptFor(server).forEach {
|
|
|
|
if (SodiumUtilities.sessionId(it.sessionId!!, blindedId, serverPublicKey)) {
|
|
|
|
val otherMapping = mapping.copy(sessionId = it.sessionId)
|
|
|
|
db.addBlindedIdMapping(otherMapping)
|
|
|
|
return otherMapping
|
|
|
|
}
|
|
|
|
}
|
|
|
|
db.addBlindedIdMapping(mapping)
|
|
|
|
return mapping
|
|
|
|
}
|
2022-09-04 13:03:32 +02:00
|
|
|
|
2022-09-07 06:41:39 +02:00
|
|
|
override fun addReaction(reaction: Reaction, messageSender: String, notifyUnread: Boolean) {
|
2022-09-04 13:03:32 +02:00
|
|
|
val timestamp = reaction.timestamp
|
|
|
|
val localId = reaction.localId
|
|
|
|
val isMms = reaction.isMms
|
|
|
|
val messageId = if (localId != null && localId > 0 && isMms != null) {
|
|
|
|
MessageId(localId, isMms)
|
|
|
|
} else if (timestamp != null && timestamp > 0) {
|
|
|
|
val messageRecord = DatabaseComponent.get(context).mmsSmsDatabase().getMessageForTimestamp(timestamp) ?: return
|
|
|
|
MessageId(messageRecord.id, messageRecord.isMms)
|
|
|
|
} else return
|
|
|
|
DatabaseComponent.get(context).reactionDatabase().addReaction(
|
|
|
|
messageId,
|
|
|
|
ReactionRecord(
|
|
|
|
messageId = messageId.id,
|
|
|
|
isMms = messageId.mms,
|
2022-09-05 03:29:47 +02:00
|
|
|
author = messageSender,
|
2022-09-04 13:03:32 +02:00
|
|
|
emoji = reaction.emoji!!,
|
|
|
|
serverId = reaction.serverId!!,
|
|
|
|
count = reaction.count!!,
|
|
|
|
sortId = reaction.index!!,
|
|
|
|
dateSent = reaction.dateSent!!,
|
|
|
|
dateReceived = reaction.dateReceived!!
|
2022-09-07 06:41:39 +02:00
|
|
|
),
|
|
|
|
notifyUnread
|
2022-09-04 13:03:32 +02:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2022-09-07 06:41:39 +02:00
|
|
|
override fun removeReaction(emoji: String, messageTimestamp: Long, author: String, notifyUnread: Boolean) {
|
2022-09-04 13:03:32 +02:00
|
|
|
val messageRecord = DatabaseComponent.get(context).mmsSmsDatabase().getMessageForTimestamp(messageTimestamp) ?: return
|
|
|
|
val messageId = MessageId(messageRecord.id, messageRecord.isMms)
|
2022-09-07 06:41:39 +02:00
|
|
|
DatabaseComponent.get(context).reactionDatabase().deleteReaction(emoji, messageId, author, notifyUnread)
|
2022-09-04 13:03:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
override fun updateReactionIfNeeded(message: Message, sender: String, openGroupSentTimestamp: Long) {
|
|
|
|
val database = DatabaseComponent.get(context).reactionDatabase()
|
|
|
|
var reaction = database.getReactionFor(message.sentTimestamp!!, sender) ?: return
|
|
|
|
if (openGroupSentTimestamp != -1L) {
|
|
|
|
addReceivedMessageTimestamp(openGroupSentTimestamp)
|
|
|
|
reaction = reaction.copy(dateSent = openGroupSentTimestamp)
|
|
|
|
}
|
|
|
|
message.serverHash?.let {
|
|
|
|
reaction = reaction.copy(serverId = it)
|
|
|
|
}
|
|
|
|
message.openGroupServerMessageID?.let {
|
|
|
|
reaction = reaction.copy(serverId = "$it")
|
|
|
|
}
|
|
|
|
database.updateReaction(reaction)
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun deleteReactions(messageId: Long, mms: Boolean) {
|
|
|
|
DatabaseComponent.get(context).reactionDatabase().deleteMessageReactions(MessageId(messageId, mms))
|
|
|
|
}
|
|
|
|
|
2023-05-19 16:14:07 +02:00
|
|
|
override fun unblock(toUnblock: Iterable<Recipient>) {
|
New app theming (#913)
* feat: start new app theming feature
* feat: add some theming colours
* refactor: start refactoring themes and colours to use dynamic attributes
* feat: adding more colours and switching over default colours to be theme based instead of hard-coded or day/night specific
* refactor: take a look at ocean light and logo colour
* feat: global search colours for light and dark ocean
* feat: more styling
* feat: adding themes to conversation activity and refactoring the base theme to apply over the top of the activity's theme so it retains noActionBar etc
* feat: add dynamic accent color
* docs: add todo for changing how accent colour is applied
* feat: update new theming to use override primary style so that the regular colorAccent attribute can be used in existing layouts
* feat: coordinating styles across layouts, fixing up pinned icons and naming for conversation list items
* refactor: re-styling layouts to match new themes and attributes. Need to figure out action mode close button
* refactor: remove @color/text and replace with ?android:textColorPrimary to override in themes
* refactor: add context theme wrapper to bottom sheet dialog that references accent color
* fix: input bar bug fix and preference activity themes
* refactor: new settings menu options
* fix: crash for PNModeActivity.kt
refactor: move ordering in seed dialog to match designs, copy changes to match new settings menu
* feat: add new appearance settings activity
* refactor: title and VM changes
* fix: correct override
* feat: add theme appearance screen UI features and start VM implementation. re-add legacy theme utils to get default for migration
* fix: compile errors and missing themes from emoji features
* refactor: remove background shape alteration and old bottom sheet styles, re-add the theme mode attr
* feat: appearance screen wired up, just need to refresh theme
* feat: add theme state recreation and fix match system settings option
* refactor: add bottom margin
* feat: explore custom preference category
* feat: add the customized session theme for CorrectedPreferenceFragment
* feat: replace AppProtectionPreferenceFragment to extend ListSummaryPreferenceFragment
* refactor: change drawable style and remove explicit dividers
* refactor: remove divider in CorrectedPreferenceFragment
* feat: add theme state check on resume, might be jarring currently
* feat: add preference divider elements for settings menu
* refactor: settings menu redesigns
* refactor: change led preference to integer and refactor TextSecurePreferences.kt
* feat: add scroll parcel to save/restore hierarchy on restart with appearance changes
* feat: add the conversations blocked contacts and refactor preference order and copy
* feat: add blocked contacts activity, basic layout and vm
* feat: add unblock DB functions and storage protocol, start working on the DB query state flow, might have to just implement recipient on modified listener
* feat: add blocked contacts and notif recipient listeners
* feat: add recipient db reader
* feat: add blocked contact interactions and fix a theming crash for notifications
* feat: introduce better equals and hashcode implementations to recipient, replace home diff util content check with hashcode-based comparison
* feat: add settings menu vectors
* fix: preview compile error
* refactor: migrating settings menu to new designs
* feat: help menu
* refactor: simplify link opening
* refactor: remove space
* feat: refactor preferences and start theming for light mode options
* refactor: fixing dark and light modes with dialogs
* refactor: popup dialogs use proper themes now
* refactor: alert dialogs and media edit fragments use attribute references
* refactor: use input bar button attribute instead color control normal in vector tint
* refactor: transparency, dialog fixes, notification fix
* refactor: attrs and styles for buttons
* fix: use prominent button color on the outline button's border
* fix: fix the trash
* refactor: remove the appearance
* refactor: avatar placeholder generation, chips and element border styles
* refactor: use colors instead of style references
* refactor: theming changes to match designs and feedback
* refactor: the titles are bold and the categories are tertiary coloured now
* fix: appearance settings match preferences, search bottom bar uses themed attributes
* refactor: increase setting button height
* Update clear all data dialog
* Update seed dialog
* refactor: more qa feedback changes
* feat: add new TLs and fa-rIR TLs
* Update notification content dialog
* Fix message requests clear all button text color
* feat: re-add screenshot observer
* refactor: make send tint accent color
* feat: add unread background differences
* fix: change unread count indicator
* build: upgrade build numbers
* Fix message requests popupmenu background color
* fix: crash from attr reference in color attribute
* build: upgrade build number
* fix: message bubbles, thumbnail backgrounds, search bar visibility with input bar, attachment buttons
* fix: tertiary text for keyboard page search view
* fix: emoji overflow colour differences
* fix: reaction pill dialog background is now correct colour
* Add style to reactions tab layout
* fix: appearance activity reverting primary color at correct time
* fix: show call privacy warning every time instead of just once
* fix: gradient background(?) and audio autoplay disable
* fix: crash in all media containing documents
* fix: reaction dialog heading fixes
* Add style to reactions tab layout
* fix: remove gradient backgrounds
* fix: adding new reaction normal text attribute to try correct the tab layout
* fix: ocean dark unread/read colours
* build; update build number
* build: update build number
Co-authored-by: charles <charles@oxen.io>
2022-10-12 08:05:55 +02:00
|
|
|
val recipientDb = DatabaseComponent.get(context).recipientDatabase()
|
|
|
|
recipientDb.setBlocked(toUnblock, false)
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun blockedContacts(): List<Recipient> {
|
|
|
|
val recipientDb = DatabaseComponent.get(context).recipientDatabase()
|
|
|
|
return recipientDb.blockedContacts
|
|
|
|
}
|
2021-01-13 07:11:30 +01:00
|
|
|
}
|