- try {
- if ("read".equals(type)) {
- m.sendReadReceipt(recipient, targetTimestamps);
- } else if ("viewed".equals(type)) {
- m.sendViewedReceipt(recipient, targetTimestamps);
- } else {
- throw new UserErrorException("Unknown receipt type: " + type);
- }
- } catch (IOException | UntrustedIdentityException e) {
- throw new UserErrorException("Failed to send message: " + e.getMessage());
- } catch (InvalidNumberException e) {
- throw new UserErrorException("Invalid number: " + e.getMessage());
+ final SendMessageResults results;
+ if (type == null || "read".equals(type)) {
+ results = m.sendReadReceipt(recipient, targetTimestamps);
+ } else if ("viewed".equals(type)) {
+ results = m.sendViewedReceipt(recipient, targetTimestamps);
+ } else {
+ throw new UserErrorException("Unknown receipt type: " + type);