mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-20 13:38:06 +01:00
Add logic to handle sending a common payload to multiple recipients
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright 2021 Signal Messenger, LLC
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
package org.whispersystems.textsecuregcm.entities;
|
||||
|
||||
import java.util.UUID;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import org.whispersystems.textsecuregcm.providers.MultiRecipientMessageProvider;
|
||||
|
||||
public class MultiRecipientMessage {
|
||||
|
||||
public static class Recipient {
|
||||
|
||||
@NotNull
|
||||
private final UUID uuid;
|
||||
|
||||
@Min(1)
|
||||
private final long deviceId;
|
||||
|
||||
@Size(min = 48, max = 48)
|
||||
@NotNull
|
||||
private final byte[] perRecipientKeyMaterial;
|
||||
|
||||
public Recipient(UUID uuid, long deviceId, byte[] perRecipientKeyMaterial) {
|
||||
this.uuid = uuid;
|
||||
this.deviceId = deviceId;
|
||||
this.perRecipientKeyMaterial = perRecipientKeyMaterial;
|
||||
}
|
||||
|
||||
public UUID getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public long getDeviceId() {
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
public byte[] getPerRecipientKeyMaterial() {
|
||||
return perRecipientKeyMaterial;
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Size(min = 1, max = MultiRecipientMessageProvider.MAX_RECIPIENT_COUNT)
|
||||
private final Recipient[] recipients;
|
||||
|
||||
@NotNull
|
||||
@Min(32)
|
||||
private final byte[] commonPayload;
|
||||
|
||||
public MultiRecipientMessage(Recipient[] recipients, byte[] commonPayload) {
|
||||
this.recipients = recipients;
|
||||
this.commonPayload = commonPayload;
|
||||
}
|
||||
|
||||
public Recipient[] getRecipients() {
|
||||
return recipients;
|
||||
}
|
||||
|
||||
public byte[] getCommonPayload() {
|
||||
return commonPayload;
|
||||
}
|
||||
}
|
||||
@@ -6,16 +6,24 @@
|
||||
package org.whispersystems.textsecuregcm.entities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class SendMessageResponse {
|
||||
|
||||
@JsonProperty
|
||||
private boolean needsSync;
|
||||
|
||||
@JsonProperty
|
||||
private List<UUID> uuids404;
|
||||
|
||||
public SendMessageResponse() {}
|
||||
|
||||
public SendMessageResponse(boolean needsSync) {
|
||||
this.needsSync = needsSync;
|
||||
}
|
||||
|
||||
public SendMessageResponse(List<UUID> uuids404) {
|
||||
this.uuids404 = uuids404;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user