Fixed an issue where shared messages and community invites wouldn't disappear

pull/1056/head
Morgan Pretty 10 months ago
parent a702179196
commit 15aaa8332d

@ -792,18 +792,19 @@ class ThreadSettingsViewModel: SessionTableViewModel, NavigationItemSource, Navi
) )
.save(db) .save(db)
let sentTimestampMs: Int64 = SnodeAPI.currentOffsetTimestampMs()
let destinationDisappearingMessagesConfiguration: DisappearingMessagesConfiguration? = try? DisappearingMessagesConfiguration
.filter(id: userId)
.filter(DisappearingMessagesConfiguration.Columns.isEnabled == true)
.fetchOne(db)
let interaction: Interaction = try Interaction( let interaction: Interaction = try Interaction(
threadId: thread.id, threadId: thread.id,
threadVariant: thread.variant, threadVariant: thread.variant,
authorId: currentUserSessionId, authorId: currentUserSessionId,
variant: .standardOutgoing, variant: .standardOutgoing,
timestampMs: SnodeAPI.currentOffsetTimestampMs(), timestampMs: sentTimestampMs,
expiresInSeconds: try? DisappearingMessagesConfiguration expiresInSeconds: destinationDisappearingMessagesConfiguration?.durationSeconds,
.select(.durationSeconds) expiresStartedAtMs: (destinationDisappearingMessagesConfiguration?.type == .disappearAfterSend ? Double(sentTimestampMs) : nil),
.filter(id: userId)
.filter(DisappearingMessagesConfiguration.Columns.isEnabled == true)
.asRequest(of: TimeInterval.self)
.fetchOne(db),
linkPreviewUrl: communityUrl linkPreviewUrl: communityUrl
) )
.inserted(db) .inserted(db)

@ -512,14 +512,21 @@ class NotificationActionHandler {
return Storage.shared return Storage.shared
.writePublisher { db in .writePublisher { db in
let sentTimestampMs: Int64 = SnodeAPI.currentOffsetTimestampMs()
let destinationDisappearingMessagesConfiguration: DisappearingMessagesConfiguration? = try? DisappearingMessagesConfiguration
.filter(id: threadId)
.filter(DisappearingMessagesConfiguration.Columns.isEnabled == true)
.fetchOne(db)
let interaction: Interaction = try Interaction( let interaction: Interaction = try Interaction(
threadId: threadId, threadId: threadId,
threadVariant: thread.variant, threadVariant: thread.variant,
authorId: getUserHexEncodedPublicKey(db), authorId: getUserHexEncodedPublicKey(db),
variant: .standardOutgoing, variant: .standardOutgoing,
body: replyText, body: replyText,
timestampMs: SnodeAPI.currentOffsetTimestampMs(), timestampMs: sentTimestampMs,
hasMention: Interaction.isUserMentioned(db, threadId: threadId, body: replyText) hasMention: Interaction.isUserMentioned(db, threadId: threadId, body: replyText),
expiresInSeconds: destinationDisappearingMessagesConfiguration?.durationSeconds,
expiresStartedAtMs: (destinationDisappearingMessagesConfiguration?.type == .disappearAfterSend ? Double(sentTimestampMs) : nil)
).inserted(db) ).inserted(db)
try Interaction.markAsRead( try Interaction.markAsRead(

@ -280,14 +280,21 @@ final class ThreadPickerVC: UIViewController, UITableViewDataSource, UITableView
} }
// Create the interaction // Create the interaction
let sentTimestampMs: Int64 = SnodeAPI.currentOffsetTimestampMs()
let destinationDisappearingMessagesConfiguration: DisappearingMessagesConfiguration? = try? DisappearingMessagesConfiguration
.filter(id: threadId)
.filter(DisappearingMessagesConfiguration.Columns.isEnabled == true)
.fetchOne(db)
let interaction: Interaction = try Interaction( let interaction: Interaction = try Interaction(
threadId: threadId, threadId: threadId,
threadVariant: threadVariant, threadVariant: threadVariant,
authorId: getUserHexEncodedPublicKey(db), authorId: getUserHexEncodedPublicKey(db),
variant: .standardOutgoing, variant: .standardOutgoing,
body: body, body: body,
timestampMs: SnodeAPI.currentOffsetTimestampMs(), timestampMs: sentTimestampMs,
hasMention: Interaction.isUserMentioned(db, threadId: threadId, body: body), hasMention: Interaction.isUserMentioned(db, threadId: threadId, body: body),
expiresInSeconds: destinationDisappearingMessagesConfiguration?.durationSeconds,
expiresStartedAtMs: (destinationDisappearingMessagesConfiguration?.type == .disappearAfterSend ? Double(sentTimestampMs) : nil),
linkPreviewUrl: (isSharingUrl ? attachments.first?.linkPreviewDraft?.urlString : nil) linkPreviewUrl: (isSharingUrl ? attachments.first?.linkPreviewDraft?.urlString : nil)
).inserted(db) ).inserted(db)

Loading…
Cancel
Save