mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Canonicalize recipient addresses
This commit is contained in:
parent
0a7a6a5c54
commit
960e97bc12
2 changed files with 14 additions and 4 deletions
|
@ -24,7 +24,7 @@ import org.whispersystems.textsecure.api.TextSecureMessageSender;
|
||||||
import org.whispersystems.textsecure.api.crypto.UntrustedIdentityException;
|
import org.whispersystems.textsecure.api.crypto.UntrustedIdentityException;
|
||||||
import org.whispersystems.textsecure.api.messages.*;
|
import org.whispersystems.textsecure.api.messages.*;
|
||||||
import org.whispersystems.textsecure.api.messages.multidevice.TextSecureSyncMessage;
|
import org.whispersystems.textsecure.api.messages.multidevice.TextSecureSyncMessage;
|
||||||
import org.whispersystems.textsecure.api.push.TextSecureAddress;
|
import org.whispersystems.textsecure.api.util.InvalidNumberException;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
|
@ -152,9 +152,9 @@ public class Main {
|
||||||
TextSecureDataMessage message = messageBuilder.build();
|
TextSecureDataMessage message = messageBuilder.build();
|
||||||
for (String recipient : ns.<String>getList("recipient")) {
|
for (String recipient : ns.<String>getList("recipient")) {
|
||||||
try {
|
try {
|
||||||
messageSender.sendMessage(new TextSecureAddress(recipient), message);
|
messageSender.sendMessage(m.getPushAddress(recipient), message);
|
||||||
} catch (UntrustedIdentityException | IOException e) {
|
} catch (UntrustedIdentityException | IOException | InvalidNumberException e) {
|
||||||
System.out.println("Send message: " + e.getMessage());
|
System.out.println("Failed to send message to \"" + recipient + "\": " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -206,4 +206,14 @@ public class Manager {
|
||||||
messagePipe.shutdown();
|
messagePipe.shutdown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String canonicalizeNumber(String number) throws InvalidNumberException {
|
||||||
|
String localNumber = username;
|
||||||
|
return PhoneNumberFormatter.formatNumber(number, localNumber);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected TextSecureAddress getPushAddress(String number) throws InvalidNumberException {
|
||||||
|
String e164number = canonicalizeNumber(number);
|
||||||
|
return new TextSecureAddress(e164number);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue