mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-29 19:27:43 +00:00
375207f073
Eliminate the concept of 'Recipients' (plural). There is now just a 'Recipient', which contains an Address that is either an individual or a group ID. MMS groups now exist as part of the group database, just like push groups. // FREEBIE
64 lines
2.1 KiB
Java
64 lines
2.1 KiB
Java
package org.thoughtcrime.securesms.mms;
|
|
|
|
import android.support.annotation.NonNull;
|
|
import android.support.annotation.Nullable;
|
|
|
|
import org.thoughtcrime.securesms.attachments.Attachment;
|
|
import org.thoughtcrime.securesms.database.ThreadDatabase;
|
|
import org.thoughtcrime.securesms.recipients.Recipient;
|
|
import org.thoughtcrime.securesms.util.Base64;
|
|
import org.whispersystems.signalservice.internal.push.SignalServiceProtos.GroupContext;
|
|
|
|
import java.io.IOException;
|
|
import java.util.LinkedList;
|
|
import java.util.List;
|
|
|
|
public class OutgoingGroupMediaMessage extends OutgoingSecureMediaMessage {
|
|
|
|
private final GroupContext group;
|
|
|
|
public OutgoingGroupMediaMessage(@NonNull Recipient recipient,
|
|
@NonNull String encodedGroupContext,
|
|
@NonNull List<Attachment> avatar,
|
|
long sentTimeMillis,
|
|
long expiresIn)
|
|
throws IOException
|
|
{
|
|
super(recipient, encodedGroupContext, avatar, sentTimeMillis,
|
|
ThreadDatabase.DistributionTypes.CONVERSATION, expiresIn);
|
|
|
|
this.group = GroupContext.parseFrom(Base64.decode(encodedGroupContext));
|
|
}
|
|
|
|
public OutgoingGroupMediaMessage(@NonNull Recipient recipient,
|
|
@NonNull GroupContext group,
|
|
@Nullable final Attachment avatar,
|
|
long sentTimeMillis,
|
|
long expireIn)
|
|
{
|
|
super(recipient, Base64.encodeBytes(group.toByteArray()),
|
|
new LinkedList<Attachment>() {{if (avatar != null) add(avatar);}},
|
|
System.currentTimeMillis(),
|
|
ThreadDatabase.DistributionTypes.CONVERSATION, expireIn);
|
|
|
|
this.group = group;
|
|
}
|
|
|
|
@Override
|
|
public boolean isGroup() {
|
|
return true;
|
|
}
|
|
|
|
public boolean isGroupUpdate() {
|
|
return group.getType().getNumber() == GroupContext.Type.UPDATE_VALUE;
|
|
}
|
|
|
|
public boolean isGroupQuit() {
|
|
return group.getType().getNumber() == GroupContext.Type.QUIT_VALUE;
|
|
}
|
|
|
|
public GroupContext getGroupContext() {
|
|
return group;
|
|
}
|
|
}
|