Add support for replying to gift badges.

This commit is contained in:
Alex Hart
2022-05-10 10:10:35 -03:00
parent 0c1edd6a56
commit 8ca0f4baf4
22 changed files with 247 additions and 54 deletions

View File

@@ -846,7 +846,8 @@ public class SignalServiceMessageSender {
DataMessage.Quote.Builder quoteBuilder = DataMessage.Quote.newBuilder()
.setId(message.getQuote().get().getId())
.setText(message.getQuote().get().getText())
.setAuthorUuid(message.getQuote().get().getAuthor().getServiceId().toString());
.setAuthorUuid(message.getQuote().get().getAuthor().getServiceId().toString())
.setType(message.getQuote().get().getType().getProtoType());
if (!message.getQuote().get().getMentions().isEmpty()) {
for (SignalServiceDataMessage.Mention mention : message.getQuote().get().getMentions()) {

View File

@@ -1021,7 +1021,8 @@ public final class SignalServiceContent {
address,
content.getQuote().getText(),
attachments,
createMentions(content.getQuote().getBodyRangesList(), content.getQuote().getText(), isGroupV2));
createMentions(content.getQuote().getBodyRangesList(), content.getQuote().getText(), isGroupV2),
SignalServiceDataMessage.Quote.Type.fromProto(content.getQuote().getType()));
} else {
Log.w(TAG, "Quote was missing an author! Returning null.");
return null;

View File

@@ -13,6 +13,7 @@ import org.whispersystems.signalservice.api.messages.shared.SharedContact;
import org.whispersystems.signalservice.api.push.ServiceId;
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
import org.whispersystems.signalservice.api.util.OptionalUtil;
import org.whispersystems.signalservice.internal.push.SignalServiceProtos;
import java.util.LinkedList;
import java.util.List;
@@ -456,13 +457,21 @@ public class SignalServiceDataMessage {
private final String text;
private final List<QuotedAttachment> attachments;
private final List<Mention> mentions;
private final Type type;
public Quote(long id, SignalServiceAddress author, String text, List<QuotedAttachment> attachments, List<Mention> mentions) {
public Quote(long id,
SignalServiceAddress author,
String text,
List<QuotedAttachment> attachments,
List<Mention> mentions,
Type type)
{
this.id = id;
this.author = author;
this.text = text;
this.attachments = attachments;
this.mentions = mentions;
this.type = type;
}
public long getId() {
@@ -485,6 +494,35 @@ public class SignalServiceDataMessage {
return mentions;
}
public Type getType() {
return type;
}
public enum Type {
NORMAL(SignalServiceProtos.DataMessage.Quote.Type.NORMAL),
GIFT_BADGE(SignalServiceProtos.DataMessage.Quote.Type.GIFT_BADGE);
private final SignalServiceProtos.DataMessage.Quote.Type protoType;
Type(SignalServiceProtos.DataMessage.Quote.Type protoType) {
this.protoType = protoType;
}
public SignalServiceProtos.DataMessage.Quote.Type getProtoType() {
return protoType;
}
public static Type fromProto(SignalServiceProtos.DataMessage.Quote.Type protoType) {
for (final Type value : values()) {
if (value.protoType == protoType) {
return value;
}
}
return NORMAL;
}
}
public static class QuotedAttachment {
private final String contentType;
private final String fileName;

View File

@@ -138,6 +138,11 @@ message DataMessage {
}
message Quote {
enum Type {
NORMAL = 0;
GIFT_BADGE = 1;
}
message QuotedAttachment {
optional string contentType = 1;
optional string fileName = 2;
@@ -150,6 +155,7 @@ message DataMessage {
optional string text = 3;
repeated QuotedAttachment attachments = 4;
repeated BodyRange bodyRanges = 6;
optional Type type = 7;
}
message Contact {