Convert attachment descriptors to records

This commit is contained in:
Jon Chambers
2023-04-18 14:45:16 -04:00
committed by Jon Chambers
parent 1083d8bde0
commit dd27e3b0c8
3 changed files with 31 additions and 141 deletions

View File

@@ -7,87 +7,17 @@ package org.whispersystems.textsecuregcm.entities;
import com.fasterxml.jackson.annotation.JsonProperty;
public class AttachmentDescriptorV2 {
public record AttachmentDescriptorV2(long attachmentId,
String key,
String credential,
String acl,
String algorithm,
String date,
String policy,
String signature) {
@JsonProperty
private String key;
@JsonProperty
private String credential;
@JsonProperty
private String acl;
@JsonProperty
private String algorithm;
@JsonProperty
private String date;
@JsonProperty
private String policy;
@JsonProperty
private String signature;
@JsonProperty
private long attachmentId;
@JsonProperty
private String attachmentIdString;
public AttachmentDescriptorV2() {}
public AttachmentDescriptorV2(long attachmentId,
String key, String credential,
String acl, String algorithm,
String date, String policy,
String signature)
{
this.attachmentId = attachmentId;
this.attachmentIdString = String.valueOf(attachmentId);
this.key = key;
this.credential = credential;
this.acl = acl;
this.algorithm = algorithm;
this.date = date;
this.policy = policy;
this.signature = signature;
}
public String getKey() {
return key;
}
public String getCredential() {
return credential;
}
public String getAcl() {
return acl;
}
public String getAlgorithm() {
return algorithm;
}
public String getDate() {
return date;
}
public String getPolicy() {
return policy;
}
public String getSignature() {
return signature;
}
public long getAttachmentId() {
return attachmentId;
}
public String getAttachmentIdString() {
return attachmentIdString;
public String attachmentIdString() {
return String.valueOf(attachmentId);
}
}

View File

@@ -5,47 +5,7 @@
package org.whispersystems.textsecuregcm.entities;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Map;
public class AttachmentDescriptorV3 {
@JsonProperty
private int cdn;
@JsonProperty
private String key;
@JsonProperty
private Map<String, String> headers;
@JsonProperty
private String signedUploadLocation;
public AttachmentDescriptorV3() {
}
public AttachmentDescriptorV3(int cdn, String key, Map<String, String> headers, String signedUploadLocation) {
this.cdn = cdn;
this.key = key;
this.headers = headers;
this.signedUploadLocation = signedUploadLocation;
}
public int getCdn() {
return cdn;
}
public String getKey() {
return key;
}
public Map<String, String> getHeaders() {
return headers;
}
public String getSignedUploadLocation() {
return signedUploadLocation;
}
public record AttachmentDescriptorV3(int cdn, String key, Map<String, String> headers, String signedUploadLocation) {
}