Commit 8eee9ed9 authored by Dennis Beier's avatar Dennis Beier
Browse files

Merge branch 'master' of https://git.fairkom.net/chat/RocketChatMobileEngine...

Merge branch 'master' of https://git.fairkom.net/chat/RocketChatMobileEngine into fix-upload-performance
parents d9f53570 cf9884ca
......@@ -61,11 +61,14 @@ void RocketChatServerData::initConnections()
MessageList messageList = messages->values( it.key() );
auto channel = mChannels->get( it.key() );
QList<QSharedPointer<RocketChatMessage>> newones = channel->addMessages( messageList );
mMessageService->deleteMessagesNotInList(messages, it.key(),true);
if(newones.count())
mMessageService->deleteMessagesNotInList( messages, it.key(), true );
if ( newones.count() ) {
mMessageService->persistMessages( newones );
}
}
}
mStorage->askForcommit();
delete messages;
}
......@@ -167,6 +170,7 @@ void RocketChatServerData::initConnections()
wipeDbAndReconnect();
emit loggedOut( mServerId );
}
emit readyToCheckForPendingNotification();
mChannelService->loadJoinedChannelsFromDb();
}
......@@ -621,23 +625,23 @@ void RocketChatServerData::reconnect()
resume();
}
void RocketChatServerData::deleteMessage(QString rid, QString id)
void RocketChatServerData::deleteMessage( QString rid, QString id )
{
QJsonArray params = { QJsonObject({{"_id", id }})};
auto request = QSharedPointer<DDPMethodRequest>::create("deleteMessage",params);
QJsonArray params = { QJsonObject( {{"_id", id }} )};
auto request = QSharedPointer<DDPMethodRequest>::create( "deleteMessage", params );
DdpCallback success = [ = ]( QJsonObject, MeteorDDP * ) {
try {
auto room = mChannels->get(rid);
mStorage->deleteMessage(id);
room->deleteMessage(id);
auto room = mChannels->get( rid );
mStorage->deleteMessage( id );
room->deleteMessage( id );
} catch (std::logic_error error) {
} catch ( std::logic_error error ) {
qDebug() << error.what();
}
};
request->setSuccess(success);
sendDdprequest(request);
request->setSuccess( success );
sendDdprequest( request );
}
QSharedPointer<RocketChatUser> RocketChatServerData::getOwnUser() const
......@@ -986,11 +990,13 @@ void RocketChatServerData::onDDPConnected()
if ( mResumeOperation ) {
auto token = mDdpApi->getToken();
if(token.isEmpty()){
if ( token.isEmpty() ) {
token = mStorage->getToken().first;
}
if(!token.isEmpty()){
mDdpApi->setToken(token);
if ( !token.isEmpty() ) {
mDdpApi->setToken( token );
loginWithToken( mUsername, token, true );
}
} else {
......@@ -1372,23 +1378,29 @@ void RocketChatServerData::onDDPMessageReceived( const QJsonObject &pMessage )
handleUserJoinMessage( pMessage );
} else if ( Q_LIKELY( isStreamRoomMessage( pMessage ) ) ) {
handleStreamRoomMessage( pMessage );
}else if(pMessage[QStringLiteral( "collection" )] == QStringLiteral( "stream-notify-room" )){
QJsonObject fields = pMessage["fields"].toObject();
if(fields.contains("eventName")){
} else if ( pMessage[QStringLiteral( "collection" )] == QStringLiteral( "stream-notify-room" ) ) {
QJsonObject fields = pMessage["fields"].toObject();
if ( fields.contains( "eventName" ) ) {
QString eventname = fields["eventName"].toString();
if(eventname.contains("deleteMessage")){
QStringList tokens = eventname.split("/");
if(tokens.size() == 2){
if ( eventname.contains( "deleteMessage" ) ) {
QStringList tokens = eventname.split( "/" );
if ( tokens.size() == 2 ) {
QString roomId = tokens[0];
if(fields.contains("args") && fields["args"].isArray()){
if ( fields.contains( "args" ) && fields["args"].isArray() ) {
QJsonArray args = fields["args"].toArray();
QJsonObject idarg;
if(args.size() && args[0].isObject() && (idarg = args[0].toObject()).contains("_id")){
QString messageId =idarg["_id"].toString();
if(mChannels->contains(roomId)){
auto room = mChannels->get(roomId);
room->deleteMessage(messageId);
mStorage->deleteMessage(roomId);
if ( args.size() && args[0].isObject() && ( idarg = args[0].toObject() ).contains( "_id" ) ) {
QString messageId = idarg["_id"].toString();
if ( mChannels->contains( roomId ) ) {
auto room = mChannels->get( roomId );
room->deleteMessage( messageId );
mStorage->deleteMessage( roomId );
}
}
}
......@@ -1750,7 +1762,7 @@ void RocketChatServerData::loadRecentHistory( const QString &pChannelId )
auto messageList = messages->values( pChannelId );
qDebug() << "load recent history successfull loaded " << messageList.size();
mChannels->get( pChannelId )->addMessages( messageList );
// mMessageService->persistMessages( messageList );
mMessageService->persistMessages( messageList );
delete messages;
}
......@@ -1780,7 +1792,7 @@ void RocketChatServerData::getCustomEmojis()
for ( auto &emoji : pEmojiList ) {
if ( !emoji.isNull() ) {
if ( !mEmojiRepo->contains( emoji->getIdentifier() ) ) {
//mEmojiService->persistEmoji( emoji );
mEmojiService->persistEmoji( emoji );
mEmojiRepo->add( emoji->getIdentifier(), emoji );
newEmojis.append( std::move( emoji ) );
}
......@@ -2072,6 +2084,7 @@ void RocketChatServerData::addUsersToChannel( const QString &pChannelId, const Q
}
ChannelRepository *RocketChatServerData::getChannels() const
{
return mChannels;
......
......@@ -199,7 +199,7 @@ QVector<QSharedPointer<RocketChatChannel> > RocketChatChannelService::processCha
channel->setUpdatedAt( updatedAt );
vec.append( channel );
//persistChannel( channel );
persistChannel( channel );
}
}
......@@ -437,8 +437,8 @@ void RocketChatChannelService::subscribeChannel( const QSharedPointer<RocketChat
void RocketChatChannelService::subscribeChannel( const QString &pChannel )
{
auto subscription = QSharedPointer<RocketChatSubscribeChannelRequest>::create( pChannel );
QJsonArray params = {pChannel+"/deleteMessage"};
auto deletesub =QSharedPointer<DDPSubscriptionRequest>::create( "stream-notify-room",params );
QJsonArray params = {pChannel + "/deleteMessage"};
auto deletesub = QSharedPointer<DDPSubscriptionRequest>::create( "stream-notify-room", params );
mServer->sendDdprequest( subscription );
mServer->sendDdprequest( deletesub );
}
......
Supports Markdown
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