Merge branch 'dev' into group-leaving

This commit is contained in:
Niels Andriesse 2020-02-21 11:22:24 +07:00
commit f46354392c
4 changed files with 13 additions and 15 deletions

View File

@ -725,26 +725,26 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
private void handleGroupSyncMessage(@NonNull SignalServiceContent content, @NonNull SignalServiceAttachment groupMessage) { private void handleGroupSyncMessage(@NonNull SignalServiceContent content, @NonNull SignalServiceAttachment groupMessage) {
if (groupMessage.isStream()) { if (groupMessage.isStream()) {
Log.d("Loki", "Received group sync message"); Log.d("Loki", "Received a group sync message.");
try { try {
InputStream in = groupMessage.asStream().getInputStream(); InputStream in = groupMessage.asStream().getInputStream();
DeviceGroupsInputStream groupsInputStream = new DeviceGroupsInputStream(in); DeviceGroupsInputStream groupsInputStream = new DeviceGroupsInputStream(in);
List<DeviceGroup> groups = groupsInputStream.readAll(); List<DeviceGroup> groups = groupsInputStream.readAll();
for (DeviceGroup group : groups) { for (DeviceGroup group : groups) {
SignalServiceGroup serviceGroup = new SignalServiceGroup( SignalServiceGroup serviceGroup = new SignalServiceGroup(
SignalServiceGroup.Type.UPDATE, SignalServiceGroup.Type.UPDATE,
group.getId(), group.getId(),
SignalServiceGroup.GroupType.SIGNAL, SignalServiceGroup.GroupType.SIGNAL,
group.getName().orNull(), group.getName().orNull(),
group.getMembers(), group.getMembers(),
group.getAvatar().orNull(), group.getAvatar().orNull(),
group.getAdmins() group.getAdmins()
); );
SignalServiceDataMessage dataMessage = new SignalServiceDataMessage(content.getTimestamp(), serviceGroup, null, null); SignalServiceDataMessage dataMessage = new SignalServiceDataMessage(content.getTimestamp(), serviceGroup, null, null);
GroupMessageProcessor.process(context, content, dataMessage, false); GroupMessageProcessor.process(context, content, dataMessage, false);
} }
} catch (Exception e) { } catch (Exception e) {
Log.d("Loki", "Failed to sync group: " + e); Log.d("Loki", "Failed to sync group due to error: " + e + ".");
} }
} }
} }

View File

@ -128,7 +128,7 @@ fun sendDeviceLinkMessage(context: Context, hexEncodedPublicKey: String, deviceL
} }
Promise.ofSuccess(Unit) Promise.ofSuccess(Unit)
} catch (e: Exception) { } catch (e: Exception) {
Log.d("Loki", "Failed to send device link message to $hexEncodedPublicKey: $e") Log.d("Loki", "Failed to send device link message to: $hexEncodedPublicKey due to error: $e.")
Promise.ofFail(e) Promise.ofFail(e)
} }
} }

View File

@ -22,7 +22,6 @@ import org.thoughtcrime.securesms.loki.redesign.dialogs.*
import org.thoughtcrime.securesms.loki.signAndSendDeviceLinkMessage import org.thoughtcrime.securesms.loki.signAndSendDeviceLinkMessage
import org.thoughtcrime.securesms.sms.MessageSender import org.thoughtcrime.securesms.sms.MessageSender
import org.thoughtcrime.securesms.util.TextSecurePreferences import org.thoughtcrime.securesms.util.TextSecurePreferences
import org.thoughtcrime.securesms.util.Util
import org.whispersystems.signalservice.loki.api.DeviceLink import org.whispersystems.signalservice.loki.api.DeviceLink
import org.whispersystems.signalservice.loki.api.LokiFileServerAPI import org.whispersystems.signalservice.loki.api.LokiFileServerAPI
import java.util.* import java.util.*
@ -153,12 +152,11 @@ class LinkedDevicesActivity : PassphraseRequiredActionBarActivity, LoaderManager
MessageSender.syncAllGroups(this@LinkedDevicesActivity) MessageSender.syncAllGroups(this@LinkedDevicesActivity)
MessageSender.syncAllContacts(this@LinkedDevicesActivity, Address.fromSerialized(deviceLink.slaveHexEncodedPublicKey)) MessageSender.syncAllContacts(this@LinkedDevicesActivity, Address.fromSerialized(deviceLink.slaveHexEncodedPublicKey))
} }
}.failUi {
Toast.makeText(this, "Couldn't link device", Toast.LENGTH_LONG).show()
}.fail { }.fail {
LokiFileServerAPI.shared.removeDeviceLink(deviceLink) // If this fails we have a problem LokiFileServerAPI.shared.removeDeviceLink(deviceLink) // If this fails we have a problem
DatabaseFactory.getLokiPreKeyBundleDatabase(this).removePreKeyBundle(deviceLink.slaveHexEncodedPublicKey) DatabaseFactory.getLokiPreKeyBundleDatabase(this).removePreKeyBundle(deviceLink.slaveHexEncodedPublicKey)
Util.runOnMain {
Toast.makeText(this, "Couldn't link device", Toast.LENGTH_LONG).show()
}
} }
}.failUi { }.failUi {
DatabaseFactory.getLokiPreKeyBundleDatabase(this).removePreKeyBundle(deviceLink.slaveHexEncodedPublicKey) DatabaseFactory.getLokiPreKeyBundleDatabase(this).removePreKeyBundle(deviceLink.slaveHexEncodedPublicKey)

View File

@ -55,7 +55,7 @@ class LokiPreKeyBundleDatabase(context: Context, helper: SQLCipherOpenHelper) :
failureCount += 1 failureCount += 1
} }
} }
Log.w("Loki", "Failed to generate a valid PreKeyBundle for $hexEncodedPublicKey") Log.w("Loki", "Failed to generate a valid pre key bundle for: $hexEncodedPublicKey.")
return null return null
} }