Пример #1
0
ChannelMessage::ChannelMessage(MessagePacket packet)
  : Message(packet->id(), QByteArray(), LS("channel"), LS("addChannelMessage"))
  , m_packet(packet)
{
  setDate(m_packet->date());
  setAuthor(m_packet->sender());
  m_tab = detectTab(m_packet->sender(), m_packet->dest());

  if (!m_packet->internalId().isEmpty())
    m_data.insert(kInternalId, ChatId(m_packet->internalId()).toString());

  m_data.insert(kCommand,   packet->command());
  m_data.insert(kDirection, m_packet->sender() == ChatClient::id() ? kOutgoing : kIncoming);

  /// Если это собственное сообщение, то для него при необходимости устанавливается
  /// статус "offline" или "rejected".
  const int status = packet->status();
  if (isOffline(status))
    m_data.insert(kStatus, kOffline);
  else if (status != Notice::OK && status != Notice::Found && status < Notice::UserStatus)
    m_data.insert(kStatus, kRejected);

  if (status == MessageNotice::Removed) {
    m_data.insert(kStatus, kRemoved);
    m_data.insert(kText, QString(LS("<span class='message-removed' data-tr='message-removed'>%1</span> <i class='message-trash'></i>")).arg(WebBridge::i()->translate("message-removed")));
  }
  else
    m_data.insert(kText, TokenFilter::filter(LS("channel"), packet->text(), 0, packet->id()));

  if (!packet->oid.isNull()) {
    m_data.insert(kOID, QString(ChatId::toBase32(packet->oid.byteArray())));
    m_data.insert(kMDate, packet->mdate);
  }
}
Пример #2
0
int SendFileMessages::read(MessagePacket packet)
{
  if (packet->command() != LS("file"))
    return 0;

  if (SimpleID::typeOf(packet->id()) != SimpleID::MessageId)
    return 0;

  m_plugin->read(packet);
  return 1;
}
Пример #3
0
int ShareMessages::read(MessagePacket packet)
{
  if (packet->command() != LS("image") || Hooks::MessagesImpl::isIgnored(packet))
    return 0;

  if (ChatId(packet->id()).type() != ChatId::MessageId)
    return 0;

  m_share->read(packet);
  return 1;
}