fix an issue where deleting outgoing messages in a 1-1 globally does not leave artifacts behind for the person deleting

pull/894/head
Ryan ZHAO 3 months ago
parent 379ab2629f
commit 7ed4d393e3

@ -812,6 +812,19 @@ public extension Interaction {
} }
} }
struct ThreadInfo: FetchableRecord, Codable {
public let id: Int64
public let threadId: String
public init(
id: Int64,
threadId: String
) {
self.id = id
self.threadId = threadId
}
}
static func idsForTermWithin(threadId: String, pattern: FTS5Pattern) -> SQLRequest<TimestampInfo> { static func idsForTermWithin(threadId: String, pattern: FTS5Pattern) -> SQLRequest<TimestampInfo> {
let interaction: TypedTableAlias<Interaction> = TypedTableAlias() let interaction: TypedTableAlias<Interaction> = TypedTableAlias()
let interactionFullTextSearch: TypedTableAlias<FullTextSearch> = TypedTableAlias(name: Interaction.fullTextSearchTableName) let interactionFullTextSearch: TypedTableAlias<FullTextSearch> = TypedTableAlias(name: Interaction.fullTextSearchTableName)

@ -35,11 +35,11 @@ extension MessageReceiver {
guard guard
let author: String = message.author, let author: String = message.author,
let timestampMs: UInt64 = message.timestamp, let timestampMs: UInt64 = message.timestamp,
let interactionId: Int64 = try Interaction let interactionInfo: Interaction.ThreadInfo = try Interaction
.select(.id) .select(.id, .threadId)
.filter(Interaction.Columns.timestampMs == Int64(timestampMs)) .filter(Interaction.Columns.timestampMs == Int64(timestampMs))
.filter(Interaction.Columns.authorId == author) .filter(Interaction.Columns.authorId == author)
.asRequest(of: Int64.self) .asRequest(of: Interaction.ThreadInfo.self)
.fetchOne(db) .fetchOne(db)
else { return } else { return }
@ -48,20 +48,20 @@ extension MessageReceiver {
/// message content /// message content
let hashes: Set<String> = try Interaction.serverHashesForDeletion( let hashes: Set<String> = try Interaction.serverHashesForDeletion(
db, db,
interactionIds: [interactionId] interactionIds: [interactionInfo.id]
) )
try Interaction.markAsDeleted( try Interaction.markAsDeleted(
db, db,
threadId: threadId, threadId: threadId,
threadVariant: threadVariant, threadVariant: threadVariant,
interactionIds: [interactionId], interactionIds: [interactionInfo.id],
localOnly: false, localOnly: false,
using: dependencies using: dependencies
) )
/// If it's the `Note to Self` conversation then we want to just delete the interaction /// If it's the `Note to Self` conversation then we want to just delete the interaction
if userSessionId.hexString == threadId { if userSessionId.hexString == interactionInfo.threadId {
try Interaction.deleteOne(db, id: interactionId) try Interaction.deleteOne(db, id: interactionInfo.id)
} }
/// Can't delete from the legacy group swarm so only bother for contact conversations /// Can't delete from the legacy group swarm so only bother for contact conversations

Loading…
Cancel
Save