Add profile data to message request responses

This commit is contained in:
charles 2022-10-04 15:23:58 +11:00
parent fbd1721eaf
commit 1f7edadc59
3 changed files with 315 additions and 22 deletions

View File

@ -1,15 +1,22 @@
package org.session.libsession.messaging.messages.control package org.session.libsession.messaging.messages.control
import com.google.protobuf.ByteString
import org.session.libsession.messaging.messages.visible.Profile
import org.session.libsignal.protos.SignalServiceProtos import org.session.libsignal.protos.SignalServiceProtos
import org.session.libsignal.utilities.Log import org.session.libsignal.utilities.Log
class MessageRequestResponse(val isApproved: Boolean) : ControlMessage() { class MessageRequestResponse(val isApproved: Boolean, val profile: Profile? = null) : ControlMessage() {
override val isSelfSendValid: Boolean = true override val isSelfSendValid: Boolean = true
override fun toProto(): SignalServiceProtos.Content? { override fun toProto(): SignalServiceProtos.Content? {
val profileProto = SignalServiceProtos.DataMessage.LokiProfile.newBuilder()
profile?.displayName?.let { profileProto.displayName = it }
profile?.profilePictureURL?.let { profileProto.profilePicture = it }
val messageRequestResponseProto = SignalServiceProtos.MessageRequestResponse.newBuilder() val messageRequestResponseProto = SignalServiceProtos.MessageRequestResponse.newBuilder()
.setIsApproved(isApproved) .setIsApproved(isApproved)
.setProfile(profileProto.build())
profile?.profileKey?.let { messageRequestResponseProto.profileKey = ByteString.copyFrom(it) }
return try { return try {
SignalServiceProtos.Content.newBuilder() SignalServiceProtos.Content.newBuilder()
.setMessageRequestResponse(messageRequestResponseProto.build()) .setMessageRequestResponse(messageRequestResponseProto.build())
@ -26,7 +33,13 @@ class MessageRequestResponse(val isApproved: Boolean) : ControlMessage() {
fun fromProto(proto: SignalServiceProtos.Content): MessageRequestResponse? { fun fromProto(proto: SignalServiceProtos.Content): MessageRequestResponse? {
val messageRequestResponseProto = if (proto.hasMessageRequestResponse()) proto.messageRequestResponse else return null val messageRequestResponseProto = if (proto.hasMessageRequestResponse()) proto.messageRequestResponse else return null
val isApproved = messageRequestResponseProto.isApproved val isApproved = messageRequestResponseProto.isApproved
return MessageRequestResponse(isApproved) val profileProto = messageRequestResponseProto.profile
val profile = Profile().apply {
displayName = profileProto.displayName
profileKey = messageRequestResponseProto.profileKey.toByteArray()
profilePictureURL = profileProto.profilePicture
}
return MessageRequestResponse(isApproved, profile)
} }
} }

View File

@ -233,7 +233,9 @@ message ConfigurationMessage {
message MessageRequestResponse { message MessageRequestResponse {
// @required // @required
required bool isApproved = 1; // Whether the request was approved required bool isApproved = 1;
optional bytes profileKey = 2;
optional DataMessage.LokiProfile profile = 3;
} }
message ReceiptMessage { message ReceiptMessage {

View File

@ -21504,6 +21504,30 @@ public final class SignalServiceProtos {
* </pre> * </pre>
*/ */
boolean getIsApproved(); boolean getIsApproved();
// optional bytes profileKey = 2;
/**
* <code>optional bytes profileKey = 2;</code>
*/
boolean hasProfileKey();
/**
* <code>optional bytes profileKey = 2;</code>
*/
com.google.protobuf.ByteString getProfileKey();
// optional .signalservice.DataMessage.LokiProfile profile = 3;
/**
* <code>optional .signalservice.DataMessage.LokiProfile profile = 3;</code>
*/
boolean hasProfile();
/**
* <code>optional .signalservice.DataMessage.LokiProfile profile = 3;</code>
*/
org.session.libsignal.protos.SignalServiceProtos.DataMessage.LokiProfile getProfile();
/**
* <code>optional .signalservice.DataMessage.LokiProfile profile = 3;</code>
*/
org.session.libsignal.protos.SignalServiceProtos.DataMessage.LokiProfileOrBuilder getProfileOrBuilder();
} }
/** /**
* Protobuf type {@code signalservice.MessageRequestResponse} * Protobuf type {@code signalservice.MessageRequestResponse}
@ -21561,6 +21585,24 @@ public final class SignalServiceProtos {
isApproved_ = input.readBool(); isApproved_ = input.readBool();
break; break;
} }
case 18: {
bitField0_ |= 0x00000002;
profileKey_ = input.readBytes();
break;
}
case 26: {
org.session.libsignal.protos.SignalServiceProtos.DataMessage.LokiProfile.Builder subBuilder = null;
if (((bitField0_ & 0x00000004) == 0x00000004)) {
subBuilder = profile_.toBuilder();
}
profile_ = input.readMessage(org.session.libsignal.protos.SignalServiceProtos.DataMessage.LokiProfile.PARSER, extensionRegistry);
if (subBuilder != null) {
subBuilder.mergeFrom(profile_);
profile_ = subBuilder.buildPartial();
}
bitField0_ |= 0x00000004;
break;
}
} }
} }
} catch (com.google.protobuf.InvalidProtocolBufferException e) { } catch (com.google.protobuf.InvalidProtocolBufferException e) {
@ -21625,8 +21667,48 @@ public final class SignalServiceProtos {
return isApproved_; return isApproved_;
} }
// optional bytes profileKey = 2;
public static final int PROFILEKEY_FIELD_NUMBER = 2;
private com.google.protobuf.ByteString profileKey_;
/**
* <code>optional bytes profileKey = 2;</code>
*/
public boolean hasProfileKey() {
return ((bitField0_ & 0x00000002) == 0x00000002);
}
/**
* <code>optional bytes profileKey = 2;</code>
*/
public com.google.protobuf.ByteString getProfileKey() {
return profileKey_;
}
// optional .signalservice.DataMessage.LokiProfile profile = 3;
public static final int PROFILE_FIELD_NUMBER = 3;
private org.session.libsignal.protos.SignalServiceProtos.DataMessage.LokiProfile profile_;
/**
* <code>optional .signalservice.DataMessage.LokiProfile profile = 3;</code>
*/
public boolean hasProfile() {
return ((bitField0_ & 0x00000004) == 0x00000004);
}
/**
* <code>optional .signalservice.DataMessage.LokiProfile profile = 3;</code>
*/
public org.session.libsignal.protos.SignalServiceProtos.DataMessage.LokiProfile getProfile() {
return profile_;
}
/**
* <code>optional .signalservice.DataMessage.LokiProfile profile = 3;</code>
*/
public org.session.libsignal.protos.SignalServiceProtos.DataMessage.LokiProfileOrBuilder getProfileOrBuilder() {
return profile_;
}
private void initFields() { private void initFields() {
isApproved_ = false; isApproved_ = false;
profileKey_ = com.google.protobuf.ByteString.EMPTY;
profile_ = org.session.libsignal.protos.SignalServiceProtos.DataMessage.LokiProfile.getDefaultInstance();
} }
private byte memoizedIsInitialized = -1; private byte memoizedIsInitialized = -1;
public final boolean isInitialized() { public final boolean isInitialized() {
@ -21647,6 +21729,12 @@ public final class SignalServiceProtos {
if (((bitField0_ & 0x00000001) == 0x00000001)) { if (((bitField0_ & 0x00000001) == 0x00000001)) {
output.writeBool(1, isApproved_); output.writeBool(1, isApproved_);
} }
if (((bitField0_ & 0x00000002) == 0x00000002)) {
output.writeBytes(2, profileKey_);
}
if (((bitField0_ & 0x00000004) == 0x00000004)) {
output.writeMessage(3, profile_);
}
getUnknownFields().writeTo(output); getUnknownFields().writeTo(output);
} }
@ -21660,6 +21748,14 @@ public final class SignalServiceProtos {
size += com.google.protobuf.CodedOutputStream size += com.google.protobuf.CodedOutputStream
.computeBoolSize(1, isApproved_); .computeBoolSize(1, isApproved_);
} }
if (((bitField0_ & 0x00000002) == 0x00000002)) {
size += com.google.protobuf.CodedOutputStream
.computeBytesSize(2, profileKey_);
}
if (((bitField0_ & 0x00000004) == 0x00000004)) {
size += com.google.protobuf.CodedOutputStream
.computeMessageSize(3, profile_);
}
size += getUnknownFields().getSerializedSize(); size += getUnknownFields().getSerializedSize();
memoizedSerializedSize = size; memoizedSerializedSize = size;
return size; return size;
@ -21768,6 +21864,7 @@ public final class SignalServiceProtos {
} }
private void maybeForceBuilderInitialization() { private void maybeForceBuilderInitialization() {
if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) {
getProfileFieldBuilder();
} }
} }
private static Builder create() { private static Builder create() {
@ -21778,6 +21875,14 @@ public final class SignalServiceProtos {
super.clear(); super.clear();
isApproved_ = false; isApproved_ = false;
bitField0_ = (bitField0_ & ~0x00000001); bitField0_ = (bitField0_ & ~0x00000001);
profileKey_ = com.google.protobuf.ByteString.EMPTY;
bitField0_ = (bitField0_ & ~0x00000002);
if (profileBuilder_ == null) {
profile_ = org.session.libsignal.protos.SignalServiceProtos.DataMessage.LokiProfile.getDefaultInstance();
} else {
profileBuilder_.clear();
}
bitField0_ = (bitField0_ & ~0x00000004);
return this; return this;
} }
@ -21810,6 +21915,18 @@ public final class SignalServiceProtos {
to_bitField0_ |= 0x00000001; to_bitField0_ |= 0x00000001;
} }
result.isApproved_ = isApproved_; result.isApproved_ = isApproved_;
if (((from_bitField0_ & 0x00000002) == 0x00000002)) {
to_bitField0_ |= 0x00000002;
}
result.profileKey_ = profileKey_;
if (((from_bitField0_ & 0x00000004) == 0x00000004)) {
to_bitField0_ |= 0x00000004;
}
if (profileBuilder_ == null) {
result.profile_ = profile_;
} else {
result.profile_ = profileBuilder_.build();
}
result.bitField0_ = to_bitField0_; result.bitField0_ = to_bitField0_;
onBuilt(); onBuilt();
return result; return result;
@ -21829,6 +21946,12 @@ public final class SignalServiceProtos {
if (other.hasIsApproved()) { if (other.hasIsApproved()) {
setIsApproved(other.getIsApproved()); setIsApproved(other.getIsApproved());
} }
if (other.hasProfileKey()) {
setProfileKey(other.getProfileKey());
}
if (other.hasProfile()) {
mergeProfile(other.getProfile());
}
this.mergeUnknownFields(other.getUnknownFields()); this.mergeUnknownFields(other.getUnknownFields());
return this; return this;
} }
@ -21909,6 +22032,159 @@ public final class SignalServiceProtos {
return this; return this;
} }
// optional bytes profileKey = 2;
private com.google.protobuf.ByteString profileKey_ = com.google.protobuf.ByteString.EMPTY;
/**
* <code>optional bytes profileKey = 2;</code>
*/
public boolean hasProfileKey() {
return ((bitField0_ & 0x00000002) == 0x00000002);
}
/**
* <code>optional bytes profileKey = 2;</code>
*/
public com.google.protobuf.ByteString getProfileKey() {
return profileKey_;
}
/**
* <code>optional bytes profileKey = 2;</code>
*/
public Builder setProfileKey(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
bitField0_ |= 0x00000002;
profileKey_ = value;
onChanged();
return this;
}
/**
* <code>optional bytes profileKey = 2;</code>
*/
public Builder clearProfileKey() {
bitField0_ = (bitField0_ & ~0x00000002);
profileKey_ = getDefaultInstance().getProfileKey();
onChanged();
return this;
}
// optional .signalservice.DataMessage.LokiProfile profile = 3;
private org.session.libsignal.protos.SignalServiceProtos.DataMessage.LokiProfile profile_ = org.session.libsignal.protos.SignalServiceProtos.DataMessage.LokiProfile.getDefaultInstance();
private com.google.protobuf.SingleFieldBuilder<
org.session.libsignal.protos.SignalServiceProtos.DataMessage.LokiProfile, org.session.libsignal.protos.SignalServiceProtos.DataMessage.LokiProfile.Builder, org.session.libsignal.protos.SignalServiceProtos.DataMessage.LokiProfileOrBuilder> profileBuilder_;
/**
* <code>optional .signalservice.DataMessage.LokiProfile profile = 3;</code>
*/
public boolean hasProfile() {
return ((bitField0_ & 0x00000004) == 0x00000004);
}
/**
* <code>optional .signalservice.DataMessage.LokiProfile profile = 3;</code>
*/
public org.session.libsignal.protos.SignalServiceProtos.DataMessage.LokiProfile getProfile() {
if (profileBuilder_ == null) {
return profile_;
} else {
return profileBuilder_.getMessage();
}
}
/**
* <code>optional .signalservice.DataMessage.LokiProfile profile = 3;</code>
*/
public Builder setProfile(org.session.libsignal.protos.SignalServiceProtos.DataMessage.LokiProfile value) {
if (profileBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
profile_ = value;
onChanged();
} else {
profileBuilder_.setMessage(value);
}
bitField0_ |= 0x00000004;
return this;
}
/**
* <code>optional .signalservice.DataMessage.LokiProfile profile = 3;</code>
*/
public Builder setProfile(
org.session.libsignal.protos.SignalServiceProtos.DataMessage.LokiProfile.Builder builderForValue) {
if (profileBuilder_ == null) {
profile_ = builderForValue.build();
onChanged();
} else {
profileBuilder_.setMessage(builderForValue.build());
}
bitField0_ |= 0x00000004;
return this;
}
/**
* <code>optional .signalservice.DataMessage.LokiProfile profile = 3;</code>
*/
public Builder mergeProfile(org.session.libsignal.protos.SignalServiceProtos.DataMessage.LokiProfile value) {
if (profileBuilder_ == null) {
if (((bitField0_ & 0x00000004) == 0x00000004) &&
profile_ != org.session.libsignal.protos.SignalServiceProtos.DataMessage.LokiProfile.getDefaultInstance()) {
profile_ =
org.session.libsignal.protos.SignalServiceProtos.DataMessage.LokiProfile.newBuilder(profile_).mergeFrom(value).buildPartial();
} else {
profile_ = value;
}
onChanged();
} else {
profileBuilder_.mergeFrom(value);
}
bitField0_ |= 0x00000004;
return this;
}
/**
* <code>optional .signalservice.DataMessage.LokiProfile profile = 3;</code>
*/
public Builder clearProfile() {
if (profileBuilder_ == null) {
profile_ = org.session.libsignal.protos.SignalServiceProtos.DataMessage.LokiProfile.getDefaultInstance();
onChanged();
} else {
profileBuilder_.clear();
}
bitField0_ = (bitField0_ & ~0x00000004);
return this;
}
/**
* <code>optional .signalservice.DataMessage.LokiProfile profile = 3;</code>
*/
public org.session.libsignal.protos.SignalServiceProtos.DataMessage.LokiProfile.Builder getProfileBuilder() {
bitField0_ |= 0x00000004;
onChanged();
return getProfileFieldBuilder().getBuilder();
}
/**
* <code>optional .signalservice.DataMessage.LokiProfile profile = 3;</code>
*/
public org.session.libsignal.protos.SignalServiceProtos.DataMessage.LokiProfileOrBuilder getProfileOrBuilder() {
if (profileBuilder_ != null) {
return profileBuilder_.getMessageOrBuilder();
} else {
return profile_;
}
}
/**
* <code>optional .signalservice.DataMessage.LokiProfile profile = 3;</code>
*/
private com.google.protobuf.SingleFieldBuilder<
org.session.libsignal.protos.SignalServiceProtos.DataMessage.LokiProfile, org.session.libsignal.protos.SignalServiceProtos.DataMessage.LokiProfile.Builder, org.session.libsignal.protos.SignalServiceProtos.DataMessage.LokiProfileOrBuilder>
getProfileFieldBuilder() {
if (profileBuilder_ == null) {
profileBuilder_ = new com.google.protobuf.SingleFieldBuilder<
org.session.libsignal.protos.SignalServiceProtos.DataMessage.LokiProfile, org.session.libsignal.protos.SignalServiceProtos.DataMessage.LokiProfile.Builder, org.session.libsignal.protos.SignalServiceProtos.DataMessage.LokiProfileOrBuilder>(
profile_,
getParentForChildren(),
isClean());
profile_ = null;
}
return profileBuilder_;
}
// @@protoc_insertion_point(builder_scope:signalservice.MessageRequestResponse) // @@protoc_insertion_point(builder_scope:signalservice.MessageRequestResponse)
} }
@ -25921,24 +26197,26 @@ public final class SignalServiceProtos {
"\001 \002(\014\022\014\n\004name\030\002 \002(\t\022\026\n\016profilePicture\030\003 ", "\001 \002(\014\022\014\n\004name\030\002 \002(\t\022\026\n\016profilePicture\030\003 ",
"\001(\t\022\022\n\nprofileKey\030\004 \001(\014\022\022\n\nisApproved\030\005 " + "\001(\t\022\022\n\nprofileKey\030\004 \001(\014\022\022\n\nisApproved\030\005 " +
"\001(\010\022\021\n\tisBlocked\030\006 \001(\010\022\024\n\014didApproveMe\030\007" + "\001(\010\022\021\n\tisBlocked\030\006 \001(\010\022\024\n\014didApproveMe\030\007" +
" \001(\010\",\n\026MessageRequestResponse\022\022\n\nisAppr" + " \001(\010\"y\n\026MessageRequestResponse\022\022\n\nisAppr" +
"oved\030\001 \002(\010\"u\n\016ReceiptMessage\0220\n\004type\030\001 \002" + "oved\030\001 \002(\010\022\022\n\nprofileKey\030\002 \001(\014\0227\n\007profil" +
"(\0162\".signalservice.ReceiptMessage.Type\022\021" + "e\030\003 \001(\0132&.signalservice.DataMessage.Loki" +
"\n\ttimestamp\030\002 \003(\004\"\036\n\004Type\022\014\n\010DELIVERY\020\000\022" + "Profile\"u\n\016ReceiptMessage\0220\n\004type\030\001 \002(\0162" +
"\010\n\004READ\020\001\"\354\001\n\021AttachmentPointer\022\n\n\002id\030\001 " + "\".signalservice.ReceiptMessage.Type\022\021\n\tt" +
"\002(\006\022\023\n\013contentType\030\002 \001(\t\022\013\n\003key\030\003 \001(\014\022\014\n" + "imestamp\030\002 \003(\004\"\036\n\004Type\022\014\n\010DELIVERY\020\000\022\010\n\004" +
"\004size\030\004 \001(\r\022\021\n\tthumbnail\030\005 \001(\014\022\016\n\006digest" + "READ\020\001\"\354\001\n\021AttachmentPointer\022\n\n\002id\030\001 \002(\006" +
"\030\006 \001(\014\022\020\n\010fileName\030\007 \001(\t\022\r\n\005flags\030\010 \001(\r\022", "\022\023\n\013contentType\030\002 \001(\t\022\013\n\003key\030\003 \001(\014\022\014\n\004si",
"\r\n\005width\030\t \001(\r\022\016\n\006height\030\n \001(\r\022\017\n\007captio" + "ze\030\004 \001(\r\022\021\n\tthumbnail\030\005 \001(\014\022\016\n\006digest\030\006 " +
"n\030\013 \001(\t\022\013\n\003url\030e \001(\t\"\032\n\005Flags\022\021\n\rVOICE_M" + "\001(\014\022\020\n\010fileName\030\007 \001(\t\022\r\n\005flags\030\010 \001(\r\022\r\n\005" +
"ESSAGE\020\001\"\365\001\n\014GroupContext\022\n\n\002id\030\001 \001(\014\022.\n" + "width\030\t \001(\r\022\016\n\006height\030\n \001(\r\022\017\n\007caption\030\013" +
"\004type\030\002 \001(\0162 .signalservice.GroupContext" + " \001(\t\022\013\n\003url\030e \001(\t\"\032\n\005Flags\022\021\n\rVOICE_MESS" +
".Type\022\014\n\004name\030\003 \001(\t\022\017\n\007members\030\004 \003(\t\0220\n\006" + "AGE\020\001\"\365\001\n\014GroupContext\022\n\n\002id\030\001 \001(\014\022.\n\004ty" +
"avatar\030\005 \001(\0132 .signalservice.AttachmentP" + "pe\030\002 \001(\0162 .signalservice.GroupContext.Ty" +
"ointer\022\016\n\006admins\030\006 \003(\t\"H\n\004Type\022\013\n\007UNKNOW" + "pe\022\014\n\004name\030\003 \001(\t\022\017\n\007members\030\004 \003(\t\0220\n\006ava" +
"N\020\000\022\n\n\006UPDATE\020\001\022\013\n\007DELIVER\020\002\022\010\n\004QUIT\020\003\022\020" + "tar\030\005 \001(\0132 .signalservice.AttachmentPoin" +
"\n\014REQUEST_INFO\020\004B3\n\034org.session.libsigna" + "ter\022\016\n\006admins\030\006 \003(\t\"H\n\004Type\022\013\n\007UNKNOWN\020\000" +
"l.protosB\023SignalServiceProtos" "\022\n\n\006UPDATE\020\001\022\013\n\007DELIVER\020\002\022\010\n\004QUIT\020\003\022\020\n\014R",
"EQUEST_INFO\020\004B3\n\034org.session.libsignal.p" +
"rotosB\023SignalServiceProtos"
}; };
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
@ -26064,7 +26342,7 @@ public final class SignalServiceProtos {
internal_static_signalservice_MessageRequestResponse_fieldAccessorTable = new internal_static_signalservice_MessageRequestResponse_fieldAccessorTable = new
com.google.protobuf.GeneratedMessage.FieldAccessorTable( com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_signalservice_MessageRequestResponse_descriptor, internal_static_signalservice_MessageRequestResponse_descriptor,
new java.lang.String[] { "IsApproved", }); new java.lang.String[] { "IsApproved", "ProfileKey", "Profile", });
internal_static_signalservice_ReceiptMessage_descriptor = internal_static_signalservice_ReceiptMessage_descriptor =
getDescriptor().getMessageTypes().get(10); getDescriptor().getMessageTypes().get(10);
internal_static_signalservice_ReceiptMessage_fieldAccessorTable = new internal_static_signalservice_ReceiptMessage_fieldAccessorTable = new