mirror of
https://github.com/oxen-io/session-android.git
synced 2025-04-16 10:31:28 +00:00
Fix duplicate message handling
This commit is contained in:
parent
a907d78916
commit
92bf59b5a0
@ -151,6 +151,7 @@ object FriendRequestProtocol {
|
|||||||
// Guard against invalid state transitions
|
// Guard against invalid state transitions
|
||||||
if (threadFRStatus != LokiThreadFriendRequestStatus.REQUEST_SENDING && threadFRStatus != LokiThreadFriendRequestStatus.REQUEST_SENT
|
if (threadFRStatus != LokiThreadFriendRequestStatus.REQUEST_SENDING && threadFRStatus != LokiThreadFriendRequestStatus.REQUEST_SENT
|
||||||
&& threadFRStatus != LokiThreadFriendRequestStatus.REQUEST_RECEIVED) { return }
|
&& threadFRStatus != LokiThreadFriendRequestStatus.REQUEST_RECEIVED) { return }
|
||||||
|
Log.d("Loki", "Accepting friend request from $publicKey.")
|
||||||
lokiThreadDB.setFriendRequestStatus(threadID, LokiThreadFriendRequestStatus.FRIENDS)
|
lokiThreadDB.setFriendRequestStatus(threadID, LokiThreadFriendRequestStatus.FRIENDS)
|
||||||
val lastMessageID = getLastMessageID(context, threadID)
|
val lastMessageID = getLastMessageID(context, threadID)
|
||||||
if (lastMessageID != null) {
|
if (lastMessageID != null) {
|
||||||
@ -208,6 +209,7 @@ object FriendRequestProtocol {
|
|||||||
val lokiThreadDB = DatabaseFactory.getLokiThreadDatabase(context)
|
val lokiThreadDB = DatabaseFactory.getLokiThreadDatabase(context)
|
||||||
val threadFRStatus = lokiThreadDB.getFriendRequestStatus(threadID)
|
val threadFRStatus = lokiThreadDB.getFriendRequestStatus(threadID)
|
||||||
if (canFriendRequestBeAutoAccepted(context, publicKey)) {
|
if (canFriendRequestBeAutoAccepted(context, publicKey)) {
|
||||||
|
Log.d("Loki", "Auto-accepting friend request from $publicKey.")
|
||||||
lokiThreadDB.setFriendRequestStatus(threadID, LokiThreadFriendRequestStatus.FRIENDS)
|
lokiThreadDB.setFriendRequestStatus(threadID, LokiThreadFriendRequestStatus.FRIENDS)
|
||||||
val lastMessageID = getLastMessageID(context, threadID)
|
val lastMessageID = getLastMessageID(context, threadID)
|
||||||
if (lastMessageID != null) {
|
if (lastMessageID != null) {
|
||||||
@ -217,6 +219,7 @@ object FriendRequestProtocol {
|
|||||||
val ephemeralMessage = EphemeralMessage.create(publicKey)
|
val ephemeralMessage = EphemeralMessage.create(publicKey)
|
||||||
ApplicationContext.getInstance(context).jobManager.add(PushEphemeralMessageSendJob(ephemeralMessage))
|
ApplicationContext.getInstance(context).jobManager.add(PushEphemeralMessageSendJob(ephemeralMessage))
|
||||||
} else if (threadFRStatus != LokiThreadFriendRequestStatus.FRIENDS) {
|
} else if (threadFRStatus != LokiThreadFriendRequestStatus.FRIENDS) {
|
||||||
|
Log.d("Loki", "Handling friend request from $publicKey.")
|
||||||
// Checking that the sender of the message isn't already a friend is necessary because otherwise
|
// Checking that the sender of the message isn't already a friend is necessary because otherwise
|
||||||
// the following situation can occur: Alice and Bob are friends. Bob loses his database and his
|
// the following situation can occur: Alice and Bob are friends. Bob loses his database and his
|
||||||
// friend request status is reset to NONE. Bob now sends Alice a friend request. Alice's thread's
|
// friend request status is reset to NONE. Bob now sends Alice a friend request. Alice's thread's
|
||||||
|
@ -17,7 +17,9 @@ object SessionMetaProtocol {
|
|||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun shouldIgnoreMessage(content: SignalServiceContent): Boolean {
|
fun shouldIgnoreMessage(content: SignalServiceContent): Boolean {
|
||||||
val timestamp = content.timestamp
|
val timestamp = content.timestamp
|
||||||
return timestamps.contains(timestamp)
|
val shouldIgnoreMessage = timestamps.contains(timestamp)
|
||||||
|
timestamps.add(timestamp)
|
||||||
|
return shouldIgnoreMessage
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
|
Loading…
x
Reference in New Issue
Block a user