use of org.thoughtcrime.securesms.database.GroupDatabase.GroupRecord in project Signal-Android by WhisperSystems.
the class ConversationActivity method isActiveGroup.
private boolean isActiveGroup() {
if (!isGroupConversation())
return false;
try {
byte[] groupId = GroupUtil.getDecodedId(getRecipients().getPrimaryRecipient().getNumber());
GroupRecord record = DatabaseFactory.getGroupDatabase(this).getGroup(groupId);
return record != null && record.isActive();
} catch (IOException e) {
Log.w("ConversationActivity", e);
return false;
}
}
use of org.thoughtcrime.securesms.database.GroupDatabase.GroupRecord in project Signal-Android by WhisperSystems.
the class ContactAccessor method getNumbersForThreadSearchFilter.
public List<String> getNumbersForThreadSearchFilter(Context context, String constraint) {
LinkedList<String> numberList = new LinkedList<>();
Cursor cursor = null;
try {
cursor = context.getContentResolver().query(Uri.withAppendedPath(Phone.CONTENT_FILTER_URI, Uri.encode(constraint)), null, null, null, null);
while (cursor != null && cursor.moveToNext()) {
numberList.add(cursor.getString(cursor.getColumnIndexOrThrow(Phone.NUMBER)));
}
} finally {
if (cursor != null)
cursor.close();
}
GroupDatabase.Reader reader = null;
GroupRecord record;
try {
reader = DatabaseFactory.getGroupDatabase(context).getGroupsFilteredByTitle(constraint);
while ((record = reader.getNext()) != null) {
numberList.add(record.getEncodedId());
}
} finally {
if (reader != null)
reader.close();
}
return numberList;
}
use of org.thoughtcrime.securesms.database.GroupDatabase.GroupRecord in project Signal-Android by WhisperSystems.
the class GroupMessageProcessor method process.
@Nullable
public static Long process(@NonNull Context context, @NonNull MasterSecretUnion masterSecret, @NonNull SignalServiceEnvelope envelope, @NonNull SignalServiceDataMessage message, boolean outgoing) {
if (!message.getGroupInfo().isPresent() || message.getGroupInfo().get().getGroupId() == null) {
Log.w(TAG, "Received group message with no id! Ignoring...");
return null;
}
GroupDatabase database = DatabaseFactory.getGroupDatabase(context);
SignalServiceGroup group = message.getGroupInfo().get();
byte[] id = group.getGroupId();
GroupRecord record = database.getGroup(id);
if (record != null && group.getType() == Type.UPDATE) {
return handleGroupUpdate(context, masterSecret, envelope, group, record, outgoing);
} else if (record == null && group.getType() == Type.UPDATE) {
return handleGroupCreate(context, masterSecret, envelope, group, outgoing);
} else if (record != null && group.getType() == Type.QUIT) {
return handleGroupLeave(context, masterSecret, envelope, group, record, outgoing);
} else if (record != null && group.getType() == Type.REQUEST_INFO) {
return handleGroupInfoRequest(context, envelope, group, record);
} else {
Log.w(TAG, "Received unknown type, ignoring...");
return null;
}
}
use of org.thoughtcrime.securesms.database.GroupDatabase.GroupRecord in project Signal-Android by WhisperSystems.
the class PushGroupUpdateJob method onRun.
@Override
public void onRun() throws IOException, UntrustedIdentityException {
SignalServiceMessageSender messageSender = messageSenderFactory.create();
GroupDatabase groupDatabase = DatabaseFactory.getGroupDatabase(context);
GroupRecord record = groupDatabase.getGroup(groupId);
SignalServiceAttachment avatar = null;
if (record == null) {
Log.w(TAG, "No information for group record info request: " + new String(groupId));
return;
}
if (record.getAvatar() != null) {
avatar = SignalServiceAttachmentStream.newStreamBuilder().withContentType("image/jpeg").withStream(new ByteArrayInputStream(record.getAvatar())).withLength(record.getAvatar().length).build();
}
SignalServiceGroup groupContext = SignalServiceGroup.newBuilder(Type.UPDATE).withAvatar(avatar).withId(groupId).withMembers(record.getMembers()).withName(record.getTitle()).build();
SignalServiceDataMessage message = SignalServiceDataMessage.newBuilder().asGroupMessage(groupContext).withTimestamp(System.currentTimeMillis()).build();
messageSender.sendMessage(new SignalServiceAddress(source), message);
}
Aggregations