mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-05-08 09:18:39 +01:00
Ensure images sent to stories respect media quality settings.
Stories should always use "Standard" quality, not L3 (high quality). This change ensures that we: 1. Always send stories at the appropriate quality 2. Do not corrupt or overwrite pre-existing image attachments 3. Close several streams when done (thanks StrictMode!)
This commit is contained in:
committed by
Cody Henthorne
parent
c4bef8099f
commit
b18542a839
+8
-1
@@ -10,13 +10,15 @@ package org.whispersystems.signalservice.api.messages;
|
||||
import org.whispersystems.signalservice.internal.push.http.CancelationSignal;
|
||||
import org.whispersystems.signalservice.internal.push.http.ResumableUploadSpec;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Represents a local SignalServiceAttachment to be sent.
|
||||
*/
|
||||
public class SignalServiceAttachmentStream extends SignalServiceAttachment {
|
||||
public class SignalServiceAttachmentStream extends SignalServiceAttachment implements Closeable {
|
||||
|
||||
private final InputStream inputStream;
|
||||
private final long length;
|
||||
@@ -151,4 +153,9 @@ public class SignalServiceAttachmentStream extends SignalServiceAttachment {
|
||||
public Optional<ResumableUploadSpec> getResumableUploadSpec() {
|
||||
return resumableUploadSpec;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
inputStream.close();
|
||||
}
|
||||
}
|
||||
|
||||
+3
-9
@@ -1450,17 +1450,11 @@ public class PushServiceSocket {
|
||||
connections.add(call);
|
||||
}
|
||||
|
||||
try {
|
||||
Response response;
|
||||
|
||||
try {
|
||||
response = call.execute();
|
||||
} catch (IOException e) {
|
||||
throw new PushNetworkException(e);
|
||||
}
|
||||
|
||||
try (Response response = call.execute()) {
|
||||
if (response.isSuccessful()) return file.getTransmittedDigest();
|
||||
else throw new NonSuccessfulResponseCodeException(response.code(), "Response: " + response);
|
||||
} catch (IOException e) {
|
||||
throw new PushNetworkException(e);
|
||||
} finally {
|
||||
synchronized (connections) {
|
||||
connections.remove(call);
|
||||
|
||||
Reference in New Issue
Block a user