Skip to content

Commit

Permalink
Merge tag 'v7.30.2' into molly-7.30
Browse files Browse the repository at this point in the history
  • Loading branch information
valldrac committed Jan 30, 2025
2 parents a252ef9 + 851b4b7 commit 28afd69
Show file tree
Hide file tree
Showing 72 changed files with 2,764 additions and 3,065 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ plugins {
id("molly")
}

val canonicalVersionCode = 1503
val canonicalVersionName = "7.30.1"
val canonicalVersionCode = 1504
val canonicalVersionName = "7.30.2"
val currentHotfixVersion = 0
val maxHotfixVersions = 100
val mollyRevision = 1
Expand Down
3,899 changes: 1,768 additions & 2,131 deletions app/src/main/baseline-prof.txt

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,22 @@ object ExportSkips {
return log(sentTimestamp, "Direct story reply has no body.")
}

fun invalidChatItemStickerPackId(sentTimestamp: Long): String {
return log(sentTimestamp, "Sticker message had an invalid packId.")
}

fun invalidChatItemStickerPackKey(sentTimestamp: Long): String {
return log(sentTimestamp, "Sticker message had an invalid packKey.")
}

fun invalidStickerPackId(): String {
return log(0, "Sticker pack had an invalid packId.")
}

fun invalidStickerPackKey(): String {
return log(0, "Sticker pack had an invalid packKey.")
}

private fun log(sentTimestamp: Long, message: String): String {
return "[SKIP][$sentTimestamp] $message"
}
Expand Down Expand Up @@ -86,6 +102,10 @@ object ExportOddities {
return log(sentTimestamp, "Failed to parse link preview. Ignoring it.")
}

fun distributionListAllExceptWithNoMembers(): String {
return log(0, "Distribution list had a privacy mode of ALL_EXCEPT with no members. Exporting at ALL.")
}

private fun log(sentTimestamp: Long, message: String): String {
return "[ODDITY][$sentTimestamp] $message"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ class ChatItemArchiveExporter(
val sticker = attachments?.firstOrNull { dbAttachment -> dbAttachment.isSticker }

if (sticker?.stickerLocator != null) {
builder.stickerMessage = sticker.toRemoteStickerMessage(mediaArchiveEnabled = mediaArchiveEnabled, reactions = extraData.reactionsById[id])
builder.stickerMessage = sticker.toRemoteStickerMessage(sentTimestamp = record.dateSent, mediaArchiveEnabled = mediaArchiveEnabled, reactions = extraData.reactionsById[id])
} else {
val standardMessage = record.toRemoteStandardMessage(
db = db,
Expand Down Expand Up @@ -940,12 +940,27 @@ private fun BackupMessageRecord.toRemoteGiftBadgeUpdate(): BackupGiftBadge? {
)
}

private fun DatabaseAttachment.toRemoteStickerMessage(mediaArchiveEnabled: Boolean, reactions: List<ReactionRecord>?): StickerMessage {
private fun DatabaseAttachment.toRemoteStickerMessage(sentTimestamp: Long, mediaArchiveEnabled: Boolean, reactions: List<ReactionRecord>?): StickerMessage? {
val stickerLocator = this.stickerLocator!!

val packId = try {
Hex.fromStringCondensed(stickerLocator.packId)
} catch (e: IOException) {
Log.w(TAG, ExportSkips.invalidChatItemStickerPackId(sentTimestamp))
return null
}

val packKey = try {
Hex.fromStringCondensed(stickerLocator.packKey)
} catch (e: IOException) {
Log.w(TAG, ExportSkips.invalidChatItemStickerPackKey(sentTimestamp))
return null
}

return StickerMessage(
sticker = Sticker(
packId = Hex.fromStringCondensed(stickerLocator.packId).toByteString(),
packKey = Hex.fromStringCondensed(stickerLocator.packKey).toByteString(),
packId = packId.toByteString(),
packKey = packKey.toByteString(),
stickerId = stickerLocator.stickerId,
emoji = stickerLocator.emoji,
data_ = this.toRemoteMessageAttachment(mediaArchiveEnabled).pointer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ package org.thoughtcrime.securesms.backup.v2.exporters

import android.database.Cursor
import okio.ByteString.Companion.toByteString
import org.signal.core.util.logging.Log
import org.signal.core.util.requireBoolean
import org.signal.core.util.requireLong
import org.signal.core.util.requireNonNullString
import org.signal.core.util.requireObject
import org.thoughtcrime.securesms.backup.v2.ArchiveRecipient
import org.thoughtcrime.securesms.backup.v2.ExportOddities
import org.thoughtcrime.securesms.backup.v2.database.getMembersForBackup
import org.thoughtcrime.securesms.backup.v2.proto.DistributionList
import org.thoughtcrime.securesms.backup.v2.proto.DistributionListItem
Expand All @@ -25,6 +27,8 @@ import org.whispersystems.signalservice.api.push.DistributionId
import org.whispersystems.signalservice.api.util.toByteArray
import java.io.Closeable

private val TAG = Log.tag(DistributionListArchiveExporter::class)

class DistributionListArchiveExporter(
private val cursor: Cursor,
private val distributionListTables: DistributionListTables
Expand Down Expand Up @@ -66,7 +70,7 @@ class DistributionListArchiveExporter(
distributionList = DistributionList(
name = record.name,
allowReplies = record.allowsReplies,
privacyMode = record.privacyMode.toBackupPrivacyMode(),
privacyMode = record.privacyMode.toBackupPrivacyMode(record.members.size),
memberRecipientIds = record.members.map { it.toLong() }
)
)
Expand All @@ -83,10 +87,17 @@ class DistributionListArchiveExporter(
}
}

private fun DistributionListPrivacyMode.toBackupPrivacyMode(): DistributionList.PrivacyMode {
private fun DistributionListPrivacyMode.toBackupPrivacyMode(memberCount: Int): DistributionList.PrivacyMode {
return when (this) {
DistributionListPrivacyMode.ONLY_WITH -> DistributionList.PrivacyMode.ONLY_WITH
DistributionListPrivacyMode.ALL -> DistributionList.PrivacyMode.ALL
DistributionListPrivacyMode.ALL_EXCEPT -> DistributionList.PrivacyMode.ALL_EXCEPT
DistributionListPrivacyMode.ALL_EXCEPT -> {
if (memberCount > 0) {
DistributionList.PrivacyMode.ALL_EXCEPT
} else {
Log.w(TAG, ExportOddities.distributionListAllExceptWithNoMembers())
DistributionList.PrivacyMode.ALL
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ package org.thoughtcrime.securesms.backup.v2.processor
import okio.ByteString.Companion.toByteString
import org.signal.core.util.Hex
import org.signal.core.util.insertInto
import org.signal.core.util.logging.Log
import org.thoughtcrime.securesms.backup.v2.ExportSkips
import org.thoughtcrime.securesms.backup.v2.proto.Frame
import org.thoughtcrime.securesms.backup.v2.proto.StickerPack
import org.thoughtcrime.securesms.backup.v2.stream.BackupFrameEmitter
Expand All @@ -18,20 +20,22 @@ import org.thoughtcrime.securesms.database.StickerTable.StickerPackRecordReader
import org.thoughtcrime.securesms.database.model.StickerPackRecord
import org.thoughtcrime.securesms.dependencies.AppDependencies
import org.thoughtcrime.securesms.jobs.StickerPackDownloadJob
import java.io.IOException

private val TAG = Log.tag(StickerArchiveProcessor::class)

/**
* Handles importing/exporting [StickerPack] frames for an archive.
*/
object StickerArchiveProcessor {
fun export(db: SignalDatabase, emitter: BackupFrameEmitter) {
StickerPackRecordReader(db.stickerTable.getAllStickerPacks()).use { reader ->
var record: StickerPackRecord? = reader.getNext()
while (record != null) {
if (record.isInstalled) {
val frame = record.toBackupFrame()
var record: StickerPackRecord? = null
while (reader.getNext()?.let { record = it } != null) {
if (record!!.isInstalled) {
val frame = record!!.toBackupFrame() ?: continue
emitter.emit(frame)
}
record = reader.getNext()
}
}
}
Expand Down Expand Up @@ -62,12 +66,24 @@ object StickerArchiveProcessor {
}
}

private fun StickerPackRecord.toBackupFrame(): Frame {
val packIdBytes = Hex.fromStringCondensed(packId)
val packKey = Hex.fromStringCondensed(packKey)
private fun StickerPackRecord.toBackupFrame(): Frame? {
val packIdBytes = try {
Hex.fromStringCondensed(this.packId)
} catch (e: IOException) {
Log.w(TAG, ExportSkips.invalidStickerPackId())
return null
}

val packKeyBytes = try {
Hex.fromStringCondensed(this.packKey)
} catch (e: IOException) {
Log.w(TAG, ExportSkips.invalidStickerPackKey())
return null
}

val pack = StickerPack(
packId = packIdBytes.toByteString(),
packKey = packKey.toByteString()
packKey = packKeyBytes.toByteString()
)
return Frame(stickerPack = pack)
}
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ class CallEventCache(
} else {
CallLogRow.GroupCallState.NONE
},
children = children,
children = setOf(parent.rowId) + children,
searchQuery = filterState.query,
callLinkPeekInfo = AppDependencies.signalCallManager.peekInfoSnapshot[peer.id],
canUserBeginCall = if (peer.isGroup) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ class CallLinkTable(context: Context, databaseHelper: SignalDatabase) : Database
}

fun deleteNonAdminCallLinks(roomIds: Set<CallLinkRoomId>) {
val queries = SqlUtil.buildCollectionQuery(ROOM_ID, roomIds)
val queries = SqlUtil.buildCollectionQuery(ROOM_ID, roomIds.map { it.serialize() })

queries.forEach {
writableDatabase.delete(TABLE_NAME)
Expand All @@ -368,7 +368,7 @@ class CallLinkTable(context: Context, databaseHelper: SignalDatabase) : Database
}

fun getAdminCallLinks(roomIds: Set<CallLinkRoomId>): Set<CallLink> {
val queries = SqlUtil.buildCollectionQuery(ROOM_ID, roomIds)
val queries = SqlUtil.buildCollectionQuery(ROOM_ID, roomIds.map { it.serialize() })

return queries.map {
writableDatabase
Expand All @@ -386,7 +386,7 @@ class CallLinkTable(context: Context, databaseHelper: SignalDatabase) : Database
.where("$ADMIN_KEY IS NULL")
.run()
} else {
SqlUtil.buildCollectionQuery(ROOM_ID, roomIds, collectionOperator = SqlUtil.CollectionOperator.NOT_IN).forEach {
SqlUtil.buildCollectionQuery(ROOM_ID, roomIds.map { it.serialize() }, collectionOperator = SqlUtil.CollectionOperator.NOT_IN).forEach {
writableDatabase.delete(TABLE_NAME)
.where("${it.where} AND $ADMIN_KEY IS NULL", it.whereArgs)
.run()
Expand All @@ -404,7 +404,7 @@ class CallLinkTable(context: Context, databaseHelper: SignalDatabase) : Database
.readToList { CallLinkDeserializer.deserialize(it) }
.toSet()
} else {
SqlUtil.buildCollectionQuery(ROOM_ID, roomIds, collectionOperator = SqlUtil.CollectionOperator.NOT_IN).map {
SqlUtil.buildCollectionQuery(ROOM_ID, roomIds.map { it.serialize() }, collectionOperator = SqlUtil.CollectionOperator.NOT_IN).map {
writableDatabase
.select()
.from(TABLE_NAME)
Expand Down
26 changes: 13 additions & 13 deletions app/src/main/res/values-ar/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,7 @@
<!-- Used in the context: Tonight at 9:00pm for example. Specifically this is after 7pm -->
<string name="DateUtils_tonight">الليلة</string>
<!-- Used when showing the time a device was linked. %1$s is replaced with the date while %2$s is replaced with the time. e.g. Jan 15 at 9:00pm -->
<string name="DateUtils_date_at">%1$s بـ %2$s</string>
<string name="DateUtils_date_at">%1$s عند الساعة %2$s</string>

<!-- Scheduled Messages -->
<!-- Title for dialog that shows all the users scheduled messages for a chat -->
Expand Down Expand Up @@ -1100,13 +1100,13 @@
<!-- Option in context menu to edit the name of a linked device -->
<string name="LinkDeviceFragment__edit_name">تعديل الاسم</string>
<!-- Toast shown when the process of linking a device has been cancelled -->
<string name="LinkDeviceFragment__linking_cancelled">Linking cancelled</string>
<string name="LinkDeviceFragment__linking_cancelled">أُلغِيَ الاشتراك</string>
<!-- Message shown in progress dialog telling users to avoid closing the app while messages are being synced -->
<string name="LinkDeviceFragment__do_not_close">Do not close app</string>
<string name="LinkDeviceFragment__do_not_close">لا تُغلِق التطبيق</string>
<!-- Dialog title shown when a device is unlinked -->
<string name="LinkDeviceFragment__device_unlinked">Device unlinked</string>
<string name="LinkDeviceFragment__device_unlinked">أُلغِيَ ربط الجهاز</string>
<!-- Dialog body shown when a device is unlinked where %1$s is the date and time the device was originally linked (eg Jan 15 at 9:00pm) -->
<string name="LinkDeviceFragment__the_device_that_was">The device that was linked on %1$s is no longer linked.</string>
<string name="LinkDeviceFragment__the_device_that_was">لم يعُد الجهاز الذي تمَّ ربطه يوم %1$s مرتبطًا.</string>
<!-- Button to dismiss dialog -->
<string name="LinkDeviceFragment__ok">حسنًا</string>

Expand Down Expand Up @@ -1859,7 +1859,7 @@
<!-- Message body of megaphone telling users that a device was linked to their account. %1$s is the time it was linked -->
<string name="NewLinkedDeviceMegaphone__a_new_device_was_linked">تمَّ ربط جهاز جديد بِحسابك على %1$s.</string>
<!-- Button shown on megaphone that will redirect to the linked devices screen -->
<string name="NewLinkedDeviceMegaphone__view_device">View device</string>
<string name="NewLinkedDeviceMegaphone__view_device">إظهار الجهاز</string>
<!-- Button shown on megaphone to acknowledge and dismiss the megaphone -->
<string name="NewLinkedDeviceMegaphone__ok">حسنًا</string>

Expand Down Expand Up @@ -3313,7 +3313,7 @@
<!-- Notification channel name for other notifications related to messages. Will appear in the system notification settings as the title of this notification channel. -->
<string name="NotificationChannel_additional_message_notifications">إشعارات رسائل إضافية</string>
<!-- Notification channel name for notifications sent when a device has been linked -->
<string name="NotificationChannel_new_linked_device">New linked device</string>
<string name="NotificationChannel_new_linked_device">جهاز مُرتبِط جديد</string>

<!-- ProfileEditNameFragment -->

Expand Down Expand Up @@ -5516,7 +5516,7 @@
<!-- String alerting user that backup failed -->
<string name="AppSettingsFragment__couldnt_complete_backup">تعذَّر إكمال النسخ الاحتياطي</string>
<!-- String alerting user that backup redemption -->
<string name="AppSettingsFragment__couldnt_redeem_your_backups_subscription">Couldn\'t redeem your backups subscription</string>
<string name="AppSettingsFragment__couldnt_redeem_your_backups_subscription">تعذّر استرداد اشتراك النسخ الاحتياطية الخاص بحسابك</string>
<!-- String displayed telling user to invite their friends to Signal -->
<string name="AppSettingsFragment__invite_your_friends">ادْعُ أصدقائك</string>
<!-- String displayed in a toast when we successfully copy the donations subscriber id to the clipboard -->
Expand Down Expand Up @@ -5594,7 +5594,7 @@
<string name="ChangeNumberEnterPhoneNumberFragment__you_must_specify_your_old_phone_number">يجب عليك تحديد رقم هاتفك القديم.</string>
<string name="ChangeNumberEnterPhoneNumberFragment__you_must_specify_your_new_number_country_code">يجب عليك تحديد رمز الدولة لرقم هاتفك الجديد.</string>
<string name="ChangeNumberEnterPhoneNumberFragment__you_must_specify_your_new_phone_number">يجب عليك تحديد رقم هاتفك الجديد.</string>
<string name="ChangeNumberEnterPhoneNumberFragment__your_new_phone_number_can_not_be_same_as_your_old_phone_number">Your new phone number can not be same as your old phone number</string>
<string name="ChangeNumberEnterPhoneNumberFragment__your_new_phone_number_can_not_be_same_as_your_old_phone_number">لا يُمكن أن يكون رقم هاتفك الجديد مطابقًا لِرقمك القديم.</string>

<!-- ChangeNumberVerifyFragment -->
<string name="ChangeNumberVerifyFragment__change_number">تغيير الرقم</string>
Expand Down Expand Up @@ -8211,17 +8211,17 @@
<!-- Dialog title when a backup fails to be created -->
<string name="BackupAlertBottomSheet__backup_failed">فشل النسخ الاحتياطي</string>
<!-- Dialog title when a backup redemption fails -->
<string name="BackupAlertBottomSheet__couldnt_redeem_your_backups_subscription">Couldn\'t redeem your backups subscription</string>
<string name="BackupAlertBottomSheet__couldnt_redeem_your_backups_subscription">تعذّر استرداد اشتراك النسخ الاحتياطية الخاص بحسابك</string>
<!-- Dialog text for when a backup fails to be created and ways to fix it -->
<string name="BackupAlertBottomSheet__an_error_occurred">حدث خطأ منع إكمال عملية النسخ الاحتياطي. تأكَّد من أنك تستخدم آخر إصدار لسيجنال وحاوِل من جديد. إذا استمرت المشكلة، يُرجى الاتصال بقسم الدعم.</string>
<!-- Dialog action button that will allow you to check for any Signal version updates -->
<string name="BackupAlertBottomSheet__check_for_update">ابحث عن تحديث</string>
<!-- Backup redemption error sheet text line 1 -->
<string name="BackupAlertBottomSheet__too_many_devices_have_tried">Too many devices have tried to redeem your subscription this month. You may have:</string>
<string name="BackupAlertBottomSheet__too_many_devices_have_tried">اُستخدِمَت أجهزةٌ عديدة لاسترداد اشتراكك هذا الشهر. من المُحتمل أن:</string>
<!-- Backup redemption error sheet bullet point 1 -->
<string name="BackupAlertBottomSheet__reregistered_your_signal_account">Re-registered your Signal account too many times.</string>
<string name="BackupAlertBottomSheet__reregistered_your_signal_account">تكون قُمتَ بإعادة تسجيل حسابك على سيجنال أكثر من مرّة.</string>
<!-- Backup redemption error sheet bullet point 2 -->
<string name="BackupAlertBottomSheet__have_too_many_devices_using_the_same_subscription">Have too many devices using the same subscription.</string>
<string name="BackupAlertBottomSheet__have_too_many_devices_using_the_same_subscription">يكون هناك تجاوز في عدد الأجهزة التي تستخدم الاشتراك الحالي.</string>

<!-- BackupStatus -->
<!-- Status title when user does not have enough free space to download their media. Placeholder is required disk space. -->
Expand Down
Loading

0 comments on commit 28afd69

Please sign in to comment.