This commit is contained in:
fmodf 2024-11-08 11:55:47 +01:00
parent 0e2c135bea
commit af7664d2d3

View file

@ -8,9 +8,10 @@ final class ClientMartinCarbonsManager {
init(_ xmppConnection: XMPPClient) { init(_ xmppConnection: XMPPClient) {
// subscribe to carbons // subscribe to carbons
let ctx = xmppConnection.module(MessageCarbonsModule.self).context
xmppConnection.module(MessageCarbonsModule.self).carbonsPublisher xmppConnection.module(MessageCarbonsModule.self).carbonsPublisher
.sink { [weak self] carbon in .sink { [weak self] carbon in
self?.handleMessage(carbon) self?.handleMessage(carbon, ctx)
} }
.store(in: &cancellables) .store(in: &cancellables)
@ -22,7 +23,7 @@ final class ClientMartinCarbonsManager {
.store(in: &cancellables) .store(in: &cancellables)
} }
private func handleMessage(_ received: Martin.MessageCarbonsModule.CarbonReceived) { private func handleMessage(_ received: Martin.MessageCarbonsModule.CarbonReceived, _ context: Context?) {
let message = received.message let message = received.message
let action = received.action let action = received.action
let onJid = received.jid let onJid = received.jid
@ -34,7 +35,7 @@ final class ClientMartinCarbonsManager {
print("---") print("---")
#endif #endif
if let msg = Message.map(message, context: nil) { if let msg = Message.map(message, context: context) {
Task { Task {
do { do {
try await msg.save() try await msg.save()