Commit cf9884ca authored by armin's avatar armin
Browse files

Merge branch 'commentCodeThatShouldNotHaveBeenMerged' into 'master'

reverts changes that should not have beet commited in 36012136

See merge request !105
parents 7fea6181 c2cb7885
......@@ -62,11 +62,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;
}
......@@ -168,6 +171,7 @@ void RocketChatServerData::initConnections()
wipeDbAndReconnect();
emit loggedOut( mServerId );
}
emit readyToCheckForPendingNotification();
mChannelService->loadJoinedChannelsFromDb();
}
......@@ -625,23 +629,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
......@@ -990,11 +994,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 {
......@@ -1376,23 +1382,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 );
}
}
}
......@@ -1754,7 +1766,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;
}
......@@ -1784,7 +1796,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 ) );
}
......@@ -2077,9 +2089,10 @@ void RocketChatServerData::addUsersToChannel( const QString &pChannelId, const Q
void RocketChatServerData::persistData()
{
mMessageService->persist();
mChannelService->persist();
mEmojiService->persist();
/* mMessageService->persist();
mChannelService->persist();
mEmojiService->persist();
*/
}
......
......@@ -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