Create local messages for group join request/cancel events.
This commit is contained in:
parent
e273f914b6
commit
1d14a90ac3
1 changed files with 45 additions and 17 deletions
|
@ -44,6 +44,7 @@ import org.thoughtcrime.securesms.jobs.ProfileUploadJob;
|
||||||
import org.thoughtcrime.securesms.jobs.PushGroupSilentUpdateSendJob;
|
import org.thoughtcrime.securesms.jobs.PushGroupSilentUpdateSendJob;
|
||||||
import org.thoughtcrime.securesms.jobs.RequestGroupV2InfoJob;
|
import org.thoughtcrime.securesms.jobs.RequestGroupV2InfoJob;
|
||||||
import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
||||||
|
import org.thoughtcrime.securesms.mms.MmsException;
|
||||||
import org.thoughtcrime.securesms.mms.OutgoingGroupUpdateMessage;
|
import org.thoughtcrime.securesms.mms.OutgoingGroupUpdateMessage;
|
||||||
import org.thoughtcrime.securesms.profiles.AvatarHelper;
|
import org.thoughtcrime.securesms.profiles.AvatarHelper;
|
||||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||||
|
@ -854,8 +855,10 @@ final class GroupManagerV2 {
|
||||||
} else if (requestToJoin) {
|
} else if (requestToJoin) {
|
||||||
Log.i(TAG, "Requested to join, cannot send update");
|
Log.i(TAG, "Requested to join, cannot send update");
|
||||||
|
|
||||||
|
RecipientAndThread recipientAndThread = sendGroupUpdate(groupMasterKey, new GroupMutation(null, decryptedChange, decryptedGroup), signedGroupChange, false);
|
||||||
|
|
||||||
return new GroupManager.GroupActionResult(groupRecipient,
|
return new GroupManager.GroupActionResult(groupRecipient,
|
||||||
SignalDatabase.threads().getThreadIdIfExistsFor(groupRecipientId),
|
recipientAndThread.threadId,
|
||||||
0,
|
0,
|
||||||
Collections.emptyList());
|
Collections.emptyList());
|
||||||
} else {
|
} else {
|
||||||
|
@ -1075,6 +1078,8 @@ final class GroupManagerV2 {
|
||||||
DecryptedGroup newGroup = DecryptedGroupUtil.applyWithoutRevisionCheck(decryptedGroup, decryptedChange);
|
DecryptedGroup newGroup = DecryptedGroupUtil.applyWithoutRevisionCheck(decryptedGroup, decryptedChange);
|
||||||
|
|
||||||
groupDatabase.update(groupId, resetRevision(newGroup, decryptedGroup.getRevision()));
|
groupDatabase.update(groupId, resetRevision(newGroup, decryptedGroup.getRevision()));
|
||||||
|
|
||||||
|
sendGroupUpdate(groupMasterKey, new GroupMutation(decryptedGroup, decryptedChange, newGroup), signedGroupChange, false);
|
||||||
} catch (VerificationFailedException | InvalidGroupStateException | NotAbleToApplyGroupV2ChangeException e) {
|
} catch (VerificationFailedException | InvalidGroupStateException | NotAbleToApplyGroupV2ChangeException e) {
|
||||||
throw new GroupChangeFailedException(e);
|
throw new GroupChangeFailedException(e);
|
||||||
}
|
}
|
||||||
|
@ -1131,29 +1136,52 @@ final class GroupManagerV2 {
|
||||||
@NonNull GroupMutation groupMutation,
|
@NonNull GroupMutation groupMutation,
|
||||||
@Nullable GroupChange signedGroupChange)
|
@Nullable GroupChange signedGroupChange)
|
||||||
{
|
{
|
||||||
GroupId.V2 groupId = GroupId.v2(masterKey);
|
return sendGroupUpdate(masterKey, groupMutation, signedGroupChange, true);
|
||||||
Recipient groupRecipient = Recipient.externalGroupExact(context, groupId);
|
}
|
||||||
DecryptedGroupV2Context decryptedGroupV2Context = GroupProtoUtil.createDecryptedGroupV2Context(masterKey, groupMutation, signedGroupChange);
|
|
||||||
OutgoingGroupUpdateMessage outgoingMessage = new OutgoingGroupUpdateMessage(groupRecipient,
|
private @NonNull RecipientAndThread sendGroupUpdate(@NonNull GroupMasterKey masterKey,
|
||||||
decryptedGroupV2Context,
|
@NonNull GroupMutation groupMutation,
|
||||||
null,
|
@Nullable GroupChange signedGroupChange,
|
||||||
System.currentTimeMillis(),
|
boolean sendToMembers)
|
||||||
0,
|
{
|
||||||
false,
|
GroupId.V2 groupId = GroupId.v2(masterKey);
|
||||||
null,
|
Recipient groupRecipient = Recipient.externalGroupExact(context, groupId);
|
||||||
Collections.emptyList(),
|
DecryptedGroupV2Context decryptedGroupV2Context = GroupProtoUtil.createDecryptedGroupV2Context(masterKey, groupMutation, signedGroupChange);
|
||||||
Collections.emptyList(),
|
OutgoingGroupUpdateMessage outgoingMessage = new OutgoingGroupUpdateMessage(groupRecipient,
|
||||||
Collections.emptyList());
|
decryptedGroupV2Context,
|
||||||
|
null,
|
||||||
|
System.currentTimeMillis(),
|
||||||
|
0,
|
||||||
|
false,
|
||||||
|
null,
|
||||||
|
Collections.emptyList(),
|
||||||
|
Collections.emptyList(),
|
||||||
|
Collections.emptyList());
|
||||||
|
|
||||||
|
|
||||||
DecryptedGroupChange plainGroupChange = groupMutation.getGroupChange();
|
DecryptedGroupChange plainGroupChange = groupMutation.getGroupChange();
|
||||||
|
|
||||||
if (plainGroupChange != null && DecryptedGroupUtil.changeIsEmptyExceptForProfileKeyChanges(plainGroupChange)) {
|
if (plainGroupChange != null && DecryptedGroupUtil.changeIsEmptyExceptForProfileKeyChanges(plainGroupChange)) {
|
||||||
ApplicationDependencies.getJobManager().add(PushGroupSilentUpdateSendJob.create(context, groupId, groupMutation.getNewGroupState(), outgoingMessage));
|
if (sendToMembers) {
|
||||||
|
ApplicationDependencies.getJobManager().add(PushGroupSilentUpdateSendJob.create(context, groupId, groupMutation.getNewGroupState(), outgoingMessage));
|
||||||
|
}
|
||||||
|
|
||||||
return new RecipientAndThread(groupRecipient, -1);
|
return new RecipientAndThread(groupRecipient, -1);
|
||||||
} else {
|
} else {
|
||||||
long threadId = MessageSender.send(context, outgoingMessage, -1, false, null, null);
|
if (sendToMembers) {
|
||||||
return new RecipientAndThread(groupRecipient, threadId);
|
long threadId = MessageSender.send(context, outgoingMessage, -1, false, null, null);
|
||||||
|
return new RecipientAndThread(groupRecipient, threadId);
|
||||||
|
} else {
|
||||||
|
long threadId = SignalDatabase.threads().getOrCreateValidThreadId(outgoingMessage.getRecipient(), -1, outgoingMessage.getDistributionType());
|
||||||
|
try {
|
||||||
|
long messageId = SignalDatabase.mms().insertMessageOutbox(outgoingMessage, threadId, false, null);
|
||||||
|
SignalDatabase.mms().markAsSent(messageId, true);
|
||||||
|
SignalDatabase.threads().update(threadId, true);
|
||||||
|
} catch (MmsException e) {
|
||||||
|
throw new AssertionError(e);
|
||||||
|
}
|
||||||
|
return new RecipientAndThread(groupRecipient, threadId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue