mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-27 20:15:21 +00:00
Fixed link preview messages not being deleted in group chats.
This commit is contained in:
parent
f209784648
commit
9d8de789d7
@ -780,6 +780,10 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
|
||||
}
|
||||
|
||||
private void handleMediaMessage(@NonNull SignalServiceContent content, @NonNull IncomingMediaMessage mediaMessage, @NonNull Optional<Long> smsMessageID) throws StorageFailedException {
|
||||
handleMediaMessage(content, mediaMessage, smsMessageID, null);
|
||||
}
|
||||
|
||||
private void handleMediaMessage(@NonNull SignalServiceContent content, @NonNull IncomingMediaMessage mediaMessage, @NonNull Optional<Long> smsMessageID, @Nullable Optional<Long> messageServerIDOrNull) throws StorageFailedException {
|
||||
MmsDatabase database = DatabaseFactory.getMmsDatabase(context);
|
||||
database.beginTransaction();
|
||||
|
||||
@ -811,6 +815,9 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
|
||||
database.endTransaction();
|
||||
}
|
||||
|
||||
// Loki - Map message id to server id
|
||||
updatePublicChatMessageWithServerID(messageServerIDOrNull, insertResult);
|
||||
|
||||
if (insertResult.isPresent()) {
|
||||
MessageNotifier.updateNotification(context, insertResult.get().getThreadId());
|
||||
}
|
||||
@ -963,7 +970,7 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
|
||||
if (lp.isPresent()) { mediaMessage.getLinkPreviews().add(lp.get()); }
|
||||
if (c == urlCount) {
|
||||
try {
|
||||
handleMediaMessage(content, mediaMessage, smsMessageId);
|
||||
handleMediaMessage(content, mediaMessage, smsMessageId, messageServerIDOrNull);
|
||||
} catch (Exception e) {
|
||||
// TODO: Handle
|
||||
}
|
||||
@ -978,11 +985,8 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
|
||||
|
||||
if (smsMessageId.isPresent()) database.deleteMessage(smsMessageId.get());
|
||||
|
||||
if (insertResult.isPresent() && messageServerIDOrNull.isPresent()) {
|
||||
long messageID = insertResult.get().getMessageId();
|
||||
long messageServerID = messageServerIDOrNull.get();
|
||||
DatabaseFactory.getLokiMessageDatabase(context).setServerID(messageID, messageServerID);
|
||||
}
|
||||
// Loki - Map message id to server id
|
||||
updatePublicChatMessageWithServerID(messageServerIDOrNull, insertResult);
|
||||
|
||||
if (threadId != null) {
|
||||
MessageNotifier.updateNotification(context, threadId);
|
||||
@ -991,6 +995,15 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
|
||||
}
|
||||
}
|
||||
|
||||
private void updatePublicChatMessageWithServerID(@Nullable Optional<Long> messageServerIDOrNull, Optional<InsertResult> databaseInsert) {
|
||||
if (messageServerIDOrNull == null) { return; }
|
||||
if (databaseInsert.isPresent() && messageServerIDOrNull.isPresent()) {
|
||||
long messageID = databaseInsert.get().getMessageId();
|
||||
long messageServerID = messageServerIDOrNull.get();
|
||||
DatabaseFactory.getLokiMessageDatabase(context).setServerID(messageID, messageServerID);
|
||||
}
|
||||
}
|
||||
|
||||
private void acceptFriendRequestIfNeeded(@NonNull SignalServiceEnvelope envelope, @NonNull SignalServiceContent content) {
|
||||
// If we get anything other than a friend request, we can assume that we have a session with the other user
|
||||
if (envelope.isFriendRequest()) { return; }
|
||||
|
Loading…
Reference in New Issue
Block a user