Esempio n. 1
0
bool JabberChatService::sendMessage(const Message &message)
{
	if (!m_client)
		return false;

	auto jid = m_resourceService->bestChatJid(message.messageChat());
	if (jid.isEmpty())
		return false;

	auto xmppMessage = QXmppMessage{};

	FormattedStringPlainTextVisitor plainTextVisitor;
	message.content()->accept(&plainTextVisitor);

	auto plain = plainTextVisitor.result();
	if (rawMessageTransformerService())
		plain = QString::fromUtf8(rawMessageTransformerService()->transform(plain.toUtf8(), {message}).rawContent());

	xmppMessage.setBody(plain);
	xmppMessage.setFrom(m_client.data()->clientPresence().id());
	xmppMessage.setStamp(QDateTime::currentDateTime());
	xmppMessage.setTo(jid.full());
	xmppMessage.setType(chatMessageType(message.messageChat(), jid.bare()));

	m_client.data()->sendPacket(m_chatStateService->withSentChatState(xmppMessage));

	return true;
}
Esempio n. 2
0
bool FacebookChatService::sendMessage(const Message &message)
{
    auto formattedContent = m_formattedStringFactory->fromHtml(message.content());

    FormattedStringPlainTextVisitor plainTextVisitor;
    formattedContent->accept(&plainTextVisitor);

    auto contact = *message.messageChat().contacts().begin();
    auto msgId = m_facebookSession.sendMessage(contact.id().toULongLong(), plainTextVisitor.result().toUtf8());
    m_undeliveredMessages[msgId] = message;

    return true;
}