diff --git a/ConversationsClassic/AppCore/Middlewares/DatabaseMiddleware.swift b/ConversationsClassic/AppCore/Middlewares/DatabaseMiddleware.swift index ea61c49..86d96ef 100644 --- a/ConversationsClassic/AppCore/Middlewares/DatabaseMiddleware.swift +++ b/ConversationsClassic/AppCore/Middlewares/DatabaseMiddleware.swift @@ -167,7 +167,7 @@ final class DatabaseMiddleware { promise(.success(.databaseAction(.storeMessageFailed(reason: L10n.Global.Error.genericDbError)))) return } - guard message.contentType != .typing else { + guard message.contentType != .typing, message.body != nil else { promise(.success(.empty)) return } diff --git a/ConversationsClassic/AppCore/XMPP/XMPPService.swift b/ConversationsClassic/AppCore/XMPP/XMPPService.swift index 0f720fa..2386227 100644 --- a/ConversationsClassic/AppCore/XMPP/XMPPService.swift +++ b/ConversationsClassic/AppCore/XMPP/XMPPService.swift @@ -109,11 +109,13 @@ final class XMPPService: ObservableObject { completion(false) return } - let message = Martin.Message() - message.to = JID(to) - message.body = message.body + guard let chat = client.module(MessageModule.self).chatManager.chat(for: client.context, with: BareJID(to)) else { + completion(false) + return + } - client.context.writer.write(message) { res in + let msg = chat.createMessage(text: message.body ?? "??", id: message.id) + chat.send(message: msg) { res in switch res { case .success: completion(true)