+ std::string quitmsg(quitmessage);
+ std::string operquitmsg;
+ if (operquitmessage)
+ operquitmsg.assign(*operquitmessage);
+
+ LocalUser* const localuser = IS_LOCAL(user);
+ if (localuser)
+ {
+ ModResult MOD_RESULT;
+ FIRST_MOD_RESULT(OnUserPreQuit, MOD_RESULT, (localuser, quitmsg, operquitmsg));
+ if (MOD_RESULT == MOD_RES_DENY)
+ return;
+ }
+
+ if (quitmsg.length() > ServerInstance->Config->Limits.MaxQuit)
+ quitmsg.erase(ServerInstance->Config->Limits.MaxQuit + 1);
+
+ if (operquitmsg.empty())
+ operquitmsg.assign(quitmsg);
+ else if (operquitmsg.length() > ServerInstance->Config->Limits.MaxQuit)
+ operquitmsg.erase(ServerInstance->Config->Limits.MaxQuit + 1);
+
+ user->quitting = true;
+ ServerInstance->Logs->Log("USERS", LOG_DEBUG, "QuitUser: %s=%s '%s'", user->uuid.c_str(), user->nick.c_str(), quitmessage.c_str());
+ if (localuser)
+ {
+ ClientProtocol::Messages::Error errormsg(InspIRCd::Format("Closing link: (%s@%s) [%s]", user->ident.c_str(), user->GetRealHost().c_str(), operquitmsg.c_str()));
+ localuser->Send(ServerInstance->GetRFCEvents().error, errormsg);
+ }
+
+ ServerInstance->GlobalCulls.AddItem(user);
+
+ if (user->registered == REG_ALL)
+ {
+ FOREACH_MOD(OnUserQuit, (user, quitmsg, operquitmsg));
+ WriteCommonQuit(user, quitmsg, operquitmsg);
+ }