clean
This commit is contained in:
parent
3d566c1923
commit
39c9ec7357
|
@ -462,34 +462,6 @@ public extension SessionThread {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func isMessageRequestFromCommunity(_ db: Database, openGroupId: String) -> Bool {
|
|
||||||
var isMessageRequestFromCommunity: Bool = false
|
|
||||||
if let currentUserBlinded15PublicKey: String = Self.getUserHexEncodedBlindedKey(
|
|
||||||
db,
|
|
||||||
threadId: openGroupId,
|
|
||||||
threadVariant: .community,
|
|
||||||
blindingPrefix: .blinded15
|
|
||||||
) {
|
|
||||||
isMessageRequestFromCommunity = isMessageRequestFromCommunity || ((try? Interaction
|
|
||||||
.filter(Interaction.Columns.threadId == self.id)
|
|
||||||
.filter(Interaction.Columns.openGroupWhisperTo == currentUserBlinded15PublicKey)
|
|
||||||
.isNotEmpty(db)) ?? false)
|
|
||||||
}
|
|
||||||
if let currentUserBlinded25PublicKey: String = Self.getUserHexEncodedBlindedKey(
|
|
||||||
db,
|
|
||||||
threadId: openGroupId,
|
|
||||||
threadVariant: .community,
|
|
||||||
blindingPrefix: .blinded25
|
|
||||||
) {
|
|
||||||
isMessageRequestFromCommunity = isMessageRequestFromCommunity || ((try? Interaction
|
|
||||||
.filter(Interaction.Columns.threadId == self.id)
|
|
||||||
.filter(Interaction.Columns.openGroupWhisperTo == currentUserBlinded25PublicKey)
|
|
||||||
.isNotEmpty(db)) ?? false)
|
|
||||||
}
|
|
||||||
|
|
||||||
return isMessageRequestFromCommunity
|
|
||||||
}
|
|
||||||
|
|
||||||
func isNoteToSelf(_ db: Database? = nil) -> Bool {
|
func isNoteToSelf(_ db: Database? = nil) -> Bool {
|
||||||
return (
|
return (
|
||||||
variant == .contact &&
|
variant == .contact &&
|
||||||
|
|
|
@ -370,31 +370,6 @@ public final class OpenGroupManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func cleanMessageRequests(
|
|
||||||
_ db: Database,
|
|
||||||
openGroupId: String,
|
|
||||||
openGroupServer: String?,
|
|
||||||
calledFromConfigHandling: Bool,
|
|
||||||
using dependencies: Dependencies = Dependencies()
|
|
||||||
) {
|
|
||||||
// Remove threads with only message requests from open group
|
|
||||||
_ = try? SessionThread
|
|
||||||
.filter(SessionThread.isMessageRequest(userPublicKey: getUserHexEncodedPublicKey(db, using: dependencies)))
|
|
||||||
.fetchAll(db)
|
|
||||||
.filter { $0.isMessageRequestFromCommunity(db, openGroupId: openGroupId)}
|
|
||||||
.map { try $0.delete(db)}
|
|
||||||
|
|
||||||
if !calledFromConfigHandling, let server: String = openGroupServer {
|
|
||||||
//Remove inbox messages
|
|
||||||
if let data = try? OpenGroupAPI.preparedClearInbox(db, on: server) {
|
|
||||||
OpenGroupAPI
|
|
||||||
.send(data: data)
|
|
||||||
.map { _ in [server: true] }
|
|
||||||
.sinkUntilComplete()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// MARK: - Response Processing
|
// MARK: - Response Processing
|
||||||
|
|
||||||
internal static func handleCapabilities(
|
internal static func handleCapabilities(
|
||||||
|
|
Loading…
Reference in New Issue