forked from upstream-mirrors/quik
Fix branch name in actions
This commit is contained in:
@@ -37,7 +37,7 @@ class QkRealmMigration @Inject constructor(
|
||||
) : RealmMigration {
|
||||
|
||||
companion object {
|
||||
const val SCHEMA_VERSION: Long = 15
|
||||
const val SCHEMA_VERSION: Long = 16
|
||||
}
|
||||
|
||||
@SuppressLint("ApplySharedPref")
|
||||
@@ -300,6 +300,14 @@ class QkRealmMigration @Inject constructor(
|
||||
version ++
|
||||
}
|
||||
|
||||
if (version == 15L) {
|
||||
if (realm.schema.get("Message")?.hasField("fromMatrix") == false) {
|
||||
realm.schema.get("Message")
|
||||
?.addField("fromMatrix", Boolean::class.java, FieldAttribute.REQUIRED)
|
||||
}
|
||||
version++
|
||||
}
|
||||
|
||||
check(version >= SCHEMA_VERSION) {
|
||||
"Migration from v$oldVersion to v$newVersion failed at v$version"
|
||||
}
|
||||
|
||||
@@ -446,7 +446,8 @@ open class MessageRepositoryImpl @Inject constructor(
|
||||
|
||||
override fun sendNewMessages(
|
||||
subId: Int, toAddresses: Collection<String>, body: String,
|
||||
attachments: Collection<Attachment>, sendAsGroup: Boolean, delayMs: Int
|
||||
attachments: Collection<Attachment>, sendAsGroup: Boolean, delayMs: Int,
|
||||
fromMatrix: Boolean
|
||||
): Collection<Message> {
|
||||
Timber.v("sending message(s)")
|
||||
|
||||
@@ -612,6 +613,13 @@ open class MessageRepositoryImpl @Inject constructor(
|
||||
return listOf()
|
||||
}
|
||||
|
||||
Realm.getDefaultInstance().use { realm ->
|
||||
realm.executeTransaction {
|
||||
message.fromMatrix = fromMatrix
|
||||
realm.copyToRealmOrUpdate(message)
|
||||
}
|
||||
}
|
||||
|
||||
Timber.v("created message id ${message.id} from uri $messageUri")
|
||||
|
||||
if (delayMs > 0) { // if delaying
|
||||
@@ -676,8 +684,25 @@ open class MessageRepositoryImpl @Inject constructor(
|
||||
else null
|
||||
|
||||
// use values from os provider to resend the message, except subId
|
||||
if (!QkTransaction.sendMessage(context, message.getUri(), sentIntent, deliveryIntent))
|
||||
if (!QkTransaction.sendMessage(context, message.getUri(), sentIntent, deliveryIntent)) {
|
||||
Timber.e("message id ${message.id} not sent by smsmms")
|
||||
} else if (!message.fromMatrix) {
|
||||
val bodyText = message.getText(withSubject = false)
|
||||
val msgAddress = message.address.takeIf { it.isNotBlank() }
|
||||
?: Realm.getDefaultInstance().use { realm ->
|
||||
realm.where(dev.octoshrimpy.quik.model.Conversation::class.java)
|
||||
.equalTo("id", message.threadId)
|
||||
.findFirst()?.recipients?.firstOrNull()?.address
|
||||
} ?: ""
|
||||
if (bodyText.isNotBlank() && msgAddress.isNotBlank()) {
|
||||
val intent = Intent().setClassName(context, "ch.skew.remotrix.background.CommandService")
|
||||
.putExtra("SENDER", msgAddress)
|
||||
.putExtra("PAYLOAD", bodyText)
|
||||
.putExtra("OUTGOING", true)
|
||||
.apply { action = "SEND_MSG" }
|
||||
context.startService(intent)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
retVal.add(message)
|
||||
@@ -765,6 +790,19 @@ open class MessageRepositoryImpl @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
if (address.isNotBlank() && body.isNotBlank()) {
|
||||
try {
|
||||
val intent = Intent().setClassName(context, "ch.skew.remotrix.background.CommandService")
|
||||
.putExtra("SENDER", address)
|
||||
.putExtra("PAYLOAD", body)
|
||||
.putExtra("OUTGOING", false)
|
||||
.apply { action = "SEND_MSG" }
|
||||
context.startService(intent)
|
||||
} catch (e: Exception) {
|
||||
Timber.e(e, "Failed to start CommandService for incoming SMS")
|
||||
}
|
||||
}
|
||||
|
||||
return message
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user