mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-30 21:45:20 +00:00
2a644437fb
No sticker packs are available for use yet, but we now have the latent ability to send and receive.
150 lines
4.6 KiB
Java
150 lines
4.6 KiB
Java
package org.thoughtcrime.securesms.mms;
|
|
|
|
import org.thoughtcrime.securesms.attachments.Attachment;
|
|
import org.thoughtcrime.securesms.attachments.PointerAttachment;
|
|
import org.thoughtcrime.securesms.contactshare.Contact;
|
|
import org.thoughtcrime.securesms.database.Address;
|
|
import org.thoughtcrime.securesms.linkpreview.LinkPreview;
|
|
import org.thoughtcrime.securesms.util.GroupUtil;
|
|
import org.whispersystems.libsignal.util.guava.Optional;
|
|
import org.whispersystems.signalservice.api.messages.SignalServiceAttachment;
|
|
import org.whispersystems.signalservice.api.messages.SignalServiceGroup;
|
|
|
|
import java.util.Collections;
|
|
import java.util.LinkedList;
|
|
import java.util.List;
|
|
|
|
public class IncomingMediaMessage {
|
|
|
|
private final Address from;
|
|
private final Address groupId;
|
|
private final String body;
|
|
private final boolean push;
|
|
private final long sentTimeMillis;
|
|
private final int subscriptionId;
|
|
private final long expiresIn;
|
|
private final boolean expirationUpdate;
|
|
private final QuoteModel quote;
|
|
private final boolean unidentified;
|
|
|
|
private final List<Attachment> attachments = new LinkedList<>();
|
|
private final List<Contact> sharedContacts = new LinkedList<>();
|
|
private final List<LinkPreview> linkPreviews = new LinkedList<>();
|
|
|
|
public IncomingMediaMessage(Address from,
|
|
Optional<Address> groupId,
|
|
String body,
|
|
long sentTimeMillis,
|
|
List<Attachment> attachments,
|
|
int subscriptionId,
|
|
long expiresIn,
|
|
boolean expirationUpdate,
|
|
boolean unidentified)
|
|
{
|
|
this.from = from;
|
|
this.groupId = groupId.orNull();
|
|
this.sentTimeMillis = sentTimeMillis;
|
|
this.body = body;
|
|
this.push = false;
|
|
this.subscriptionId = subscriptionId;
|
|
this.expiresIn = expiresIn;
|
|
this.expirationUpdate = expirationUpdate;
|
|
this.quote = null;
|
|
this.unidentified = unidentified;
|
|
|
|
this.attachments.addAll(attachments);
|
|
}
|
|
|
|
public IncomingMediaMessage(Address from,
|
|
long sentTimeMillis,
|
|
int subscriptionId,
|
|
long expiresIn,
|
|
boolean expirationUpdate,
|
|
boolean unidentified,
|
|
Optional<String> body,
|
|
Optional<SignalServiceGroup> group,
|
|
Optional<List<SignalServiceAttachment>> attachments,
|
|
Optional<QuoteModel> quote,
|
|
Optional<List<Contact>> sharedContacts,
|
|
Optional<List<LinkPreview>> linkPreviews,
|
|
Optional<Attachment> sticker)
|
|
{
|
|
this.push = true;
|
|
this.from = from;
|
|
this.sentTimeMillis = sentTimeMillis;
|
|
this.body = body.orNull();
|
|
this.subscriptionId = subscriptionId;
|
|
this.expiresIn = expiresIn;
|
|
this.expirationUpdate = expirationUpdate;
|
|
this.quote = quote.orNull();
|
|
this.unidentified = unidentified;
|
|
|
|
if (group.isPresent()) this.groupId = Address.fromSerialized(GroupUtil.getEncodedId(group.get().getGroupId(), false));
|
|
else this.groupId = null;
|
|
|
|
this.attachments.addAll(PointerAttachment.forPointers(attachments));
|
|
this.sharedContacts.addAll(sharedContacts.or(Collections.emptyList()));
|
|
this.linkPreviews.addAll(linkPreviews.or(Collections.emptyList()));
|
|
|
|
if (sticker.isPresent()) {
|
|
this.attachments.add(sticker.get());
|
|
}
|
|
}
|
|
|
|
public int getSubscriptionId() {
|
|
return subscriptionId;
|
|
}
|
|
|
|
public String getBody() {
|
|
return body;
|
|
}
|
|
|
|
public List<Attachment> getAttachments() {
|
|
return attachments;
|
|
}
|
|
|
|
public Address getFrom() {
|
|
return from;
|
|
}
|
|
|
|
public Address getGroupId() {
|
|
return groupId;
|
|
}
|
|
|
|
public boolean isPushMessage() {
|
|
return push;
|
|
}
|
|
|
|
public boolean isExpirationUpdate() {
|
|
return expirationUpdate;
|
|
}
|
|
|
|
public long getSentTimeMillis() {
|
|
return sentTimeMillis;
|
|
}
|
|
|
|
public long getExpiresIn() {
|
|
return expiresIn;
|
|
}
|
|
|
|
public boolean isGroupMessage() {
|
|
return groupId != null;
|
|
}
|
|
|
|
public QuoteModel getQuote() {
|
|
return quote;
|
|
}
|
|
|
|
public List<Contact> getSharedContacts() {
|
|
return sharedContacts;
|
|
}
|
|
|
|
public List<LinkPreview> getLinkPreviews() {
|
|
return linkPreviews;
|
|
}
|
|
|
|
public boolean isUnidentified() {
|
|
return unidentified;
|
|
}
|
|
}
|