Add voip push support in communication with push server.
// FREEBIE
This commit is contained in:
parent
1fcd1e33c5
commit
e0f7ff325a
|
@ -5,6 +5,7 @@ import com.google.common.annotations.VisibleForTesting;
|
||||||
import org.hibernate.validator.constraints.NotEmpty;
|
import org.hibernate.validator.constraints.NotEmpty;
|
||||||
|
|
||||||
import javax.validation.constraints.Min;
|
import javax.validation.constraints.Min;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
public class ApnMessage {
|
public class ApnMessage {
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
|
@ -23,12 +24,17 @@ public class ApnMessage {
|
||||||
@NotEmpty
|
@NotEmpty
|
||||||
private String message;
|
private String message;
|
||||||
|
|
||||||
|
@JsonProperty
|
||||||
|
@NotNull
|
||||||
|
private boolean voip;
|
||||||
|
|
||||||
public ApnMessage() {}
|
public ApnMessage() {}
|
||||||
|
|
||||||
public ApnMessage(String apnId, String number, int deviceId, String message) {
|
public ApnMessage(String apnId, String number, int deviceId, String message, boolean voip) {
|
||||||
this.apnId = apnId;
|
this.apnId = apnId;
|
||||||
this.number = number;
|
this.number = number;
|
||||||
this.deviceId = deviceId;
|
this.deviceId = deviceId;
|
||||||
this.message = message;
|
this.message = message;
|
||||||
|
this.voip = voip;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ public class ApnRegistrationId {
|
||||||
private String apnRegistrationId;
|
private String apnRegistrationId;
|
||||||
|
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
String voipRegistrationId;
|
private String voipRegistrationId;
|
||||||
|
|
||||||
public String getApnRegistrationId() {
|
public String getApnRegistrationId() {
|
||||||
return apnRegistrationId;
|
return apnRegistrationId;
|
||||||
|
|
|
@ -25,6 +25,7 @@ import org.whispersystems.textsecuregcm.entities.GcmMessage;
|
||||||
import org.whispersystems.textsecuregcm.push.WebsocketSender.DeliveryStatus;
|
import org.whispersystems.textsecuregcm.push.WebsocketSender.DeliveryStatus;
|
||||||
import org.whispersystems.textsecuregcm.storage.Account;
|
import org.whispersystems.textsecuregcm.storage.Account;
|
||||||
import org.whispersystems.textsecuregcm.storage.Device;
|
import org.whispersystems.textsecuregcm.storage.Device;
|
||||||
|
import org.whispersystems.textsecuregcm.util.Util;
|
||||||
|
|
||||||
import static org.whispersystems.textsecuregcm.entities.MessageProtos.OutgoingMessageSignal;
|
import static org.whispersystems.textsecuregcm.entities.MessageProtos.OutgoingMessageSignal;
|
||||||
|
|
||||||
|
@ -99,8 +100,12 @@ public class PushSender {
|
||||||
DeliveryStatus deliveryStatus = webSocketSender.sendMessage(account, device, outgoingMessage, WebsocketSender.Type.APN);
|
DeliveryStatus deliveryStatus = webSocketSender.sendMessage(account, device, outgoingMessage, WebsocketSender.Type.APN);
|
||||||
|
|
||||||
if (!deliveryStatus.isDelivered() && outgoingMessage.getType() != OutgoingMessageSignal.Type.RECEIPT_VALUE) {
|
if (!deliveryStatus.isDelivered() && outgoingMessage.getType() != OutgoingMessageSignal.Type.RECEIPT_VALUE) {
|
||||||
ApnMessage apnMessage = new ApnMessage(device.getApnId(), account.getNumber(), (int)device.getId(),
|
String apnId = Util.isEmpty(device.getVoipApnId()) ? device.getApnId() : device.getVoipApnId();
|
||||||
String.format(APN_PAYLOAD, deliveryStatus.getMessageQueueDepth()));
|
boolean isVoip = !Util.isEmpty(device.getVoipApnId());
|
||||||
|
|
||||||
|
ApnMessage apnMessage = new ApnMessage(apnId, account.getNumber(), (int)device.getId(),
|
||||||
|
String.format(APN_PAYLOAD, deliveryStatus.getMessageQueueDepth()),
|
||||||
|
isVoip);
|
||||||
pushServiceClient.send(apnMessage);
|
pushServiceClient.send(apnMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue