use of org.thoughtcrime.securesms.database.model.databaseprotos.DecryptedGroupV2Context in project Signal-Android by WhisperSystems.
the class MessageRecord method getGv2AddInviteState.
@Nullable
public InviteAddState getGv2AddInviteState() {
DecryptedGroupV2Context decryptedGroupV2Context = getDecryptedGroupV2Context();
if (decryptedGroupV2Context == null) {
return null;
}
DecryptedGroup groupState = decryptedGroupV2Context.getGroupState();
boolean invited = DecryptedGroupUtil.findPendingByUuid(groupState.getPendingMembersList(), Recipient.self().requireServiceId().uuid()).isPresent();
if (decryptedGroupV2Context.hasChange()) {
UUID changeEditor = UuidUtil.fromByteStringOrNull(decryptedGroupV2Context.getChange().getEditor());
if (changeEditor != null) {
return new InviteAddState(invited, changeEditor);
}
}
Log.w(TAG, "GV2 Message editor could not be determined");
return null;
}
use of org.thoughtcrime.securesms.database.model.databaseprotos.DecryptedGroupV2Context in project Signal-Android by WhisperSystems.
the class MessageRecord method getDecryptedGroupV2Context.
@Nullable
private DecryptedGroupV2Context getDecryptedGroupV2Context() {
if (!isGroupUpdate() || !isGroupV2()) {
return null;
}
DecryptedGroupV2Context decryptedGroupV2Context;
try {
byte[] decoded = Base64.decode(getBody());
decryptedGroupV2Context = DecryptedGroupV2Context.parseFrom(decoded);
} catch (IOException e) {
Log.w(TAG, "GV2 Message update detail could not be read", e);
decryptedGroupV2Context = null;
}
return decryptedGroupV2Context;
}
use of org.thoughtcrime.securesms.database.model.databaseprotos.DecryptedGroupV2Context in project Signal-Android by signalapp.
the class MessageRecord method getGv2AddInviteState.
@Nullable
public InviteAddState getGv2AddInviteState() {
DecryptedGroupV2Context decryptedGroupV2Context = getDecryptedGroupV2Context();
if (decryptedGroupV2Context == null) {
return null;
}
DecryptedGroup groupState = decryptedGroupV2Context.getGroupState();
boolean invited = DecryptedGroupUtil.findPendingByUuid(groupState.getPendingMembersList(), Recipient.self().requireServiceId().uuid()).isPresent();
if (decryptedGroupV2Context.hasChange()) {
UUID changeEditor = UuidUtil.fromByteStringOrNull(decryptedGroupV2Context.getChange().getEditor());
if (changeEditor != null) {
return new InviteAddState(invited, changeEditor);
}
}
Log.w(TAG, "GV2 Message editor could not be determined");
return null;
}
use of org.thoughtcrime.securesms.database.model.databaseprotos.DecryptedGroupV2Context in project Signal-Android by signalapp.
the class MessageRecord method getGv2ChangeDescription.
@NonNull
public static UpdateDescription getGv2ChangeDescription(@NonNull Context context, @NonNull String body) {
try {
ShortStringDescriptionStrategy descriptionStrategy = new ShortStringDescriptionStrategy(context);
byte[] decoded = Base64.decode(body);
DecryptedGroupV2Context decryptedGroupV2Context = DecryptedGroupV2Context.parseFrom(decoded);
GroupsV2UpdateMessageProducer updateMessageProducer = new GroupsV2UpdateMessageProducer(context, descriptionStrategy, Recipient.self().requireServiceId().uuid());
if (decryptedGroupV2Context.hasChange() && (decryptedGroupV2Context.getGroupState().getRevision() != 0 || decryptedGroupV2Context.hasPreviousGroupState())) {
return UpdateDescription.concatWithNewLines(updateMessageProducer.describeChanges(decryptedGroupV2Context.getPreviousGroupState(), decryptedGroupV2Context.getChange()));
} else {
List<UpdateDescription> newGroupDescriptions = new ArrayList<>();
newGroupDescriptions.add(updateMessageProducer.describeNewGroup(decryptedGroupV2Context.getGroupState(), decryptedGroupV2Context.getChange()));
if (decryptedGroupV2Context.getChange().hasNewTimer()) {
updateMessageProducer.describeNewTimer(decryptedGroupV2Context.getChange(), newGroupDescriptions);
}
if (selfCreatedGroup(decryptedGroupV2Context.getChange())) {
newGroupDescriptions.add(staticUpdateDescription(context.getString(R.string.MessageRecord_invite_friends_to_this_group), 0));
}
return UpdateDescription.concatWithNewLines(newGroupDescriptions);
}
} catch (IOException | IllegalArgumentException e) {
Log.w(TAG, "GV2 Message update detail could not be read", e);
return staticUpdateDescription(context.getString(R.string.MessageRecord_group_updated), R.drawable.ic_update_group_16);
}
}
use of org.thoughtcrime.securesms.database.model.databaseprotos.DecryptedGroupV2Context in project Signal-Android by signalapp.
the class GroupV2UpdateMessageUtilTest method isJustAGroupLeave_whenEditorIsRemovedAndOtherChanges_shouldReturnFalse.
@Test
public void isJustAGroupLeave_whenEditorIsRemovedAndOtherChanges_shouldReturnFalse() {
// GIVEN
UUID alice = UUID.randomUUID();
UUID bob = UUID.randomUUID();
DecryptedGroupChange change = ChangeBuilder.changeBy(alice).deleteMember(alice).addMember(bob).build();
DecryptedGroupV2Context context = DecryptedGroupV2Context.newBuilder().setContext(SignalServiceProtos.GroupContextV2.newBuilder().setMasterKey(ByteString.copyFrom(randomBytes()))).setChange(change).build();
MessageGroupContext messageGroupContext = new MessageGroupContext(context);
// WHEN
boolean isJustAGroupLeave = GroupV2UpdateMessageUtil.isJustAGroupLeave(messageGroupContext);
// THEN
assertFalse(isJustAGroupLeave);
}
Aggregations