mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 10:30:38 +00:00
Extract getMessageReceiver method
This commit is contained in:
parent
8ad9c9b0ff
commit
df81911e44
1 changed files with 7 additions and 3 deletions
|
@ -414,6 +414,10 @@ public class Manager implements Signal {
|
|||
accountManager.setPreKeys(getIdentity(), signedPreKeyRecord, oneTimePreKeys);
|
||||
}
|
||||
|
||||
private SignalServiceMessageReceiver getMessageReceiver() {
|
||||
return new SignalServiceMessageReceiver(BaseConfig.serviceConfiguration, username, account.getPassword(), account.getDeviceId(), account.getSignalingKey(), BaseConfig.USER_AGENT, null, timer);
|
||||
}
|
||||
|
||||
private Optional<SignalServiceAttachmentStream> createGroupAvatarAttachment(byte[] groupId) throws IOException {
|
||||
File file = getGroupAvatarFile(groupId);
|
||||
if (!file.exists()) {
|
||||
|
@ -1084,7 +1088,7 @@ public class Manager implements Signal {
|
|||
|
||||
public void receiveMessages(long timeout, TimeUnit unit, boolean returnOnTimeout, boolean ignoreAttachments, ReceiveMessageHandler handler) throws IOException {
|
||||
retryFailedReceivedMessages(handler, ignoreAttachments);
|
||||
final SignalServiceMessageReceiver messageReceiver = new SignalServiceMessageReceiver(BaseConfig.serviceConfiguration, username, account.getPassword(), account.getDeviceId(), account.getSignalingKey(), BaseConfig.USER_AGENT, null, timer);
|
||||
final SignalServiceMessageReceiver messageReceiver = getMessageReceiver();
|
||||
|
||||
try {
|
||||
if (messagePipe == null) {
|
||||
|
@ -1346,7 +1350,7 @@ public class Manager implements Signal {
|
|||
}
|
||||
}
|
||||
|
||||
final SignalServiceMessageReceiver messageReceiver = new SignalServiceMessageReceiver(BaseConfig.serviceConfiguration, username, account.getPassword(), account.getDeviceId(), account.getSignalingKey(), BaseConfig.USER_AGENT, null, timer);
|
||||
final SignalServiceMessageReceiver messageReceiver = getMessageReceiver();
|
||||
|
||||
File tmpFile = IOUtils.createTempFile();
|
||||
try (InputStream input = messageReceiver.retrieveAttachment(pointer, tmpFile, BaseConfig.MAX_ATTACHMENT_SIZE)) {
|
||||
|
@ -1372,7 +1376,7 @@ public class Manager implements Signal {
|
|||
}
|
||||
|
||||
private InputStream retrieveAttachmentAsStream(SignalServiceAttachmentPointer pointer, File tmpFile) throws IOException, InvalidMessageException {
|
||||
final SignalServiceMessageReceiver messageReceiver = new SignalServiceMessageReceiver(BaseConfig.serviceConfiguration, username, account.getPassword(), account.getDeviceId(), account.getSignalingKey(), BaseConfig.USER_AGENT, null, timer);
|
||||
final SignalServiceMessageReceiver messageReceiver = getMessageReceiver();
|
||||
return messageReceiver.retrieveAttachment(pointer, tmpFile, BaseConfig.MAX_ATTACHMENT_SIZE);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue