mirror of
https://github.com/oxen-io/session-android.git
synced 2025-10-24 13:19:12 +00:00
Join group information into conversation list query
// FREEBIE
This commit is contained in:
@@ -8,6 +8,7 @@ import android.util.Log;
|
||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.database.GroupDatabase;
|
||||
import org.thoughtcrime.securesms.database.GroupDatabase.GroupRecord;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.jobs.requirements.MasterSecretRequirement;
|
||||
import org.thoughtcrime.securesms.mms.AttachmentStreamUriLoader.AttachmentModel;
|
||||
@@ -55,18 +56,18 @@ public class AvatarDownloadJob extends MasterSecretJob implements InjectableType
|
||||
|
||||
@Override
|
||||
public void onRun(MasterSecret masterSecret) throws IOException {
|
||||
String encodeId = GroupUtil.getEncodedId(groupId, false);
|
||||
GroupDatabase database = DatabaseFactory.getGroupDatabase(context);
|
||||
GroupDatabase.GroupRecord record = database.getGroup(encodeId);
|
||||
File attachment = null;
|
||||
String encodeId = GroupUtil.getEncodedId(groupId, false);
|
||||
GroupDatabase database = DatabaseFactory.getGroupDatabase(context);
|
||||
Optional<GroupRecord> record = database.getGroup(encodeId);
|
||||
File attachment = null;
|
||||
|
||||
try {
|
||||
if (record != null) {
|
||||
long avatarId = record.getAvatarId();
|
||||
String contentType = record.getAvatarContentType();
|
||||
byte[] key = record.getAvatarKey();
|
||||
String relay = record.getRelay();
|
||||
Optional<byte[]> digest = Optional.fromNullable(record.getAvatarDigest());
|
||||
if (record.isPresent()) {
|
||||
long avatarId = record.get().getAvatarId();
|
||||
String contentType = record.get().getAvatarContentType();
|
||||
byte[] key = record.get().getAvatarKey();
|
||||
String relay = record.get().getRelay();
|
||||
Optional<byte[]> digest = Optional.fromNullable(record.get().getAvatarDigest());
|
||||
Optional<String> fileName = Optional.absent();
|
||||
|
||||
if (avatarId == -1 || key == null) {
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.thoughtcrime.securesms.dependencies.SignalCommunicationModule.SignalM
|
||||
import org.thoughtcrime.securesms.util.GroupUtil;
|
||||
import org.whispersystems.jobqueue.JobParameters;
|
||||
import org.whispersystems.jobqueue.requirements.NetworkRequirement;
|
||||
import org.whispersystems.libsignal.util.guava.Optional;
|
||||
import org.whispersystems.signalservice.api.SignalServiceMessageSender;
|
||||
import org.whispersystems.signalservice.api.crypto.UntrustedIdentityException;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceAttachment;
|
||||
@@ -60,7 +61,7 @@ public class PushGroupUpdateJob extends ContextJob implements InjectableType {
|
||||
public void onRun() throws IOException, UntrustedIdentityException {
|
||||
SignalServiceMessageSender messageSender = messageSenderFactory.create();
|
||||
GroupDatabase groupDatabase = DatabaseFactory.getGroupDatabase(context);
|
||||
GroupRecord record = groupDatabase.getGroup(GroupUtil.getEncodedId(groupId, false));
|
||||
Optional<GroupRecord> record = groupDatabase.getGroup(GroupUtil.getEncodedId(groupId, false));
|
||||
SignalServiceAttachment avatar = null;
|
||||
|
||||
if (record == null) {
|
||||
@@ -68,17 +69,17 @@ public class PushGroupUpdateJob extends ContextJob implements InjectableType {
|
||||
return;
|
||||
}
|
||||
|
||||
if (record.getAvatar() != null) {
|
||||
if (record.get().getAvatar() != null) {
|
||||
avatar = SignalServiceAttachmentStream.newStreamBuilder()
|
||||
.withContentType("image/jpeg")
|
||||
.withStream(new ByteArrayInputStream(record.getAvatar()))
|
||||
.withLength(record.getAvatar().length)
|
||||
.withStream(new ByteArrayInputStream(record.get().getAvatar()))
|
||||
.withLength(record.get().getAvatar().length)
|
||||
.build();
|
||||
}
|
||||
|
||||
List<String> members = new LinkedList<>();
|
||||
|
||||
for (Address member : record.getMembers()) {
|
||||
for (Address member : record.get().getMembers()) {
|
||||
members.add(member.serialize());
|
||||
}
|
||||
|
||||
@@ -86,7 +87,7 @@ public class PushGroupUpdateJob extends ContextJob implements InjectableType {
|
||||
.withAvatar(avatar)
|
||||
.withId(groupId)
|
||||
.withMembers(members)
|
||||
.withName(record.getTitle())
|
||||
.withName(record.get().getTitle())
|
||||
.build();
|
||||
|
||||
SignalServiceDataMessage message = SignalServiceDataMessage.newBuilder()
|
||||
|
||||
Reference in New Issue
Block a user