mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 09:49:30 +01:00
Add group call NOT_ACCEPTED sync handling.
This commit is contained in:
@@ -367,6 +367,28 @@ class CallTable(context: Context, databaseHelper: SignalDatabase) : DatabaseTabl
|
||||
Log.d(TAG, "Transitioned group call ${call.callId} from ${call.event} to $newEvent")
|
||||
}
|
||||
|
||||
fun declineIncomingGroupCall(call: Call) {
|
||||
checkIsGroupOrAdHocCall(call)
|
||||
check(call.direction == Direction.INCOMING)
|
||||
|
||||
val newEvent = when (call.event) {
|
||||
Event.RINGING, Event.MISSED -> Event.DECLINED
|
||||
else -> {
|
||||
Log.d(TAG, "Call in state ${call.event} cannot be transitioned by DECLINED")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
writableDatabase
|
||||
.update(TABLE_NAME)
|
||||
.values(EVENT to Event.serialize(newEvent))
|
||||
.run()
|
||||
|
||||
ApplicationDependencies.getMessageNotifier().updateNotification(context)
|
||||
ApplicationDependencies.getDatabaseObserver().notifyCallUpdateObservers()
|
||||
Log.d(TAG, "Transitioned group call ${call.callId} from ${call.event} to $newEvent")
|
||||
}
|
||||
|
||||
fun insertAcceptedGroupCall(
|
||||
callId: Long,
|
||||
recipientId: RecipientId,
|
||||
@@ -410,6 +432,46 @@ class CallTable(context: Context, databaseHelper: SignalDatabase) : DatabaseTabl
|
||||
ApplicationDependencies.getDatabaseObserver().notifyCallUpdateObservers()
|
||||
}
|
||||
|
||||
fun insertDeclinedGroupCall(
|
||||
callId: Long,
|
||||
recipientId: RecipientId,
|
||||
timestamp: Long
|
||||
) {
|
||||
val recipient = Recipient.resolved(recipientId)
|
||||
val type = if (recipient.isCallLink) Type.AD_HOC_CALL else Type.GROUP_CALL
|
||||
|
||||
writableDatabase.withinTransaction { db ->
|
||||
val messageId: MessageId? = if (type == Type.GROUP_CALL) {
|
||||
SignalDatabase.messages.insertGroupCall(
|
||||
groupRecipientId = recipientId,
|
||||
sender = Recipient.self().id,
|
||||
timestamp,
|
||||
"",
|
||||
emptyList(),
|
||||
false
|
||||
)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
||||
db
|
||||
.insertInto(TABLE_NAME)
|
||||
.values(
|
||||
CALL_ID to callId,
|
||||
MESSAGE_ID to messageId?.id,
|
||||
PEER to recipientId.toLong(),
|
||||
EVENT to Event.serialize(Event.DECLINED),
|
||||
TYPE to Type.serialize(type),
|
||||
DIRECTION to Direction.serialize(Direction.INCOMING),
|
||||
TIMESTAMP to timestamp,
|
||||
RINGER to null
|
||||
)
|
||||
.run(SQLiteDatabase.CONFLICT_ABORT)
|
||||
}
|
||||
|
||||
ApplicationDependencies.getDatabaseObserver().notifyCallUpdateObservers()
|
||||
}
|
||||
|
||||
fun insertOrUpdateGroupCallFromExternalEvent(
|
||||
groupRecipientId: RecipientId,
|
||||
sender: RecipientId,
|
||||
|
||||
Reference in New Issue
Block a user