Do not remove onboarding story when disabling stories.

fork-5.53.8
Alex Hart 2022-10-12 13:35:38 -03:00 zatwierdzone przez Greyson Parrelli
rodzic da3623d7e6
commit 8c76cead58
5 zmienionych plików z 35 dodań i 5 usunięć

Wyświetl plik

@ -198,6 +198,7 @@ public abstract class MessageDatabase extends Database implements MmsSmsColumns,
public abstract boolean isStory(long messageId);
public abstract @NonNull Reader getOutgoingStoriesTo(@NonNull RecipientId recipientId);
public abstract @NonNull Reader getAllOutgoingStories(boolean reverse, int limit);
public abstract @NonNull Reader getAllIncomingStoriesExceptOnboarding();
public abstract @NonNull Reader getAllOutgoingStoriesAt(long sentTimestamp);
public abstract @NonNull List<StoryResult> getOrderedStoryRecipientsAndIds(boolean isOutgoingOnly);
public abstract @NonNull Reader getAllStoriesFor(@NonNull RecipientId recipientId, int limit);

Wyświetl plik

@ -635,6 +635,17 @@ public class MmsDatabase extends MessageDatabase {
return new Reader(rawQuery(where, null, reverse, limit));
}
@Override
public @NonNull MessageDatabase.Reader getAllIncomingStoriesExceptOnboarding() {
RecipientId onboardingRecipientId = SignalStore.releaseChannelValues().getReleaseChannelRecipientId();
String where = IS_STORY_CLAUSE + " AND NOT (" + getOutgoingTypeClause() + ")";
if (onboardingRecipientId != null) {
where += " AND " + RECIPIENT_ID + " != " + onboardingRecipientId.serialize();
}
return new Reader(rawQuery(where, null, false, -1L));
}
@Override
public @NonNull MessageDatabase.Reader getAllOutgoingStoriesAt(long sentTimestamp) {
String where = IS_STORY_CLAUSE + " AND " + DATE_SENT + " = ? AND (" + getOutgoingTypeClause() + ")";

Wyświetl plik

@ -1448,6 +1448,11 @@ public class SmsDatabase extends MessageDatabase {
throw new UnsupportedOperationException();
}
@Override
public @NonNull MessageDatabase.Reader getAllIncomingStoriesExceptOnboarding() {
throw new UnsupportedOperationException();
}
@Override
public @NonNull MessageDatabase.Reader getAllOutgoingStoriesAt(long sentTimestamp) {
throw new UnsupportedOperationException();

Wyświetl plik

@ -5,6 +5,7 @@ import org.signal.core.util.CursorUtil
import org.signal.core.util.logging.Log
import org.thoughtcrime.securesms.database.MmsSmsColumns
import org.thoughtcrime.securesms.database.MmsSmsDatabase
import org.thoughtcrime.securesms.database.NoSuchMessageException
import org.thoughtcrime.securesms.database.RecipientDatabase
import org.thoughtcrime.securesms.database.SignalDatabase
import org.thoughtcrime.securesms.database.model.MessageId
@ -39,7 +40,11 @@ object NotificationStateProvider {
val conversationId = ConversationId.fromMessageRecord(record)
val parentRecord = conversationId.groupStoryId?.let {
SignalDatabase.mms.getMessageRecord(it)
try {
SignalDatabase.mms.getMessageRecord(it)
} catch (e : NoSuchMessageException) {
null
}
}
val hasSelfRepliedToGroupStory = conversationId.groupStoryId?.let {

Wyświetl plik

@ -28,10 +28,18 @@ class StoriesPrivacySettingsRepository {
Stories.onStorySettingsChanged(Recipient.self().id)
ApplicationDependencies.resetAllNetworkConnections()
SignalDatabase.mms.getAllOutgoingStories(false, -1).use { reader ->
reader.map { record -> record.id }
}.forEach { messageId ->
MessageSender.sendRemoteDelete(messageId, true)
if (!isEnabled) {
SignalDatabase.mms.getAllOutgoingStories(false, -1).use { reader ->
reader.map { record -> record.id }
}.forEach { messageId ->
MessageSender.sendRemoteDelete(messageId, true)
}
SignalDatabase.mms.allIncomingStoriesExceptOnboarding.use { reader ->
reader.map { record -> record.id }
}.forEach { messageId ->
SignalDatabase.mms.deleteMessage(messageId)
}
}
}.subscribeOn(Schedulers.io())
}