Add a global “persistent” option
This commit is contained in:
@@ -436,9 +436,14 @@ void Bridge::leave_irc_channel(Iid&& iid, const std::string& status_message, con
|
||||
// acknowledgment from the server
|
||||
bool persistent = false;
|
||||
#ifdef USE_DATABASE
|
||||
const auto coptions = Database::get_irc_channel_options_with_server_default(this->user_jid,
|
||||
iid.get_server(), iid.get_local());
|
||||
persistent = coptions.col<Database::Persistent>();
|
||||
const auto goptions = Database::get_global_options(this->user_jid);
|
||||
if (goptions.col<Database::Persistent>())
|
||||
persistent = true;
|
||||
else
|
||||
{
|
||||
const auto coptions = Database::get_irc_channel_options_with_server_default(this->user_jid, iid.get_server(), iid.get_local());
|
||||
persistent = coptions.col<Database::Persistent>();
|
||||
}
|
||||
#endif
|
||||
if (channel->joined && !channel->parting && !persistent)
|
||||
{
|
||||
|
||||
@@ -98,7 +98,7 @@ class Database
|
||||
using MucLogLineTable = Table<Id, Uuid, Owner, IrcChanName, IrcServerName, Date, Body, Nick>;
|
||||
using MucLogLine = MucLogLineTable::RowType;
|
||||
|
||||
using GlobalOptionsTable = Table<Id, Owner, MaxHistoryLength, RecordHistory>;
|
||||
using GlobalOptionsTable = Table<Id, Owner, MaxHistoryLength, RecordHistory, Persistent>;
|
||||
using GlobalOptions = GlobalOptionsTable::RowType;
|
||||
|
||||
using IrcServerOptionsTable = Table<Id, Owner, Server, Pass, AfterConnectionCommand, TlsPorts, Ports, Username, Realname, VerifyCert, TrustedFingerprint, EncodingOut, EncodingIn, MaxHistoryLength>;
|
||||
|
||||
@@ -147,6 +147,21 @@ void ConfigureGlobalStep1(XmppComponent&, AdhocSession& session, XmlNode& comman
|
||||
else
|
||||
value.set_inner("false");
|
||||
}
|
||||
|
||||
XmlSubNode persistent(x, "field");
|
||||
persistent["var"] = "persistent";
|
||||
persistent["type"] = "boolean";
|
||||
persistent["label"] = "Make all channels persistent";
|
||||
persistent["desc"] = "If true, all channels will be persistent";
|
||||
|
||||
{
|
||||
XmlSubNode value(persistent, "value");
|
||||
value.set_name("value");
|
||||
if (options.col<Database::Persistent>())
|
||||
value.set_inner("true");
|
||||
else
|
||||
value.set_inner("false");
|
||||
}
|
||||
}
|
||||
|
||||
void ConfigureGlobalStep2(XmppComponent& xmpp_component, AdhocSession& session, XmlNode& command_node)
|
||||
@@ -173,6 +188,9 @@ void ConfigureGlobalStep2(XmppComponent& xmpp_component, AdhocSession& session,
|
||||
if (bridge)
|
||||
bridge->set_record_history(options.col<Database::RecordHistory>());
|
||||
}
|
||||
else if (field->get_tag("var") == "persistent" &&
|
||||
value)
|
||||
options.col<Database::Persistent>() = to_bool(value->get_inner());
|
||||
}
|
||||
|
||||
options.save(Database::db);
|
||||
|
||||
Reference in New Issue
Block a user