Add voip push support in communication with push server.

// FREEBIE
This commit is contained in:
Moxie Marlinspike 2015-03-25 15:59:52 -07:00
parent 1fcd1e33c5
commit e0f7ff325a
3 changed files with 15 additions and 4 deletions

View File

@ -5,6 +5,7 @@ import com.google.common.annotations.VisibleForTesting;
import org.hibernate.validator.constraints.NotEmpty;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
public class ApnMessage {
@JsonProperty
@ -23,12 +24,17 @@ public class ApnMessage {
@NotEmpty
private String message;
@JsonProperty
@NotNull
private boolean voip;
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.number = number;
this.deviceId = deviceId;
this.message = message;
this.voip = voip;
}
}

View File

@ -26,7 +26,7 @@ public class ApnRegistrationId {
private String apnRegistrationId;
@JsonProperty
String voipRegistrationId;
private String voipRegistrationId;
public String getApnRegistrationId() {
return apnRegistrationId;

View File

@ -25,6 +25,7 @@ import org.whispersystems.textsecuregcm.entities.GcmMessage;
import org.whispersystems.textsecuregcm.push.WebsocketSender.DeliveryStatus;
import org.whispersystems.textsecuregcm.storage.Account;
import org.whispersystems.textsecuregcm.storage.Device;
import org.whispersystems.textsecuregcm.util.Util;
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);
if (!deliveryStatus.isDelivered() && outgoingMessage.getType() != OutgoingMessageSignal.Type.RECEIPT_VALUE) {
ApnMessage apnMessage = new ApnMessage(device.getApnId(), account.getNumber(), (int)device.getId(),
String.format(APN_PAYLOAD, deliveryStatus.getMessageQueueDepth()));
String apnId = Util.isEmpty(device.getVoipApnId()) ? device.getApnId() : device.getVoipApnId();
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);
}
}