mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-25 11:05:25 +00:00
09e52834a6
Closes #4248 // FREEBIE
61 lines
1.9 KiB
Java
61 lines
1.9 KiB
Java
package org.thoughtcrime.securesms.mms;
|
|
|
|
import android.support.annotation.NonNull;
|
|
import android.support.annotation.Nullable;
|
|
|
|
import org.thoughtcrime.redphone.util.Base64;
|
|
import org.thoughtcrime.securesms.attachments.Attachment;
|
|
import org.thoughtcrime.securesms.database.ThreadDatabase;
|
|
import org.thoughtcrime.securesms.recipients.Recipients;
|
|
import org.whispersystems.textsecure.internal.push.TextSecureProtos.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 Recipients recipients,
|
|
@NonNull String encodedGroupContext,
|
|
@NonNull List<Attachment> avatar,
|
|
long sentTimeMillis)
|
|
throws IOException
|
|
{
|
|
super(recipients, encodedGroupContext, avatar, sentTimeMillis,
|
|
ThreadDatabase.DistributionTypes.CONVERSATION);
|
|
|
|
this.group = GroupContext.parseFrom(Base64.decode(encodedGroupContext));
|
|
}
|
|
|
|
public OutgoingGroupMediaMessage(@NonNull Recipients recipients,
|
|
@NonNull GroupContext group,
|
|
@Nullable final Attachment avatar)
|
|
{
|
|
super(recipients, Base64.encodeBytes(group.toByteArray()),
|
|
new LinkedList<Attachment>() {{if (avatar != null) add(avatar);}},
|
|
System.currentTimeMillis(),
|
|
ThreadDatabase.DistributionTypes.CONVERSATION);
|
|
|
|
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;
|
|
}
|
|
}
|