refactor: add in new recipient details for auto download based off the isTrusted flag for previous 1o1 chats, remove some legacy protobuf and recompile

pull/1403/head
0x330a 3 years ago
parent 8378565505
commit 516344280a

@ -66,7 +66,7 @@ class ConversationSettingsActivity: PassphraseRequiredActionBarActivity(), View.
binding.notificationSettings.setOnClickListener(this)
binding.back.setOnClickListener(this)
binding.autoDownloadMediaSwitch.setOnCheckedChangeListener { _, isChecked ->
viewModel.setTrusted(isChecked)
viewModel.setAutoDownloadAttachments(isChecked)
updateRecipientDisplay()
}
}
@ -108,7 +108,7 @@ class ConversationSettingsActivity: PassphraseRequiredActionBarActivity(), View.
)
// Set auto-download state
val trusted = viewModel.isTrusted()
val trusted = viewModel.autoDownloadAttachments()
binding.autoDownloadMediaSwitch.isChecked = trusted
// Set notification type

@ -26,15 +26,10 @@ class ConversationSettingsViewModel(
storage.setThreadPinned(threadId, !isPinned)
}
fun isTrusted() = recipient?.let { recipient ->
storage.isContactTrusted(recipient)
} ?: false
fun autoDownloadAttachments() = isTrusted()
fun autoDownloadAttachments() = recipient?.let { recipient -> storage.shouldAutoDownloadAttachments(recipient) } ?: false
fun setTrusted(isTrusted: Boolean) {
val recipient = recipient ?: return
storage.setContactTrusted(recipient, isTrusted)
fun setAutoDownloadAttachments(shouldDownload: Boolean) {
recipient?.let { recipient -> storage.setAutoDownloadAttachments(recipient, shouldDownload) }
}
fun isUserGroupAdmin(): Boolean = recipient?.let { recipient ->

@ -230,7 +230,7 @@ class VisibleMessageView : LinearLayout {
glide,
thread,
searchQuery,
message.isOutgoing || isGroupThread || (contact?.isTrusted ?: false)
message.isOutgoing || (thread.autoDownloadAttachments)
)
binding.messageContentView.delegate = delegate
onDoubleTap = { binding.messageContentView.onContentDoubleTap?.invoke() }

@ -62,13 +62,14 @@ public class RecipientDatabase extends Database {
private static final String UNIDENTIFIED_ACCESS_MODE = "unidentified_access_mode";
private static final String FORCE_SMS_SELECTION = "force_sms_selection";
private static final String NOTIFY_TYPE = "notify_type"; // all, mentions only, none
private static final String AUTO_DOWNLOAD = "auto_download"; // 1 / 0 flag for whether to auto-download in a conversation
private static final String[] RECIPIENT_PROJECTION = new String[] {
BLOCK, APPROVED, APPROVED_ME, NOTIFICATION, CALL_RINGTONE, VIBRATE, CALL_VIBRATE, MUTE_UNTIL, COLOR, SEEN_INVITE_REMINDER, DEFAULT_SUBSCRIPTION_ID, EXPIRE_MESSAGES, REGISTERED,
PROFILE_KEY, SYSTEM_DISPLAY_NAME, SYSTEM_PHOTO_URI, SYSTEM_PHONE_LABEL, SYSTEM_CONTACT_URI,
SIGNAL_PROFILE_NAME, SIGNAL_PROFILE_AVATAR, PROFILE_SHARING, NOTIFICATION_CHANNEL,
UNIDENTIFIED_ACCESS_MODE,
FORCE_SMS_SELECTION, NOTIFY_TYPE,
FORCE_SMS_SELECTION, NOTIFY_TYPE, AUTO_DOWNLOAD,
};
static final List<String> TYPED_RECIPIENT_PROJECTION = Stream.of(RECIPIENT_PROJECTION)
@ -107,6 +108,17 @@ public class RecipientDatabase extends Database {
"ADD COLUMN " + NOTIFY_TYPE + " INTEGER DEFAULT 0;";
}
public static String getCreateAutoDownloadCommand() {
return "ALTER TABLE "+ TABLE_NAME + " " +
"ADD COLUMN " + AUTO_DOWNLOAD + " INTEGER DEFAULT 0;";
}
public static String getUpdateAutoDownloadValuesCommand() {
return "UPDATE "+TABLE_NAME+" SET "+AUTO_DOWNLOAD+" = 1 "+
"WHERE "+ADDRESS+" IN (SELECT "+SessionContactDatabase.sessionContactTable+"."+SessionContactDatabase.sessionID+" "+
"FROM "+SessionContactDatabase.sessionContactTable+" WHERE ("+SessionContactDatabase.isTrusted+" != 0))";
}
public static String getCreateApprovedCommand() {
return "ALTER TABLE "+ TABLE_NAME + " " +
"ADD COLUMN " + APPROVED + " INTEGER DEFAULT 0;";
@ -170,30 +182,31 @@ public class RecipientDatabase extends Database {
}
Optional<RecipientSettings> getRecipientSettings(@NonNull Cursor cursor) {
boolean blocked = cursor.getInt(cursor.getColumnIndexOrThrow(BLOCK)) == 1;
boolean approved = cursor.getInt(cursor.getColumnIndexOrThrow(APPROVED)) == 1;
boolean approvedMe = cursor.getInt(cursor.getColumnIndexOrThrow(APPROVED_ME)) == 1;
String messageRingtone = cursor.getString(cursor.getColumnIndexOrThrow(NOTIFICATION));
String callRingtone = cursor.getString(cursor.getColumnIndexOrThrow(CALL_RINGTONE));
int messageVibrateState = cursor.getInt(cursor.getColumnIndexOrThrow(VIBRATE));
int callVibrateState = cursor.getInt(cursor.getColumnIndexOrThrow(CALL_VIBRATE));
long muteUntil = cursor.getLong(cursor.getColumnIndexOrThrow(MUTE_UNTIL));
int notifyType = cursor.getInt(cursor.getColumnIndexOrThrow(NOTIFY_TYPE));
String serializedColor = cursor.getString(cursor.getColumnIndexOrThrow(COLOR));
int defaultSubscriptionId = cursor.getInt(cursor.getColumnIndexOrThrow(DEFAULT_SUBSCRIPTION_ID));
int expireMessages = cursor.getInt(cursor.getColumnIndexOrThrow(EXPIRE_MESSAGES));
int registeredState = cursor.getInt(cursor.getColumnIndexOrThrow(REGISTERED));
String profileKeyString = cursor.getString(cursor.getColumnIndexOrThrow(PROFILE_KEY));
String systemDisplayName = cursor.getString(cursor.getColumnIndexOrThrow(SYSTEM_DISPLAY_NAME));
String systemContactPhoto = cursor.getString(cursor.getColumnIndexOrThrow(SYSTEM_PHOTO_URI));
String systemPhoneLabel = cursor.getString(cursor.getColumnIndexOrThrow(SYSTEM_PHONE_LABEL));
String systemContactUri = cursor.getString(cursor.getColumnIndexOrThrow(SYSTEM_CONTACT_URI));
String signalProfileName = cursor.getString(cursor.getColumnIndexOrThrow(SIGNAL_PROFILE_NAME));
String signalProfileAvatar = cursor.getString(cursor.getColumnIndexOrThrow(SIGNAL_PROFILE_AVATAR));
boolean profileSharing = cursor.getInt(cursor.getColumnIndexOrThrow(PROFILE_SHARING)) == 1;
String notificationChannel = cursor.getString(cursor.getColumnIndexOrThrow(NOTIFICATION_CHANNEL));
int unidentifiedAccessMode = cursor.getInt(cursor.getColumnIndexOrThrow(UNIDENTIFIED_ACCESS_MODE));
boolean forceSmsSelection = cursor.getInt(cursor.getColumnIndexOrThrow(FORCE_SMS_SELECTION)) == 1;
boolean blocked = cursor.getInt(cursor.getColumnIndexOrThrow(BLOCK)) == 1;
boolean approved = cursor.getInt(cursor.getColumnIndexOrThrow(APPROVED)) == 1;
boolean approvedMe = cursor.getInt(cursor.getColumnIndexOrThrow(APPROVED_ME)) == 1;
String messageRingtone = cursor.getString(cursor.getColumnIndexOrThrow(NOTIFICATION));
String callRingtone = cursor.getString(cursor.getColumnIndexOrThrow(CALL_RINGTONE));
int messageVibrateState = cursor.getInt(cursor.getColumnIndexOrThrow(VIBRATE));
int callVibrateState = cursor.getInt(cursor.getColumnIndexOrThrow(CALL_VIBRATE));
long muteUntil = cursor.getLong(cursor.getColumnIndexOrThrow(MUTE_UNTIL));
int notifyType = cursor.getInt(cursor.getColumnIndexOrThrow(NOTIFY_TYPE));
boolean autoDownloadAttachments = cursor.getInt(cursor.getColumnIndexOrThrow(AUTO_DOWNLOAD)) == 1;
String serializedColor = cursor.getString(cursor.getColumnIndexOrThrow(COLOR));
int defaultSubscriptionId = cursor.getInt(cursor.getColumnIndexOrThrow(DEFAULT_SUBSCRIPTION_ID));
int expireMessages = cursor.getInt(cursor.getColumnIndexOrThrow(EXPIRE_MESSAGES));
int registeredState = cursor.getInt(cursor.getColumnIndexOrThrow(REGISTERED));
String profileKeyString = cursor.getString(cursor.getColumnIndexOrThrow(PROFILE_KEY));
String systemDisplayName = cursor.getString(cursor.getColumnIndexOrThrow(SYSTEM_DISPLAY_NAME));
String systemContactPhoto = cursor.getString(cursor.getColumnIndexOrThrow(SYSTEM_PHOTO_URI));
String systemPhoneLabel = cursor.getString(cursor.getColumnIndexOrThrow(SYSTEM_PHONE_LABEL));
String systemContactUri = cursor.getString(cursor.getColumnIndexOrThrow(SYSTEM_CONTACT_URI));
String signalProfileName = cursor.getString(cursor.getColumnIndexOrThrow(SIGNAL_PROFILE_NAME));
String signalProfileAvatar = cursor.getString(cursor.getColumnIndexOrThrow(SIGNAL_PROFILE_AVATAR));
boolean profileSharing = cursor.getInt(cursor.getColumnIndexOrThrow(PROFILE_SHARING)) == 1;
String notificationChannel = cursor.getString(cursor.getColumnIndexOrThrow(NOTIFICATION_CHANNEL));
int unidentifiedAccessMode = cursor.getInt(cursor.getColumnIndexOrThrow(UNIDENTIFIED_ACCESS_MODE));
boolean forceSmsSelection = cursor.getInt(cursor.getColumnIndexOrThrow(FORCE_SMS_SELECTION)) == 1;
MaterialColor color;
byte[] profileKey = null;
@ -215,7 +228,7 @@ public class RecipientDatabase extends Database {
}
return Optional.of(new RecipientSettings(blocked, approved, approvedMe, muteUntil,
notifyType,
notifyType, autoDownloadAttachments,
Recipient.VibrateState.fromId(messageVibrateState),
Recipient.VibrateState.fromId(callVibrateState),
Util.uri(messageRingtone), Util.uri(callRingtone),

@ -11,7 +11,7 @@ import org.thoughtcrime.securesms.database.helpers.SQLCipherOpenHelper
class SessionContactDatabase(context: Context, helper: SQLCipherOpenHelper) : Database(context, helper) {
companion object {
private const val sessionContactTable = "session_contact_database"
const val sessionContactTable = "session_contact_database"
const val sessionID = "session_id"
const val name = "name"
const val nickname = "nickname"
@ -69,7 +69,6 @@ class SessionContactDatabase(context: Context, helper: SQLCipherOpenHelper) : Da
contentValues.put(profilePictureEncryptionKey, Base64.encodeBytes(it))
}
contentValues.put(threadID, contact.threadID)
contentValues.put(isTrusted, if (contact.isTrusted) 1 else 0)
database.insertOrUpdate(sessionContactTable, contentValues, "$sessionID = ?", arrayOf( contact.sessionID ))
notifyConversationListListeners()
}
@ -85,7 +84,6 @@ class SessionContactDatabase(context: Context, helper: SQLCipherOpenHelper) : Da
contact.profilePictureEncryptionKey = Base64.decode(it)
}
contact.threadID = cursor.getLong(threadID)
contact.isTrusted = cursor.getInt(isTrusted) != 0
return contact
}
@ -100,7 +98,6 @@ class SessionContactDatabase(context: Context, helper: SQLCipherOpenHelper) : Da
contact.profilePictureEncryptionKey = Base64.decode(it)
}
contact.threadID = cursor.getLong(cursor.getColumnIndexOrThrow(threadID))
contact.isTrusted = cursor.getInt(cursor.getColumnIndexOrThrow(isTrusted)) != 0
return contact
}

@ -685,19 +685,15 @@ class Storage(context: Context, helper: SQLCipherOpenHelper) : Database(context,
}
}
override fun isContactTrusted(recipient: Recipient): Boolean {
val sessionID = recipient.address.toString()
val contactDb = DatabaseComponent.get(context).sessionContactDatabase()
val contact = contactDb.getContactWithSessionID(sessionID) ?: return false
return contact.isTrusted
override fun shouldAutoDownloadAttachments(recipient: Recipient): Boolean {
TODO("Not yet implemented")
}
override fun setContactTrusted(recipient: Recipient, isTrusted: Boolean) {
val sessionID = recipient.address.toString()
val contactDb = DatabaseComponent.get(context).sessionContactDatabase()
val contact = contactDb.getContactWithSessionID(sessionID) ?: return
val threadID = DatabaseComponent.get(context).threadDatabase().getThreadIdIfExistsFor(recipient)
contactDb.setContactIsTrusted(contact, isTrusted, threadID)
override fun setAutoDownloadAttachments(
recipient: Recipient,
shouldAutoDownloadAttachments: Boolean
) {
TODO("Not yet implemented")
}
override fun getLastUpdated(threadID: Long): Long {

@ -75,9 +75,10 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper {
private static final int lokiV36 = 57;
private static final int lokiV37 = 58;
private static final int lokiV38 = 59;
private static final int lokiV39 = 60;
// Loki - onUpgrade(...) must be updated to use Loki version numbers if Signal makes any database changes
private static final int DATABASE_VERSION = lokiV38;
private static final int DATABASE_VERSION = lokiV39;
private static final String DATABASE_NAME = "signal.db";
private final Context context;
@ -414,6 +415,11 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper {
db.execSQL(EmojiSearchDatabase.CREATE_EMOJI_SEARCH_TABLE_COMMAND);
}
if (oldVersion < lokiV39) {
db.execSQL(RecipientDatabase.getCreateAutoDownloadCommand());
db.execSQL(RecipientDatabase.getUpdateAutoDownloadValuesCommand());
}
db.setTransactionSuccessful();
} finally {
db.endTransaction();

@ -163,8 +163,8 @@ interface StorageProtocol {
fun getRecipientForThread(threadId: Long): Recipient?
fun getRecipientSettings(address: Address): RecipientSettings?
fun addContacts(contacts: List<ConfigurationMessage.Contact>)
fun isContactTrusted(recipient: Recipient): Boolean
fun setContactTrusted(recipient: Recipient, isTrusted: Boolean)
fun shouldAutoDownloadAttachments(recipient: Recipient): Boolean
fun setAutoDownloadAttachments(recipient: Recipient, shouldAutoDownloadAttachments: Boolean)
// Attachments
fun getAttachmentDataUri(attachmentId: AttachmentId): Uri

@ -19,10 +19,6 @@ class Contact(val sessionID: String) {
* The ID of the thread associated with this contact.
*/
var threadID: Long? = null
/**
* This flag is used to determine whether we should auto-download files sent by this contact.
*/
var isTrusted = false
// region Name
/**

@ -99,7 +99,7 @@ class AttachmentDownloadJob(val attachmentID: Long, val databaseMessageID: Long)
handleFailure(Error.NoSender, null)
return
}
if (!threadRecipient.isGroupRecipient && (!contact.isTrusted && storage.getUserPublicKey() != sender)) {
if (!threadRecipient.isGroupRecipient && (!threadRecipient.autoDownloadAttachments && storage.getUserPublicKey() != sender)) {
// if we aren't receiving a group message, a message from ourselves (self-send) and the contact sending is not trusted:
// do not continue, but do not fail
return

@ -1,7 +1,5 @@
package org.session.libsession.messaging.messages
import com.google.protobuf.ByteString
import org.session.libsession.utilities.GroupUtil
import org.session.libsignal.protos.SignalServiceProtos
abstract class Message {
@ -28,12 +26,4 @@ abstract class Message {
abstract fun toProto(): SignalServiceProtos.Content?
fun setGroupContext(dataMessage: SignalServiceProtos.DataMessage.Builder) {
val groupProto = SignalServiceProtos.GroupContext.newBuilder()
val groupID = GroupUtil.doubleEncodeGroupID(recipient!!)
groupProto.id = ByteString.copyFrom(GroupUtil.getDecodedGroupIDAsData(groupID))
groupProto.type = SignalServiceProtos.GroupContext.Type.DELIVER
dataMessage.group = groupProto.build()
}
}

@ -172,8 +172,6 @@ class ClosedGroupControlMessage() : ControlMessage() {
val contentProto = SignalServiceProtos.Content.newBuilder()
val dataMessageProto = DataMessage.newBuilder()
dataMessageProto.closedGroupControlMessage = closedGroupControlMessage.build()
// Group context
setGroupContext(dataMessageProto)
contentProto.dataMessage = dataMessageProto.build()
return contentProto.build()
} catch (e: Exception) {

@ -1,9 +1,7 @@
package org.session.libsession.messaging.messages.control
import org.session.libsession.messaging.MessagingModuleConfiguration
import org.session.libsession.messaging.messages.visible.VisibleMessage
import org.session.libsignal.utilities.Log
import org.session.libsignal.protos.SignalServiceProtos
import org.session.libsignal.utilities.Log
class ExpirationTimerUpdate() : ControlMessage() {
/** In the case of a sync message, the public key of the person the message was targeted at.
@ -56,15 +54,6 @@ class ExpirationTimerUpdate() : ControlMessage() {
if (syncTarget != null) {
dataMessageProto.syncTarget = syncTarget
}
// Group context
if (MessagingModuleConfiguration.shared.storage.isClosedGroup(recipient!!)) {
try {
setGroupContext(dataMessageProto)
} catch(e: Exception) {
Log.w(VisibleMessage.TAG, "Couldn't construct visible message proto from: $this")
return null
}
}
val contentProto = SignalServiceProtos.Content.newBuilder()
try {
contentProto.dataMessage = dataMessageProto.build()

@ -129,15 +129,6 @@ class VisibleMessage : Message() {
Recipient.from(context, Address.fromSerialized(recipient!!), false).expireMessages
}
dataMessage.expireTimer = expiration
// Group context
if (storage.isClosedGroup(recipient!!)) {
try {
setGroupContext(dataMessage)
} catch (e: Exception) {
Log.w(TAG, "Couldn't construct visible message proto from: $this")
return null
}
}
// Sync target
if (syncTarget != null) {
dataMessage.syncTarget = syncTarget

@ -79,18 +79,19 @@ public class Recipient implements RecipientModifiedListener {
private @Nullable Uri systemContactPhoto;
private @Nullable Long groupAvatarId;
private Uri contactUri;
private @Nullable Uri messageRingtone = null;
private @Nullable Uri callRingtone = null;
public long mutedUntil = 0;
public int notifyType = 0;
private boolean blocked = false;
private boolean approved = false;
private boolean approvedMe = false;
private VibrateState messageVibrate = VibrateState.DEFAULT;
private VibrateState callVibrate = VibrateState.DEFAULT;
private int expireMessages = 0;
private Optional<Integer> defaultSubscriptionId = Optional.absent();
private @NonNull RegisteredState registered = RegisteredState.UNKNOWN;
private @Nullable Uri messageRingtone = null;
private @Nullable Uri callRingtone = null;
public long mutedUntil = 0;
public int notifyType = 0;
private boolean autoDownloadAttachments = false;
private boolean blocked = false;
private boolean approved = false;
private boolean approvedMe = false;
private VibrateState messageVibrate = VibrateState.DEFAULT;
private VibrateState callVibrate = VibrateState.DEFAULT;
private int expireMessages = 0;
private Optional<Integer> defaultSubscriptionId = Optional.absent();
private @NonNull RegisteredState registered = RegisteredState.UNKNOWN;
private @Nullable MaterialColor color;
private @Nullable byte[] profileKey;
@ -135,62 +136,64 @@ public class Recipient implements RecipientModifiedListener {
this.resolving = true;
if (stale != null) {
this.name = stale.name;
this.contactUri = stale.contactUri;
this.systemContactPhoto = stale.systemContactPhoto;
this.groupAvatarId = stale.groupAvatarId;
this.isLocalNumber = stale.isLocalNumber;
this.color = stale.color;
this.customLabel = stale.customLabel;
this.messageRingtone = stale.messageRingtone;
this.callRingtone = stale.callRingtone;
this.mutedUntil = stale.mutedUntil;
this.blocked = stale.blocked;
this.approved = stale.approved;
this.approvedMe = stale.approvedMe;
this.messageVibrate = stale.messageVibrate;
this.callVibrate = stale.callVibrate;
this.expireMessages = stale.expireMessages;
this.defaultSubscriptionId = stale.defaultSubscriptionId;
this.registered = stale.registered;
this.notificationChannel = stale.notificationChannel;
this.profileKey = stale.profileKey;
this.profileName = stale.profileName;
this.profileAvatar = stale.profileAvatar;
this.profileSharing = stale.profileSharing;
this.unidentifiedAccessMode = stale.unidentifiedAccessMode;
this.forceSmsSelection = stale.forceSmsSelection;
this.notifyType = stale.notifyType;
this.name = stale.name;
this.contactUri = stale.contactUri;
this.systemContactPhoto = stale.systemContactPhoto;
this.groupAvatarId = stale.groupAvatarId;
this.isLocalNumber = stale.isLocalNumber;
this.color = stale.color;
this.customLabel = stale.customLabel;
this.messageRingtone = stale.messageRingtone;
this.callRingtone = stale.callRingtone;
this.mutedUntil = stale.mutedUntil;
this.blocked = stale.blocked;
this.approved = stale.approved;
this.approvedMe = stale.approvedMe;
this.messageVibrate = stale.messageVibrate;
this.callVibrate = stale.callVibrate;
this.expireMessages = stale.expireMessages;
this.defaultSubscriptionId = stale.defaultSubscriptionId;
this.registered = stale.registered;
this.notificationChannel = stale.notificationChannel;
this.profileKey = stale.profileKey;
this.profileName = stale.profileName;
this.profileAvatar = stale.profileAvatar;
this.profileSharing = stale.profileSharing;
this.unidentifiedAccessMode = stale.unidentifiedAccessMode;
this.forceSmsSelection = stale.forceSmsSelection;
this.notifyType = stale.notifyType;
this.autoDownloadAttachments = stale.autoDownloadAttachments;
this.participants.clear();
this.participants.addAll(stale.participants);
}
if (details.isPresent()) {
this.name = details.get().name;
this.systemContactPhoto = details.get().systemContactPhoto;
this.groupAvatarId = details.get().groupAvatarId;
this.isLocalNumber = details.get().isLocalNumber;
this.color = details.get().color;
this.messageRingtone = details.get().messageRingtone;
this.callRingtone = details.get().callRingtone;
this.mutedUntil = details.get().mutedUntil;
this.blocked = details.get().blocked;
this.approved = details.get().approved;
this.approvedMe = details.get().approvedMe;
this.messageVibrate = details.get().messageVibrateState;
this.callVibrate = details.get().callVibrateState;
this.expireMessages = details.get().expireMessages;
this.defaultSubscriptionId = details.get().defaultSubscriptionId;
this.registered = details.get().registered;
this.notificationChannel = details.get().notificationChannel;
this.profileKey = details.get().profileKey;
this.profileName = details.get().profileName;
this.profileAvatar = details.get().profileAvatar;
this.profileSharing = details.get().profileSharing;
this.unidentifiedAccessMode = details.get().unidentifiedAccessMode;
this.forceSmsSelection = details.get().forceSmsSelection;
this.notifyType = details.get().notifyType;
this.name = details.get().name;
this.systemContactPhoto = details.get().systemContactPhoto;
this.groupAvatarId = details.get().groupAvatarId;
this.isLocalNumber = details.get().isLocalNumber;
this.color = details.get().color;
this.messageRingtone = details.get().messageRingtone;
this.callRingtone = details.get().callRingtone;
this.mutedUntil = details.get().mutedUntil;
this.blocked = details.get().blocked;
this.approved = details.get().approved;
this.approvedMe = details.get().approvedMe;
this.messageVibrate = details.get().messageVibrateState;
this.callVibrate = details.get().callVibrateState;
this.expireMessages = details.get().expireMessages;
this.defaultSubscriptionId = details.get().defaultSubscriptionId;
this.registered = details.get().registered;
this.notificationChannel = details.get().notificationChannel;
this.profileKey = details.get().profileKey;
this.profileName = details.get().profileName;
this.profileAvatar = details.get().profileAvatar;
this.profileSharing = details.get().profileSharing;
this.unidentifiedAccessMode = details.get().unidentifiedAccessMode;
this.forceSmsSelection = details.get().forceSmsSelection;
this.notifyType = details.get().notifyType;
this.autoDownloadAttachments = details.get().autoDownloadAttachments;
this.participants.clear();
this.participants.addAll(details.get().participants);
@ -201,32 +204,33 @@ public class Recipient implements RecipientModifiedListener {
public void onSuccess(RecipientDetails result) {
if (result != null) {
synchronized (Recipient.this) {
Recipient.this.name = result.name;
Recipient.this.contactUri = result.contactUri;
Recipient.this.systemContactPhoto = result.systemContactPhoto;
Recipient.this.groupAvatarId = result.groupAvatarId;
Recipient.this.isLocalNumber = result.isLocalNumber;
Recipient.this.color = result.color;
Recipient.this.customLabel = result.customLabel;
Recipient.this.messageRingtone = result.messageRingtone;
Recipient.this.callRingtone = result.callRingtone;
Recipient.this.mutedUntil = result.mutedUntil;
Recipient.this.blocked = result.blocked;
Recipient.this.approved = result.approved;
Recipient.this.approvedMe = result.approvedMe;
Recipient.this.messageVibrate = result.messageVibrateState;
Recipient.this.callVibrate = result.callVibrateState;
Recipient.this.expireMessages = result.expireMessages;
Recipient.this.defaultSubscriptionId = result.defaultSubscriptionId;
Recipient.this.registered = result.registered;
Recipient.this.notificationChannel = result.notificationChannel;
Recipient.this.profileKey = result.profileKey;
Recipient.this.profileName = result.profileName;
Recipient.this.profileAvatar = result.profileAvatar;
Recipient.this.profileSharing = result.profileSharing;
Recipient.this.unidentifiedAccessMode = result.unidentifiedAccessMode;
Recipient.this.forceSmsSelection = result.forceSmsSelection;
Recipient.this.notifyType = result.notifyType;
Recipient.this.name = result.name;
Recipient.this.contactUri = result.contactUri;
Recipient.this.systemContactPhoto = result.systemContactPhoto;
Recipient.this.groupAvatarId = result.groupAvatarId;
Recipient.this.isLocalNumber = result.isLocalNumber;
Recipient.this.color = result.color;
Recipient.this.customLabel = result.customLabel;
Recipient.this.messageRingtone = result.messageRingtone;
Recipient.this.callRingtone = result.callRingtone;
Recipient.this.mutedUntil = result.mutedUntil;
Recipient.this.blocked = result.blocked;
Recipient.this.approved = result.approved;
Recipient.this.approvedMe = result.approvedMe;
Recipient.this.messageVibrate = result.messageVibrateState;
Recipient.this.callVibrate = result.callVibrateState;
Recipient.this.expireMessages = result.expireMessages;
Recipient.this.defaultSubscriptionId = result.defaultSubscriptionId;
Recipient.this.registered = result.registered;
Recipient.this.notificationChannel = result.notificationChannel;
Recipient.this.profileKey = result.profileKey;
Recipient.this.profileName = result.profileName;
Recipient.this.profileAvatar = result.profileAvatar;
Recipient.this.profileSharing = result.profileSharing;
Recipient.this.unidentifiedAccessMode = result.unidentifiedAccessMode;
Recipient.this.forceSmsSelection = result.forceSmsSelection;
Recipient.this.notifyType = result.notifyType;
Recipient.this.autoDownloadAttachments = result.autoDownloadAttachments;
Recipient.this.participants.clear();
Recipient.this.participants.addAll(result.participants);
@ -251,34 +255,35 @@ public class Recipient implements RecipientModifiedListener {
}
Recipient(@NonNull Context context, @NonNull Address address, @NonNull RecipientDetails details) {
this.context = context;
this.address = address;
this.contactUri = details.contactUri;
this.name = details.name;
this.systemContactPhoto = details.systemContactPhoto;
this.groupAvatarId = details.groupAvatarId;
this.isLocalNumber = details.isLocalNumber;
this.color = details.color;
this.customLabel = details.customLabel;
this.messageRingtone = details.messageRingtone;
this.callRingtone = details.callRingtone;
this.mutedUntil = details.mutedUntil;
this.notifyType = details.notifyType;
this.blocked = details.blocked;
this.approved = details.approved;
this.approvedMe = details.approvedMe;
this.messageVibrate = details.messageVibrateState;
this.callVibrate = details.callVibrateState;
this.expireMessages = details.expireMessages;
this.defaultSubscriptionId = details.defaultSubscriptionId;
this.registered = details.registered;
this.notificationChannel = details.notificationChannel;
this.profileKey = details.profileKey;
this.profileName = details.profileName;
this.profileAvatar = details.profileAvatar;
this.profileSharing = details.profileSharing;
this.unidentifiedAccessMode = details.unidentifiedAccessMode;
this.forceSmsSelection = details.forceSmsSelection;
this.context = context;
this.address = address;
this.contactUri = details.contactUri;
this.name = details.name;
this.systemContactPhoto = details.systemContactPhoto;
this.groupAvatarId = details.groupAvatarId;
this.isLocalNumber = details.isLocalNumber;
this.color = details.color;
this.customLabel = details.customLabel;
this.messageRingtone = details.messageRingtone;
this.callRingtone = details.callRingtone;
this.mutedUntil = details.mutedUntil;
this.notifyType = details.notifyType;
this.autoDownloadAttachments = details.autoDownloadAttachments;
this.blocked = details.blocked;
this.approved = details.approved;
this.approvedMe = details.approvedMe;
this.messageVibrate = details.messageVibrateState;
this.callVibrate = details.callVibrateState;
this.expireMessages = details.expireMessages;
this.defaultSubscriptionId = details.defaultSubscriptionId;
this.registered = details.registered;
this.notificationChannel = details.notificationChannel;
this.profileKey = details.profileKey;
this.profileName = details.profileName;
this.profileAvatar = details.profileAvatar;
this.profileSharing = details.profileSharing;
this.unidentifiedAccessMode = details.unidentifiedAccessMode;
this.forceSmsSelection = details.forceSmsSelection;
this.participants.addAll(details.participants);
this.resolving = false;
@ -581,6 +586,18 @@ public class Recipient implements RecipientModifiedListener {
notifyListeners();
}
public boolean getAutoDownloadAttachments() {
return autoDownloadAttachments;
}
public void setAutoDownloadAttachments(boolean autoDownloadAttachments) {
synchronized (this) {
this.autoDownloadAttachments = autoDownloadAttachments;
}
notifyListeners();
}
public synchronized boolean isBlocked() {
return blocked;
}
@ -829,6 +846,7 @@ public class Recipient implements RecipientModifiedListener {
private final boolean approvedMe;
private final long muteUntil;
private final int notifyType;
private final boolean autoDownloadAttachments;
private final VibrateState messageVibrateState;
private final VibrateState callVibrateState;
private final Uri messageRingtone;
@ -851,6 +869,7 @@ public class Recipient implements RecipientModifiedListener {
public RecipientSettings(boolean blocked, boolean approved, boolean approvedMe, long muteUntil,
int notifyType,
boolean autoDownloadAttachments,
@NonNull VibrateState messageVibrateState,
@NonNull VibrateState callVibrateState,
@Nullable Uri messageRingtone,
@ -871,30 +890,31 @@ public class Recipient implements RecipientModifiedListener {
@NonNull UnidentifiedAccessMode unidentifiedAccessMode,
boolean forceSmsSelection)
{
this.blocked = blocked;
this.approved = approved;
this.approvedMe = approvedMe;
this.muteUntil = muteUntil;
this.notifyType = notifyType;
this.messageVibrateState = messageVibrateState;
this.callVibrateState = callVibrateState;
this.messageRingtone = messageRingtone;
this.callRingtone = callRingtone;
this.color = color;
this.defaultSubscriptionId = defaultSubscriptionId;
this.expireMessages = expireMessages;
this.registered = registered;
this.profileKey = profileKey;
this.systemDisplayName = systemDisplayName;
this.systemContactPhoto = systemContactPhoto;
this.systemPhoneLabel = systemPhoneLabel;
this.systemContactUri = systemContactUri;
this.signalProfileName = signalProfileName;
this.signalProfileAvatar = signalProfileAvatar;
this.profileSharing = profileSharing;
this.notificationChannel = notificationChannel;
this.unidentifiedAccessMode = unidentifiedAccessMode;
this.forceSmsSelection = forceSmsSelection;
this.blocked = blocked;
this.approved = approved;
this.approvedMe = approvedMe;
this.muteUntil = muteUntil;
this.notifyType = notifyType;
this.autoDownloadAttachments = autoDownloadAttachments;
this.messageVibrateState = messageVibrateState;
this.callVibrateState = callVibrateState;
this.messageRingtone = messageRingtone;
this.callRingtone = callRingtone;
this.color = color;
this.defaultSubscriptionId = defaultSubscriptionId;
this.expireMessages = expireMessages;
this.registered = registered;
this.profileKey = profileKey;
this.systemDisplayName = systemDisplayName;
this.systemContactPhoto = systemContactPhoto;
this.systemPhoneLabel = systemPhoneLabel;
this.systemContactUri = systemContactUri;
this.signalProfileName = signalProfileName;
this.signalProfileAvatar = signalProfileAvatar;
this.profileSharing = profileSharing;
this.notificationChannel = notificationChannel;
this.unidentifiedAccessMode = unidentifiedAccessMode;
this.forceSmsSelection = forceSmsSelection;
}
public @Nullable MaterialColor getColor() {
@ -921,6 +941,10 @@ public class Recipient implements RecipientModifiedListener {
return notifyType;
}
public boolean getAutoDownloadAttachments() {
return autoDownloadAttachments;
}
public @NonNull VibrateState getMessageVibrateState() {
return messageVibrateState;
}

@ -159,6 +159,7 @@ class RecipientProvider {
@Nullable final Uri callRingtone;
final long mutedUntil;
final int notifyType;
final boolean autoDownloadAttachments;
@Nullable final VibrateState messageVibrateState;
@Nullable final VibrateState callVibrateState;
final boolean blocked;
@ -191,6 +192,7 @@ class RecipientProvider {
this.callRingtone = settings != null ? settings.getCallRingtone() : null;
this.mutedUntil = settings != null ? settings.getMuteUntil() : 0;
this.notifyType = settings != null ? settings.getNotifyType() : 0;
this.autoDownloadAttachments = settings != null && settings.getAutoDownloadAttachments();
this.messageVibrateState = settings != null ? settings.getMessageVibrateState() : null;
this.callVibrateState = settings != null ? settings.getCallVibrateState() : null;
this.blocked = settings != null && settings.isBlocked();

@ -171,7 +171,6 @@ message DataMessage {
optional string body = 1;
repeated AttachmentPointer attachments = 2;
optional GroupContext group = 3;
optional uint32 flags = 4;
optional uint32 expireTimer = 5;
optional bytes profileKey = 6;
@ -287,24 +286,4 @@ message AttachmentPointer {
optional uint32 height = 10;
optional string caption = 11;
optional string url = 101;
}
message GroupContext {
enum Type {
UNKNOWN = 0;
UPDATE = 1;
DELIVER = 2;
QUIT = 3;
REQUEST_INFO = 4;
}
// @required
optional bytes id = 1;
// @required
optional Type type = 2;
optional string name = 3;
repeated string members = 4;
optional AttachmentPointer avatar = 5;
repeated string admins = 6;
}
}
Loading…
Cancel
Save