Update XMPPService.swift
This commit is contained in:
1 parent
cd342a3f98
commit
85c06165e8
1 file changed
+58
-15
@@ -1565,7 +1565,7 @@ final class XMPPService {
|
|||||||
replyToID: reply?.getAttribute("id"),
|
replyToID: reply?.getAttribute("id"),
|
||||||
replyToJID: reply?.getAttribute("to"),
|
replyToJID: reply?.getAttribute("to"),
|
||||||
replyPreview: parsedReply.preview,
|
replyPreview: parsedReply.preview,
|
||||||
stanzaID: nil,
|
stanzaID: archiveID,
|
||||||
senderDisplayName: nil,
|
senderDisplayName: nil,
|
||||||
isGroupMessage: false,
|
isGroupMessage: false,
|
||||||
isArchived: isArchived
|
isArchived: isArchived
|
||||||
@@ -1864,7 +1864,8 @@ final class XMPPService {
|
|||||||
roomConfig.persistentRoom = true
|
roomConfig.persistentRoom = true
|
||||||
}
|
}
|
||||||
|
|
||||||
try await withCheckedThrowingContinuation { (continuation: CheckedContinuation<Void, Error>) in
|
try await withCheckedThrowingContinuation {
|
||||||
|
(continuation: CheckedContinuation<Void, Error>) in
|
||||||
muc.setRoomConfiguration(roomJid: roomJID, configuration: roomConfig) { result in
|
muc.setRoomConfiguration(roomJid: roomJID, configuration: roomConfig) { result in
|
||||||
continuation.resume(with: result)
|
continuation.resume(with: result)
|
||||||
}
|
}
|
||||||
@@ -2423,12 +2424,28 @@ final class XMPPService {
|
|||||||
} else {
|
} else {
|
||||||
archiveHighWatermark = stanza.timestamp
|
archiveHighWatermark = stanza.timestamp
|
||||||
}
|
}
|
||||||
handle(
|
// handle(
|
||||||
message: stanza.message,
|
// message: stanza.message,
|
||||||
timestamp: stanza.timestamp,
|
// timestamp: stanza.timestamp,
|
||||||
archiveID: stanza.archiveID,
|
// archiveID: stanza.archiveID,
|
||||||
isArchived: true
|
// isArchived: true
|
||||||
)
|
// )
|
||||||
|
if stanza.message.type == .groupchat,
|
||||||
|
let roomJID = stanza.message.from?.bareJid,
|
||||||
|
let room = client?.module(.muc).roomManager.room(for: client!, with: roomJID)
|
||||||
|
{
|
||||||
|
// Some servers include MUC messages in the account MAM.
|
||||||
|
// Route them through the same group handler instead of
|
||||||
|
// dropping them in the direct-message handler.
|
||||||
|
handle(groupMessage: stanza.message, room: room)
|
||||||
|
} else {
|
||||||
|
handle(
|
||||||
|
message: stanza.message,
|
||||||
|
timestamp: stanza.timestamp,
|
||||||
|
archiveID: stanza.archiveID,
|
||||||
|
isArchived: true
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Give SwiftUI, UIScrollView and AVFoundation delegate tasks a
|
// Give SwiftUI, UIScrollView and AVFoundation delegate tasks a
|
||||||
@@ -2512,21 +2529,47 @@ final class XMPPService {
|
|||||||
caughtUp: false
|
caughtUp: false
|
||||||
)
|
)
|
||||||
archiveLastCompletedCursor = checkpoint.cursor
|
archiveLastCompletedCursor = checkpoint.cursor
|
||||||
|
// if workBudgetReached {
|
||||||
|
// if checkpoint.advances(over: archiveSyncCheckpoint) {
|
||||||
|
// finishArchiveSync(
|
||||||
|
// client: client,
|
||||||
|
// succeeded: true,
|
||||||
|
// checkpoint: checkpoint
|
||||||
|
// )
|
||||||
|
// } else {
|
||||||
|
// archivePassMutations.removeAll(keepingCapacity: true)
|
||||||
|
// eventHandler?(
|
||||||
|
// .recoverableError(
|
||||||
|
// "MAM не продвинул контрольную точку; синхронизация приостановлена."
|
||||||
|
// ))
|
||||||
|
// finishArchiveSync(client: client, succeeded: false)
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// scheduleArchiveNextPage(client: client, after: cursor)
|
||||||
|
// }
|
||||||
if workBudgetReached {
|
if workBudgetReached {
|
||||||
if checkpoint.advances(over: archiveSyncCheckpoint) {
|
guard checkpoint.advances(over: archiveSyncCheckpoint) else {
|
||||||
finishArchiveSync(
|
|
||||||
client: client,
|
|
||||||
succeeded: true,
|
|
||||||
checkpoint: checkpoint
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
archivePassMutations.removeAll(keepingCapacity: true)
|
archivePassMutations.removeAll(keepingCapacity: true)
|
||||||
eventHandler?(
|
eventHandler?(
|
||||||
.recoverableError(
|
.recoverableError(
|
||||||
"MAM не продвинул контрольную точку; синхронизация приостановлена."
|
"MAM не продвинул контрольную точку; синхронизация приостановлена."
|
||||||
))
|
))
|
||||||
finishArchiveSync(client: client, succeeded: false)
|
finishArchiveSync(client: client, succeeded: false)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The foreground budget is only a UI-yield boundary. It
|
||||||
|
// must NOT turn response.complete == false into a completed
|
||||||
|
// MAM pass, otherwise messages after this cursor are missed
|
||||||
|
// until a later activation.
|
||||||
|
if !archivePassMutations.isEmpty {
|
||||||
|
let mutations = archivePassMutations
|
||||||
|
archivePassMutations.removeAll(keepingCapacity: true)
|
||||||
|
eventHandler?(.archiveBatch(mutations))
|
||||||
|
}
|
||||||
|
archiveSyncCheckpoint = checkpoint
|
||||||
|
archiveWorkBudget = ArchiveSyncWorkBudget()
|
||||||
|
scheduleArchiveNextPage(client: client, after: cursor)
|
||||||
} else {
|
} else {
|
||||||
scheduleArchiveNextPage(client: client, after: cursor)
|
scheduleArchiveNextPage(client: client, after: cursor)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user