1 /** 2 (module summary) 3 4 Copyright: © 2012-2014 RejectedSoftware e.K. 5 License: Subject to the terms of the General Public License version 3, as written in the included LICENSE.txt file. 6 Authors: Sönke Ludwig 7 */ 8 module vibenews.vibenews; 9 10 public import vibenews.controller : Article; 11 public import vibe.data.json; 12 public import vibe.mail.smtp : SMTPClientSettings; 13 14 import antispam.antispam; 15 16 17 class VibeNewsSettings { 18 // host name used for self-referencing links 19 string hostName = "localhost"; 20 21 // title of the web forum 22 string title = "VibeNews Forum"; 23 24 // search engine description of the forum 25 string description = "VibeNews based discussion forum with news reader support"; 26 27 ushort nntpPort = 119; 28 ushort nntpSSLPort = 563; 29 deprecated @property ref inout(ushort) nntpSslPort() inout { return nntpSSLPort; } 30 ushort webPort = 80; 31 ushort adminPort = 9009; 32 string databaseName = "vibenews"; 33 string sslCertFile; 34 string sslKeyFile; 35 string[] webBindAddresses; 36 string[] adminBindAddresses; 37 38 SMTPClientSettings mailSettings; 39 40 bool requireSSL = false; 41 deprecated @property ref inout(bool) requireSsl() inout { return requireSSL; } 42 bool requireAccountValidation = false; 43 44 // enables a google site-search box in the top-right corner of the web forum 45 bool googleSearch = false; 46 bool showOverviewAvatars = true; 47 bool showLastPostAvatars = false; 48 49 SpamFilter[] spamFilters; 50 51 this() 52 { 53 import vibe.http.server : HTTPServerSettings; 54 auto defaultBindAddresses = (new HTTPServerSettings).bindAddresses; 55 webBindAddresses = defaultBindAddresses; 56 adminBindAddresses = defaultBindAddresses; 57 } 58 59 void parseSettings(Json json) 60 { 61 import std.conv; 62 63 if( auto pv = "nntpPort" in json ) nntpPort = pv.get!long.to!short; 64 if( auto pv = "nntpSslPort" in json ) nntpSSLPort = pv.get!long.to!short; // deprecated 65 if( auto pv = "nntpSSLPort" in json ) nntpSSLPort = pv.get!long.to!short; 66 if( auto pv = "webPort" in json ) webPort = pv.get!long.to!short; 67 if( auto pv = "adminPort" in json ) adminPort = pv.get!long.to!short; 68 if( auto pv = "host" in json ) hostName = pv.get!string; 69 if( auto pv = "title" in json ) title = pv.get!string; 70 if( auto pv = "description" in json ) description = pv.get!string; 71 if( auto pv = "sslCertFile" in json ) sslCertFile = pv.get!string; 72 if( auto pv = "sslKeyFile" in json ) sslKeyFile = pv.get!string; 73 if (auto pv = "requireSSL" in json) requireSSL = pv.get!bool; 74 if (auto pv = "requireAccountValidation" in json) requireAccountValidation = pv.get!bool; 75 if( auto pv = "googleSearch" in json ) googleSearch = pv.get!bool; 76 if (auto pv = "showOverviewAvatars"in json) showOverviewAvatars = pv.get!bool; 77 if (auto pv = "showLastPostAvatars"in json) showLastPostAvatars = pv.get!bool; 78 if( auto psf = "spamfilters" in json ){ 79 foreach( string key, value; *psf ){ 80 foreach( flt; spamFilters ) 81 if( flt.id == key ) 82 flt.applySettings(value); 83 } 84 } 85 if( auto pa = "webBindAddresses" in json ){ 86 webBindAddresses = []; 87 foreach( address; *pa ) 88 webBindAddresses ~= address.get!string; 89 } 90 if( auto pa = "adminBindAddresses" in json ){ 91 adminBindAddresses = []; 92 foreach( address; *pa ) 93 adminBindAddresses ~= address.get!string; 94 } 95 } 96 } 97