mirror of
https://github.com/oxen-io/session-android.git
synced 2025-08-11 17:27:42 +00:00
Fix message disappearance after send
This commit is contained in:
@@ -26,6 +26,7 @@ public class IncomingMediaMessage {
|
||||
private final long sentTimeMillis;
|
||||
private final int subscriptionId;
|
||||
private final long expiresIn;
|
||||
private final long expireStartedAt;
|
||||
private final boolean expirationUpdate;
|
||||
private final boolean unidentified;
|
||||
private final boolean messageRequestResponse;
|
||||
@@ -41,6 +42,7 @@ public class IncomingMediaMessage {
|
||||
long sentTimeMillis,
|
||||
int subscriptionId,
|
||||
long expiresIn,
|
||||
long expireStartedAt,
|
||||
boolean expirationUpdate,
|
||||
boolean unidentified,
|
||||
boolean messageRequestResponse,
|
||||
@@ -58,6 +60,7 @@ public class IncomingMediaMessage {
|
||||
this.body = body.orNull();
|
||||
this.subscriptionId = subscriptionId;
|
||||
this.expiresIn = expiresIn;
|
||||
this.expireStartedAt = expireStartedAt;
|
||||
this.expirationUpdate = expirationUpdate;
|
||||
this.dataExtractionNotification = dataExtractionNotification.orNull();
|
||||
this.quote = quote.orNull();
|
||||
@@ -75,12 +78,13 @@ public class IncomingMediaMessage {
|
||||
public static IncomingMediaMessage from(VisibleMessage message,
|
||||
Address from,
|
||||
long expiresIn,
|
||||
long expireStartedAt,
|
||||
Optional<SignalServiceGroup> group,
|
||||
List<SignalServiceAttachment> attachments,
|
||||
Optional<QuoteModel> quote,
|
||||
Optional<List<LinkPreview>> linkPreviews)
|
||||
{
|
||||
return new IncomingMediaMessage(from, message.getSentTimestamp(), -1, expiresIn, false,
|
||||
return new IncomingMediaMessage(from, message.getSentTimestamp(), -1, expiresIn, expireStartedAt, false,
|
||||
false, false, Optional.fromNullable(message.getText()), group, Optional.fromNullable(attachments), quote, Optional.absent(), linkPreviews, Optional.absent());
|
||||
}
|
||||
|
||||
@@ -120,6 +124,10 @@ public class IncomingMediaMessage {
|
||||
return expiresIn;
|
||||
}
|
||||
|
||||
public long getExpireStartedAt() {
|
||||
return expireStartedAt;
|
||||
}
|
||||
|
||||
public boolean isGroupMessage() {
|
||||
return groupId != null;
|
||||
}
|
||||
|
@@ -11,9 +11,9 @@ public class OutgoingExpirationUpdateMessage extends OutgoingSecureMediaMessage
|
||||
|
||||
private final String groupId;
|
||||
|
||||
public OutgoingExpirationUpdateMessage(Recipient recipient, long sentTimeMillis, long expiresIn, String groupId) {
|
||||
public OutgoingExpirationUpdateMessage(Recipient recipient, long sentTimeMillis, long expiresIn, long expireStartedAt, String groupId) {
|
||||
super(recipient, "", new LinkedList<Attachment>(), sentTimeMillis,
|
||||
DistributionTypes.CONVERSATION, expiresIn, null, Collections.emptyList(),
|
||||
DistributionTypes.CONVERSATION, expiresIn, expireStartedAt, null, Collections.emptyList(),
|
||||
Collections.emptyList());
|
||||
this.groupId = groupId;
|
||||
}
|
||||
|
@@ -24,6 +24,7 @@ public class OutgoingGroupMediaMessage extends OutgoingSecureMediaMessage {
|
||||
@Nullable final Attachment avatar,
|
||||
long sentTime,
|
||||
long expireIn,
|
||||
long expireStartedAt,
|
||||
boolean updateMessage,
|
||||
@Nullable QuoteModel quote,
|
||||
@NonNull List<Contact> contacts,
|
||||
@@ -32,7 +33,7 @@ public class OutgoingGroupMediaMessage extends OutgoingSecureMediaMessage {
|
||||
super(recipient, body,
|
||||
new LinkedList<Attachment>() {{if (avatar != null) add(avatar);}},
|
||||
sentTime,
|
||||
DistributionTypes.CONVERSATION, expireIn, quote, contacts, previews);
|
||||
DistributionTypes.CONVERSATION, expireIn, expireStartedAt, quote, contacts, previews);
|
||||
|
||||
this.groupID = groupId;
|
||||
this.isUpdateMessage = updateMessage;
|
||||
|
@@ -26,6 +26,7 @@ public class OutgoingMediaMessage {
|
||||
private final int distributionType;
|
||||
private final int subscriptionId;
|
||||
private final long expiresIn;
|
||||
private final long expireStartedAt;
|
||||
private final QuoteModel outgoingQuote;
|
||||
|
||||
private final List<NetworkFailure> networkFailures = new LinkedList<>();
|
||||
@@ -35,7 +36,7 @@ public class OutgoingMediaMessage {
|
||||
|
||||
public OutgoingMediaMessage(Recipient recipient, String message,
|
||||
List<Attachment> attachments, long sentTimeMillis,
|
||||
int subscriptionId, long expiresIn,
|
||||
int subscriptionId, long expiresIn, long expireStartedAt,
|
||||
int distributionType,
|
||||
@Nullable QuoteModel outgoingQuote,
|
||||
@NonNull List<Contact> contacts,
|
||||
@@ -50,6 +51,7 @@ public class OutgoingMediaMessage {
|
||||
this.attachments = attachments;
|
||||
this.subscriptionId = subscriptionId;
|
||||
this.expiresIn = expiresIn;
|
||||
this.expireStartedAt = expireStartedAt;
|
||||
this.outgoingQuote = outgoingQuote;
|
||||
|
||||
this.contacts.addAll(contacts);
|
||||
@@ -66,6 +68,7 @@ public class OutgoingMediaMessage {
|
||||
this.sentTimeMillis = that.sentTimeMillis;
|
||||
this.subscriptionId = that.subscriptionId;
|
||||
this.expiresIn = that.expiresIn;
|
||||
this.expireStartedAt = that.expireStartedAt;
|
||||
this.outgoingQuote = that.outgoingQuote;
|
||||
|
||||
this.identityKeyMismatches.addAll(that.identityKeyMismatches);
|
||||
@@ -79,14 +82,15 @@ public class OutgoingMediaMessage {
|
||||
List<Attachment> attachments,
|
||||
@Nullable QuoteModel outgoingQuote,
|
||||
@Nullable LinkPreview linkPreview,
|
||||
long expiresInMillis)
|
||||
long expiresInMillis,
|
||||
long expireStartedAt)
|
||||
{
|
||||
List<LinkPreview> previews = Collections.emptyList();
|
||||
if (linkPreview != null) {
|
||||
previews = Collections.singletonList(linkPreview);
|
||||
}
|
||||
return new OutgoingMediaMessage(recipient, message.getText(), attachments, message.getSentTimestamp(), -1,
|
||||
expiresInMillis, DistributionTypes.DEFAULT, outgoingQuote, Collections.emptyList(),
|
||||
expiresInMillis, expireStartedAt, DistributionTypes.DEFAULT, outgoingQuote, Collections.emptyList(),
|
||||
previews, Collections.emptyList(), Collections.emptyList());
|
||||
}
|
||||
|
||||
@@ -124,6 +128,10 @@ public class OutgoingMediaMessage {
|
||||
return expiresIn;
|
||||
}
|
||||
|
||||
public long getExpireStartedAt() {
|
||||
return expireStartedAt;
|
||||
}
|
||||
|
||||
public @Nullable QuoteModel getOutgoingQuote() {
|
||||
return outgoingQuote;
|
||||
}
|
||||
|
@@ -19,11 +19,12 @@ public class OutgoingSecureMediaMessage extends OutgoingMediaMessage {
|
||||
long sentTimeMillis,
|
||||
int distributionType,
|
||||
long expiresIn,
|
||||
long expireStartedAt,
|
||||
@Nullable QuoteModel quote,
|
||||
@NonNull List<Contact> contacts,
|
||||
@NonNull List<LinkPreview> previews)
|
||||
{
|
||||
super(recipient, body, attachments, sentTimeMillis, -1, expiresIn, distributionType, quote, contacts, previews, Collections.emptyList(), Collections.emptyList());
|
||||
super(recipient, body, attachments, sentTimeMillis, -1, expiresIn, expireStartedAt, distributionType, quote, contacts, previews, Collections.emptyList(), Collections.emptyList());
|
||||
}
|
||||
|
||||
public OutgoingSecureMediaMessage(OutgoingMediaMessage base) {
|
||||
|
@@ -105,7 +105,7 @@ fun updateExpirationConfigurationIfNeeded(message: Message, proto: SignalService
|
||||
)
|
||||
storage.setExpirationConfiguration(remoteConfig)
|
||||
if (message is ExpirationTimerUpdate) {
|
||||
SSKEnvironment.shared.messageExpirationManager.setExpirationTimer(message)
|
||||
SSKEnvironment.shared.messageExpirationManager.setExpirationTimer(message, type?.number ?: -1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,7 +181,7 @@ private fun MessageReceiver.handleExpirationTimerUpdate(message: ExpirationTimer
|
||||
} catch (e: Exception) {
|
||||
Log.e("Loki", "Failed to update expiration configuration.")
|
||||
}
|
||||
SSKEnvironment.shared.messageExpirationManager.setExpirationTimer(message)
|
||||
SSKEnvironment.shared.messageExpirationManager.setExpirationTimer(message, type?.number ?: -1)
|
||||
}
|
||||
|
||||
private fun MessageReceiver.handleDataExtractionNotification(message: DataExtractionNotification) {
|
||||
|
@@ -36,7 +36,7 @@ class SSKEnvironment(
|
||||
}
|
||||
|
||||
interface MessageExpirationManagerProtocol {
|
||||
fun setExpirationTimer(message: ExpirationTimerUpdate)
|
||||
fun setExpirationTimer(message: ExpirationTimerUpdate, expiryType: Int)
|
||||
fun startAnyExpiration(timestamp: Long, author: String)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user