2013-07-18 17:42:45 -07:00
|
|
|
package org.thoughtcrime.securesms.mms;
|
|
|
|
|
2015-10-12 18:25:05 -07:00
|
|
|
import org.thoughtcrime.securesms.attachments.Attachment;
|
|
|
|
import org.thoughtcrime.securesms.attachments.PointerAttachment;
|
2018-04-26 17:03:54 -07:00
|
|
|
import org.thoughtcrime.securesms.contactshare.Contact;
|
2017-07-26 09:59:15 -07:00
|
|
|
import org.thoughtcrime.securesms.database.Address;
|
2019-01-15 00:41:05 -08:00
|
|
|
import org.thoughtcrime.securesms.linkpreview.LinkPreview;
|
2014-11-04 15:01:32 -08:00
|
|
|
import org.thoughtcrime.securesms.util.GroupUtil;
|
2016-03-23 10:34:41 -07:00
|
|
|
import org.whispersystems.libsignal.util.guava.Optional;
|
|
|
|
import org.whispersystems.signalservice.api.messages.SignalServiceAttachment;
|
|
|
|
import org.whispersystems.signalservice.api.messages.SignalServiceGroup;
|
2014-11-03 15:16:04 -08:00
|
|
|
|
2018-04-26 17:03:54 -07:00
|
|
|
import java.util.Collections;
|
2015-10-12 18:25:05 -07:00
|
|
|
import java.util.LinkedList;
|
2014-11-03 15:16:04 -08:00
|
|
|
import java.util.List;
|
2013-07-18 17:42:45 -07:00
|
|
|
|
|
|
|
public class IncomingMediaMessage {
|
|
|
|
|
2018-02-07 14:01:37 -08:00
|
|
|
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;
|
2018-04-26 17:03:54 -07:00
|
|
|
private final QuoteModel quote;
|
2018-05-22 02:13:10 -07:00
|
|
|
private final boolean unidentified;
|
2015-10-12 18:25:05 -07:00
|
|
|
|
2019-01-15 00:41:05 -08:00
|
|
|
private final List<Attachment> attachments = new LinkedList<>();
|
|
|
|
private final List<Contact> sharedContacts = new LinkedList<>();
|
|
|
|
private final List<LinkPreview> linkPreviews = new LinkedList<>();
|
2013-07-18 17:42:45 -07:00
|
|
|
|
2017-08-01 08:56:00 -07:00
|
|
|
public IncomingMediaMessage(Address from,
|
|
|
|
Optional<Address> groupId,
|
|
|
|
String body,
|
|
|
|
long sentTimeMillis,
|
|
|
|
List<Attachment> attachments,
|
|
|
|
int subscriptionId,
|
|
|
|
long expiresIn,
|
2018-05-22 02:13:10 -07:00
|
|
|
boolean expirationUpdate,
|
|
|
|
boolean unidentified)
|
2015-10-12 18:25:05 -07:00
|
|
|
{
|
2017-08-01 08:56:00 -07:00
|
|
|
this.from = from;
|
|
|
|
this.groupId = groupId.orNull();
|
2016-08-15 20:23:56 -07:00
|
|
|
this.sentTimeMillis = sentTimeMillis;
|
|
|
|
this.body = body;
|
|
|
|
this.push = false;
|
|
|
|
this.subscriptionId = subscriptionId;
|
|
|
|
this.expiresIn = expiresIn;
|
|
|
|
this.expirationUpdate = expirationUpdate;
|
2018-02-07 14:01:37 -08:00
|
|
|
this.quote = null;
|
2018-05-22 02:13:10 -07:00
|
|
|
this.unidentified = unidentified;
|
2015-10-12 18:25:05 -07:00
|
|
|
|
|
|
|
this.attachments.addAll(attachments);
|
2013-07-18 17:42:45 -07:00
|
|
|
}
|
|
|
|
|
2018-01-24 19:17:44 -08:00
|
|
|
public IncomingMediaMessage(Address from,
|
2014-11-03 15:16:04 -08:00
|
|
|
long sentTimeMillis,
|
2016-02-05 16:10:33 -08:00
|
|
|
int subscriptionId,
|
2016-08-15 20:23:56 -07:00
|
|
|
long expiresIn,
|
|
|
|
boolean expirationUpdate,
|
2018-05-22 02:13:10 -07:00
|
|
|
boolean unidentified,
|
2014-11-03 15:16:04 -08:00
|
|
|
Optional<String> body,
|
2016-03-23 10:34:41 -07:00
|
|
|
Optional<SignalServiceGroup> group,
|
2018-02-07 14:01:37 -08:00
|
|
|
Optional<List<SignalServiceAttachment>> attachments,
|
2018-04-26 17:03:54 -07:00
|
|
|
Optional<QuoteModel> quote,
|
2019-01-15 00:41:05 -08:00
|
|
|
Optional<List<Contact>> sharedContacts,
|
|
|
|
Optional<List<LinkPreview>> linkPreviews)
|
2013-07-18 17:42:45 -07:00
|
|
|
{
|
2016-08-15 20:23:56 -07:00
|
|
|
this.push = true;
|
|
|
|
this.from = from;
|
|
|
|
this.sentTimeMillis = sentTimeMillis;
|
|
|
|
this.body = body.orNull();
|
|
|
|
this.subscriptionId = subscriptionId;
|
|
|
|
this.expiresIn = expiresIn;
|
|
|
|
this.expirationUpdate = expirationUpdate;
|
2018-02-07 14:01:37 -08:00
|
|
|
this.quote = quote.orNull();
|
2018-05-22 02:13:10 -07:00
|
|
|
this.unidentified = unidentified;
|
2015-10-12 18:25:05 -07:00
|
|
|
|
2017-08-01 08:56:00 -07:00
|
|
|
if (group.isPresent()) this.groupId = Address.fromSerialized(GroupUtil.getEncodedId(group.get().getGroupId(), false));
|
2015-10-12 18:25:05 -07:00
|
|
|
else this.groupId = null;
|
2013-07-18 17:42:45 -07:00
|
|
|
|
2018-01-24 19:17:44 -08:00
|
|
|
this.attachments.addAll(PointerAttachment.forPointers(attachments));
|
2018-04-26 17:03:54 -07:00
|
|
|
this.sharedContacts.addAll(sharedContacts.or(Collections.emptyList()));
|
2019-01-15 00:41:05 -08:00
|
|
|
this.linkPreviews.addAll(linkPreviews.or(Collections.emptyList()));
|
2013-07-18 17:42:45 -07:00
|
|
|
}
|
|
|
|
|
2016-02-05 16:10:33 -08:00
|
|
|
public int getSubscriptionId() {
|
|
|
|
return subscriptionId;
|
|
|
|
}
|
|
|
|
|
2015-10-12 18:25:05 -07:00
|
|
|
public String getBody() {
|
2013-07-18 17:42:45 -07:00
|
|
|
return body;
|
|
|
|
}
|
|
|
|
|
2015-10-12 18:25:05 -07:00
|
|
|
public List<Attachment> getAttachments() {
|
|
|
|
return attachments;
|
|
|
|
}
|
|
|
|
|
2017-08-01 08:56:00 -07:00
|
|
|
public Address getFrom() {
|
|
|
|
return from;
|
|
|
|
}
|
|
|
|
|
2017-07-26 09:59:15 -07:00
|
|
|
public Address getGroupId() {
|
2014-01-14 00:26:43 -08:00
|
|
|
return groupId;
|
|
|
|
}
|
|
|
|
|
2014-02-20 23:00:38 -08:00
|
|
|
public boolean isPushMessage() {
|
|
|
|
return push;
|
|
|
|
}
|
|
|
|
|
2016-08-15 20:23:56 -07:00
|
|
|
public boolean isExpirationUpdate() {
|
|
|
|
return expirationUpdate;
|
|
|
|
}
|
|
|
|
|
2015-10-12 18:25:05 -07:00
|
|
|
public long getSentTimeMillis() {
|
|
|
|
return sentTimeMillis;
|
|
|
|
}
|
|
|
|
|
2016-08-15 20:23:56 -07:00
|
|
|
public long getExpiresIn() {
|
|
|
|
return expiresIn;
|
|
|
|
}
|
|
|
|
|
2013-07-18 17:42:45 -07:00
|
|
|
public boolean isGroupMessage() {
|
2017-08-01 08:56:00 -07:00
|
|
|
return groupId != null;
|
2013-07-18 17:42:45 -07:00
|
|
|
}
|
2018-02-07 14:01:37 -08:00
|
|
|
|
|
|
|
public QuoteModel getQuote() {
|
|
|
|
return quote;
|
|
|
|
}
|
2018-04-26 17:03:54 -07:00
|
|
|
|
|
|
|
public List<Contact> getSharedContacts() {
|
|
|
|
return sharedContacts;
|
|
|
|
}
|
2018-05-22 02:13:10 -07:00
|
|
|
|
2019-01-15 00:41:05 -08:00
|
|
|
public List<LinkPreview> getLinkPreviews() {
|
|
|
|
return linkPreviews;
|
|
|
|
}
|
|
|
|
|
2018-05-22 02:13:10 -07:00
|
|
|
public boolean isUnidentified() {
|
|
|
|
return unidentified;
|
|
|
|
}
|
2013-07-18 17:42:45 -07:00
|
|
|
}
|