]> jfr.im git - irc/UndernetIRC/gnuworld.git/commitdiff
- Core: Allow modules to pass +R with a timestamp
authorSpike <redacted>
Fri, 29 Oct 2010 21:36:06 +0000 (23:36 +0200)
committerSpike <redacted>
Fri, 29 Oct 2010 21:36:06 +0000 (23:36 +0200)
- mod.cservice: Maintain valid TS in db and use it for modes/joins

mod.cservice/REGISTERCommand.cc
mod.cservice/STATUSCommand.cc
mod.cservice/cservice.cc
src/server.cc

index 55b8e96eed4a6589321799107b07b0ff5f03f7e4..c849b4b044fa8bf86fac60fed46e9b30b0cc6134 100755 (executable)
@@ -292,8 +292,12 @@ bool REGISTERCommand::Exec( iClient* theClient, const string& Message )
        bot->sqlLevelCache.insert(cservice::sqlLevelHashType::value_type(thePair, newManager));
 
        /* set channel mode R - tmpChan is created further above */
+       stringstream tmpTS;
+       tmpTS << channel_ts;
+       string channelTS = tmpTS.str();
+
        if (tmpChan)
-               bot->getUplink()->Mode(NULL, tmpChan, string("+R"), string() );
+               bot->getUplink()->Mode(NULL, tmpChan, string("+R"), channelTS );
        bot->getUplink()->RegisterChannelEvent(st[1],bot);
        return true;
 }
index b8ddcb733128ab722f238c15436bd85ba88be27f..6c5d9b0ae4cfc91adb0feac5d9b41e9e4faa7fef 100755 (executable)
@@ -323,6 +323,14 @@ if (admLevel >= 1)
                }
 }
 
+/*
+if (admLevel > level::admin::admin)
+{
+        bot->Notice(theClient, "DB TS: %i -- IRC TS: %i",
+                       theChan->getChannelTS(), tmpChan ? tmpChan->getCreationTime() : 0 );
+}
+*/
+
 return true ;
 }
 
index edbc2781b4101f74bc66841b19680c925867cbf8..40c8a7bccc540b59eb8f4c1502dca9bf0ec05752 100644 (file)
@@ -430,7 +430,12 @@ void cservice::BurstChannels()
        }
        
        MyUplink->RegisterChannelEvent( theChan->getName(), this ) ;
+
+       tmpChan = Network->findChannel(theChan->getName());
        
+       if (tmpChan && tmpChan->getCreationTime() < theChan->getChannelTS())
+                       theChan->setChannelTS(tmpChan->getCreationTime());      
+
        if (theChan->getFlag(sqlChannel::F_AUTOJOIN)) 
                {
                string tempModes = theChan->getChannelMode();
@@ -447,7 +452,6 @@ void cservice::BurstChannels()
                        if (getConfigVar("BAN_CHECK_ON_BURST")->asInt() == 1)
                        {
                                /* check current inhabitants of the channel against our banlist */
-                               tmpChan = Network->findChannel(theChan->getName());
                                for (Channel::userIterator chanUsers = tmpChan->userList_begin();
                                        chanUsers != tmpChan->userList_end(); ++chanUsers)
                                {
@@ -460,11 +464,12 @@ void cservice::BurstChannels()
                        /* although AUTOJOIN isn't set, set the channel to +R if
                         * it exists on the Network.
                         */
-                       tmpChan = Network->findChannel(theChan->getName());
                        if (tmpChan)
                        {
-                               string tempModes = "+R";
-                               MyUplink->Mode(NULL, tmpChan, tempModes, string() );
+                               stringstream tmpTS;
+                               tmpTS << theChan->getChannelTS();
+                               string channelTS = tmpTS.str();
+                               MyUplink->Mode(NULL, tmpChan, string("+R"), channelTS );
                        }
                }
        ++ptr;
@@ -3529,8 +3534,12 @@ switch( whichEvent )
                /* This is a registered channel, check it is set +R.
                 * If not, set it to +R (channel creation)
                 */
-               if (!theChan->getMode(Channel::MODE_REG))
-                       MyUplink->Mode(NULL, theChan, string("+R"), string() );
+               if (!theChan->getMode(Channel::MODE_REG)) {
+                       stringstream tmpTS;
+                       tmpTS << reggedChan->getChannelTS();
+                       string channelTS = tmpTS.str();
+                       MyUplink->Mode(NULL, theChan, string("+R"), channelTS );
+               }
 
                /* If this is a registered channel, but we're not in it -
                 * then we're not interested in the following commands!
index 0d0420a300a2c6c9ce2340db559152f88756352f..9028c7d8e1751d8e24b6b1535dc8efe8d8b0912b 100644 (file)
@@ -2238,7 +2238,6 @@ for( ; tokenIndex < st.size() ; )
                        case 'n':
                        case 'p':
                        case 'r':
-                       case 'R':
                        case 's':
                        case 't':
                        case 'D':
@@ -2254,6 +2253,26 @@ for( ; tokenIndex < st.size() ; )
                                        polarityString + theChar,
                                        string() ) ) ;
                                break ;
+                       case 'R':
+                                       /* mod.cservice setting +R with a TS */
+                                       if( nextArgIndex < st.size() && polarityBool ) {
+                                               std::string TS = st[ nextArgIndex ] ;
+                                               ++nextArgIndex ;
+                                               modeVector.push_back( make_pair(
+                                                       polarityBool,
+                                                       chanModes[ theChar ] ) ) ;
+                                               rawModeVector.push_back( make_pair(
+                                                       polarityString + theChar,
+                                                       TS ) ) ;                                                
+                                       } else {
+                                               modeVector.push_back( make_pair(
+                                                       polarityBool,
+                                                       chanModes[ theChar ] ) ) ;
+                                               rawModeVector.push_back( make_pair(
+                                                       polarityString + theChar,
+                                                       string() ) ) ;
+                                       }
+                               break;
                        case 'k':
                                {
 //                             elog    << "xServer::Mode> Mode 'k'"