Commit 77eeca37 authored by armin's avatar armin
Browse files

fixes api change in 0.70 regarding messagesearch

parent 2485fc00
......@@ -270,26 +270,45 @@ void MessageService::addChannelToBlockList( const QString &pId )
void MessageService::searchMessage( const QString &pTerm, const QString &pRoom )
{
if ( mServer ) {
DdpCallback ddpSuccess = [ = ]( const QJsonObject & pResponse,
auto ddpSuccess = [ = ]( const QJsonObject & pResponse,
MeteorDDP * pDdp ) {
Q_UNUSED( pDdp )
if ( pResponse.contains( "result" ) ) {
QJsonObject result = pResponse["result"].toObject();
if ( result.contains( "messages" ) ) {
QJsonArray messagesArray = result["messages"].toArray();
MessageList messageList;
auto major = std::get<0>( RocketChatServerConfig::serverVersion );
auto minor = std::get<1>( RocketChatServerConfig::serverVersion );
auto patch = std::get<2>( RocketChatServerConfig::serverVersion );
for ( const auto message : messagesArray ) {
messageList.append( parseMessage( message.toObject() ) );
MessageList messageList;
if ( major >= 0 && minor >= 70 ) {
if ( result.contains( "message" ) ) {
auto message = result["message"].toObject();
if ( message.contains( "docs" ) ) {
auto docs = message["docs"].toArray();
for ( const auto doc : docs ) {
messageList.append( parseMessage( doc.toObject() ) );
}
}
}
} else {
if ( result.contains( "messages" ) ) {
auto messagesArray = result["messages"].toArray();
if ( !messageList.isEmpty() ) {
auto result = QMetaObject::invokeMethod( mSearchResults, "setSearchResults", Q_ARG( MessageList, messageList ) );
Q_ASSERT( result );
for ( const auto message : messagesArray ) {
messageList.append( parseMessage( message.toObject() ) );
}
}
}
if ( !messageList.isEmpty() ) {
auto result = QMetaObject::invokeMethod( mSearchResults, "setSearchResults", Q_ARG( MessageList, messageList ) );
Q_ASSERT( result );
}
}
};
......
......@@ -19,7 +19,7 @@
********************************************************************************************/
#pragma once
#ifndef MESSAGESERVICE_H
#define MESSAGESERVICE_H
......@@ -65,8 +65,8 @@ class MessageService : public QObject
void addUserToBlockList( const QString &pId );
void addChannelToBlockList( const QString &pId );
void searchMessage( const QString &pTerm, const QString &pRoom );
void deleteMessagesNotInList(MessageMap *pMessages, QString pChannelId, bool pCheckForYounger);
protected:
void deleteMessagesNotInList( MessageMap *pMessages, QString pChannelId, bool pCheckForYounger );
protected:
QRegularExpression mReplyRegeEx;
EmojiRepo *mEmojiRepo;
MessagesModel *mMessagesModel;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment