Implement support for 'allows replies' toggle.

This commit is contained in:
Alex Hart
2022-03-01 12:41:45 -04:00
parent ee176cbe3d
commit 35cd36e9fe
40 changed files with 374 additions and 148 deletions

View File

@@ -770,6 +770,8 @@ public class SignalServiceMessageSender {
builder.setTextAttachment(createTextAttachment(message.getTextAttachment().get()));
}
builder.setAllowsReplies(message.getAllowsReplies().or(true));
return container.setStoryMessage(builder).build();
}

View File

@@ -958,11 +958,13 @@ public final class SignalServiceContent {
if (content.hasFileAttachment()) {
return SignalServiceStoryMessage.forFileAttachment(profileKey,
createGroupV2Info(content),
createAttachmentPointer(content.getFileAttachment()));
createAttachmentPointer(content.getFileAttachment()),
content.getAllowsReplies());
} else {
return SignalServiceStoryMessage.forTextAttachment(profileKey,
createGroupV2Info(content),
createTextAttachment(content.getTextAttachment()));
createTextAttachment(content.getTextAttachment()),
content.getAllowsReplies());
}
}

View File

@@ -7,27 +7,32 @@ public class SignalServiceStoryMessage {
private final Optional<SignalServiceGroupV2> groupContext;
private final Optional<SignalServiceAttachment> fileAttachment;
private final Optional<SignalServiceTextAttachment> textAttachment;
private final Optional<Boolean> allowsReplies;
private SignalServiceStoryMessage(byte[] profileKey,
SignalServiceGroupV2 groupContext,
SignalServiceAttachment fileAttachment,
SignalServiceTextAttachment textAttachment) {
SignalServiceTextAttachment textAttachment,
boolean allowsReplies) {
this.profileKey = Optional.fromNullable(profileKey);
this.groupContext = Optional.fromNullable(groupContext);
this.fileAttachment = Optional.fromNullable(fileAttachment);
this.textAttachment = Optional.fromNullable(textAttachment);
this.allowsReplies = Optional.of(allowsReplies);
}
public static SignalServiceStoryMessage forFileAttachment(byte[] profileKey,
SignalServiceGroupV2 groupContext,
SignalServiceAttachment fileAttachment) {
return new SignalServiceStoryMessage(profileKey, groupContext, fileAttachment, null);
SignalServiceAttachment fileAttachment,
boolean allowsReplies) {
return new SignalServiceStoryMessage(profileKey, groupContext, fileAttachment, null, allowsReplies);
}
public static SignalServiceStoryMessage forTextAttachment(byte[] profileKey,
SignalServiceGroupV2 groupContext,
SignalServiceTextAttachment textAttachment) {
return new SignalServiceStoryMessage(profileKey, groupContext, null, textAttachment);
SignalServiceTextAttachment textAttachment,
boolean allowsReplies) {
return new SignalServiceStoryMessage(profileKey, groupContext, null, textAttachment, allowsReplies);
}
public Optional<byte[]> getProfileKey() {
@@ -45,4 +50,8 @@ public class SignalServiceStoryMessage {
public Optional<SignalServiceTextAttachment> getTextAttachment() {
return textAttachment;
}
public Optional<Boolean> getAllowsReplies() {
return allowsReplies;
}
}

View File

@@ -350,12 +350,13 @@ message TypingMessage {
}
message StoryMessage {
optional bytes profileKey = 1;
optional GroupContextV2 group = 2;
optional bytes profileKey = 1;
optional GroupContextV2 group = 2;
oneof attachment {
AttachmentPointer fileAttachment = 3;
TextAttachment textAttachment = 4;
}
optional bool allowsReplies = 5;
}
message Preview {