Implement Stories feature behind flag.

Co-Authored-By: Greyson Parrelli <37311915+greyson-signal@users.noreply.github.com>
Co-Authored-By: Rashad Sookram <95182499+rashad-signal@users.noreply.github.com>
This commit is contained in:
Alex Hart
2022-02-24 13:40:28 -04:00
parent 765185952e
commit 174cd860a0
416 changed files with 19506 additions and 857 deletions

View File

@@ -4,6 +4,7 @@ import org.thoughtcrime.securesms.attachments.Attachment
import org.thoughtcrime.securesms.attachments.PointerAttachment
import org.thoughtcrime.securesms.contactshare.Contact
import org.thoughtcrime.securesms.database.model.Mention
import org.thoughtcrime.securesms.database.model.MessageId
import org.thoughtcrime.securesms.database.model.databaseprotos.BodyRangeList
import org.thoughtcrime.securesms.groups.GroupId
import org.thoughtcrime.securesms.linkpreview.LinkPreview
@@ -18,6 +19,8 @@ class IncomingMediaMessage(
val groupId: GroupId? = null,
val body: String? = null,
val isPushMessage: Boolean = false,
val isStory: Boolean = false,
val parentStoryId: MessageId? = null,
val sentTimeMillis: Long,
val serverTimeMillis: Long,
val receivedTimeMillis: Long,
@@ -80,6 +83,8 @@ class IncomingMediaMessage(
sentTimeMillis: Long,
serverTimeMillis: Long,
receivedTimeMillis: Long,
isStory: Boolean,
parentStoryId: MessageId?,
subscriptionId: Int,
expiresIn: Long,
expirationUpdate: Boolean,
@@ -99,6 +104,8 @@ class IncomingMediaMessage(
groupId = if (group.isPresent) GroupUtil.idFromGroupContextOrThrow(group.get()) else null,
body = body.orNull(),
isPushMessage = true,
isStory = isStory,
parentStoryId = parentStoryId,
sentTimeMillis = sentTimeMillis,
serverTimeMillis = serverTimeMillis,
receivedTimeMillis = receivedTimeMillis,

View File

@@ -10,9 +10,19 @@ import java.util.LinkedList;
public class OutgoingExpirationUpdateMessage extends OutgoingSecureMediaMessage {
public OutgoingExpirationUpdateMessage(Recipient recipient, long sentTimeMillis, long expiresIn) {
super(recipient, "", new LinkedList<Attachment>(), sentTimeMillis,
ThreadDatabase.DistributionTypes.CONVERSATION, expiresIn, false, null, Collections.emptyList(),
Collections.emptyList(), Collections.emptyList());
super(recipient,
"",
new LinkedList<Attachment>(),
sentTimeMillis,
ThreadDatabase.DistributionTypes.CONVERSATION,
expiresIn,
false,
false,
null,
null,
Collections.emptyList(),
Collections.emptyList(),
Collections.emptyList());
}
@Override

View File

@@ -31,8 +31,19 @@ public final class OutgoingGroupUpdateMessage extends OutgoingSecureMediaMessage
@NonNull List<LinkPreview> previews,
@NonNull List<Mention> mentions)
{
super(recipient, groupContext.getEncodedGroupContext(), avatar, sentTimeMillis,
ThreadDatabase.DistributionTypes.CONVERSATION, expiresIn, viewOnce, quote, contacts, previews, mentions);
super(recipient,
groupContext.getEncodedGroupContext(),
avatar,
sentTimeMillis,
ThreadDatabase.DistributionTypes.CONVERSATION,
expiresIn,
viewOnce,
false,
null,
quote,
contacts,
previews,
mentions);
this.messageGroupContext = groupContext;
}

View File

@@ -10,6 +10,7 @@ import org.thoughtcrime.securesms.contactshare.Contact;
import org.thoughtcrime.securesms.database.documents.IdentityKeyMismatch;
import org.thoughtcrime.securesms.database.documents.NetworkFailure;
import org.thoughtcrime.securesms.database.model.Mention;
import org.thoughtcrime.securesms.database.model.MessageId;
import org.thoughtcrime.securesms.linkpreview.LinkPreview;
import org.thoughtcrime.securesms.recipients.Recipient;
@@ -29,6 +30,8 @@ public class OutgoingMediaMessage {
private final long expiresIn;
private final boolean viewOnce;
private final QuoteModel outgoingQuote;
private final boolean isStory;
private final MessageId parentStoryId;
private final Set<NetworkFailure> networkFailures = new HashSet<>();
private final Set<IdentityKeyMismatch> identityKeyMismatches = new HashSet<>();
@@ -36,10 +39,16 @@ public class OutgoingMediaMessage {
private final List<LinkPreview> linkPreviews = new LinkedList<>();
private final List<Mention> mentions = new LinkedList<>();
public OutgoingMediaMessage(Recipient recipient, String message,
List<Attachment> attachments, long sentTimeMillis,
int subscriptionId, long expiresIn, boolean viewOnce,
public OutgoingMediaMessage(Recipient recipient,
String message,
List<Attachment> attachments,
long sentTimeMillis,
int subscriptionId,
long expiresIn,
boolean viewOnce,
int distributionType,
boolean isStory,
@Nullable MessageId parentStoryId,
@Nullable QuoteModel outgoingQuote,
@NonNull List<Contact> contacts,
@NonNull List<LinkPreview> linkPreviews,
@@ -56,6 +65,8 @@ public class OutgoingMediaMessage {
this.expiresIn = expiresIn;
this.viewOnce = viewOnce;
this.outgoingQuote = outgoingQuote;
this.isStory = isStory;
this.parentStoryId = parentStoryId;
this.contacts.addAll(contacts);
this.linkPreviews.addAll(linkPreviews);
@@ -64,9 +75,16 @@ public class OutgoingMediaMessage {
this.identityKeyMismatches.addAll(identityKeyMismatches);
}
public OutgoingMediaMessage(Recipient recipient, SlideDeck slideDeck, String message,
long sentTimeMillis, int subscriptionId, long expiresIn,
boolean viewOnce, int distributionType,
public OutgoingMediaMessage(Recipient recipient,
SlideDeck slideDeck,
String message,
long sentTimeMillis,
int subscriptionId,
long expiresIn,
boolean viewOnce,
int distributionType,
boolean isStory,
@Nullable MessageId parentStoryId,
@Nullable QuoteModel outgoingQuote,
@NonNull List<Contact> contacts,
@NonNull List<LinkPreview> linkPreviews,
@@ -75,9 +93,19 @@ public class OutgoingMediaMessage {
this(recipient,
buildMessage(slideDeck, message),
slideDeck.asAttachments(),
sentTimeMillis, subscriptionId,
expiresIn, viewOnce, distributionType, outgoingQuote,
contacts, linkPreviews, mentions, new HashSet<>(), new HashSet<>());
sentTimeMillis,
subscriptionId,
expiresIn,
viewOnce,
distributionType,
isStory,
parentStoryId,
outgoingQuote,
contacts,
linkPreviews,
mentions,
new HashSet<>(),
new HashSet<>());
}
public OutgoingMediaMessage(OutgoingMediaMessage that) {
@@ -90,6 +118,8 @@ public class OutgoingMediaMessage {
this.expiresIn = that.expiresIn;
this.viewOnce = that.viewOnce;
this.outgoingQuote = that.outgoingQuote;
this.isStory = that.isStory;
this.parentStoryId = that.parentStoryId;
this.identityKeyMismatches.addAll(that.identityKeyMismatches);
this.networkFailures.addAll(that.networkFailures);
@@ -108,6 +138,8 @@ public class OutgoingMediaMessage {
expiresIn,
viewOnce,
distributionType,
isStory,
parentStoryId,
outgoingQuote,
contacts,
linkPreviews,
@@ -161,6 +193,14 @@ public class OutgoingMediaMessage {
return viewOnce;
}
public boolean isStory() {
return isStory;
}
public @Nullable MessageId getParentStoryId() {
return parentStoryId;
}
public @Nullable QuoteModel getOutgoingQuote() {
return outgoingQuote;
}
@@ -194,5 +234,4 @@ public class OutgoingMediaMessage {
return slideDeck.getBody();
}
}
}

View File

@@ -6,6 +6,7 @@ import androidx.annotation.Nullable;
import org.thoughtcrime.securesms.attachments.Attachment;
import org.thoughtcrime.securesms.contactshare.Contact;
import org.thoughtcrime.securesms.database.model.Mention;
import org.thoughtcrime.securesms.database.model.MessageId;
import org.thoughtcrime.securesms.linkpreview.LinkPreview;
import org.thoughtcrime.securesms.recipients.Recipient;
@@ -14,18 +15,21 @@ import java.util.List;
public class OutgoingSecureMediaMessage extends OutgoingMediaMessage {
public OutgoingSecureMediaMessage(Recipient recipient, String body,
public OutgoingSecureMediaMessage(Recipient recipient,
String body,
List<Attachment> attachments,
long sentTimeMillis,
int distributionType,
long expiresIn,
boolean viewOnce,
boolean isStory,
@Nullable MessageId parentStoryId,
@Nullable QuoteModel quote,
@NonNull List<Contact> contacts,
@NonNull List<LinkPreview> previews,
@NonNull List<Mention> mentions)
{
super(recipient, body, attachments, sentTimeMillis, -1, expiresIn, viewOnce, distributionType, quote, contacts, previews, mentions, Collections.emptySet(), Collections.emptySet());
super(recipient, body, attachments, sentTimeMillis, -1, expiresIn, viewOnce, distributionType, isStory, parentStoryId, quote, contacts, previews, mentions, Collections.emptySet(), Collections.emptySet());
}
public OutgoingSecureMediaMessage(OutgoingMediaMessage base) {
@@ -46,6 +50,8 @@ public class OutgoingSecureMediaMessage extends OutgoingMediaMessage {
getDistributionType(),
expiresIn,
isViewOnce(),
isStory(),
getParentStoryId(),
getOutgoingQuote(),
getSharedContacts(),
getLinkPreviews(),