* Finished syndie address auto-import. If syndie.importAddresses=true in syndie.config, then new addresses will automatically be imported to the router's petname db. If importaddresses=true in a user's config file, then new addresses will automatically be imported to that users pername db, when they're logged in.
This commit is contained in:
@ -341,7 +341,8 @@ public class BlogManager {
|
||||
public String getDefaultProxyHost() { return _context.getProperty("syndie.defaultProxyHost", ""); }
|
||||
public String getDefaultProxyPort() { return _context.getProperty("syndie.defaultProxyPort", ""); }
|
||||
public int getUpdateDelay() { return Integer.parseInt(_context.getProperty("syndie.updateDelay", "12")); }
|
||||
public String[] getUpdateArchives() { return _context.getProperty("syndie.updateArchives", "").split(","); }
|
||||
public String[] getUpdateArchives() { return _context.getProperty("syndie.updateArchives", "").split(","); }
|
||||
public boolean getImportAddresses() { return _context.getProperty("syndie.importAddresses", "false").equals("true"); }
|
||||
|
||||
public boolean authorizeAdmin(String pass) {
|
||||
if (isSingleUser()) return true;
|
||||
|
@ -40,6 +40,7 @@ public class User {
|
||||
private String _torProxyHost;
|
||||
private int _torProxyPort;
|
||||
private PetNameDB _petnames;
|
||||
private boolean _importAddresses;
|
||||
|
||||
static final String PROP_USERHASH = "__userHash";
|
||||
|
||||
@ -70,6 +71,7 @@ public class User {
|
||||
_lastLogin = -1;
|
||||
_lastMetaEntry = 0;
|
||||
_petnames = new PetNameDB();
|
||||
_importAddresses = false;
|
||||
}
|
||||
|
||||
public boolean getAuthenticated() { return _authenticated; }
|
||||
@ -102,6 +104,7 @@ public class User {
|
||||
public int getTorProxyPort() { return _torProxyPort; }
|
||||
|
||||
public PetNameDB getPetNameDB() { return _petnames; }
|
||||
public boolean getImportAddresses() { return _importAddresses; }
|
||||
|
||||
public void invalidate() {
|
||||
if (_authenticated)
|
||||
@ -197,6 +200,8 @@ public class User {
|
||||
_eepProxyHost = props.getProperty("eepproxyhost");
|
||||
_webProxyHost = props.getProperty("webproxyhost");
|
||||
_torProxyHost = props.getProperty("torproxyhost");
|
||||
String importadr = props.getProperty("importaddresses", "false");
|
||||
_importAddresses = (importadr != null) && (importadr.equals("true"));
|
||||
}
|
||||
|
||||
private int getInt(String val) {
|
||||
@ -218,7 +223,7 @@ public class User {
|
||||
buf.append("showexpanded=" + getShowExpanded() + "\n");
|
||||
buf.append("defaultselector=" + getDefaultSelector() + "\n");
|
||||
buf.append("allowaccessremote=" + _allowAccessRemote + "\n");
|
||||
|
||||
buf.append("importaddresses=" + getImportAddresses() + "\n");
|
||||
buf.append("groups=");
|
||||
Map groups = getBlogGroups();
|
||||
for (Iterator iter = groups.keySet().iterator(); iter.hasNext(); ) {
|
||||
|
@ -102,7 +102,7 @@ public class HTMLPreviewRenderer extends HTMLRenderer {
|
||||
_postBodyBuffer.append(getSpan("summDetailAddr")).append("Addresses:</span>");
|
||||
for (int i = 0; i < _addresses.size(); i++) {
|
||||
Address a = (Address)_addresses.get(i);
|
||||
|
||||
importAddress(a);
|
||||
PetName pn = null;
|
||||
if (_user != null)
|
||||
pn = _user.getPetNameDB().getByLocation(a.location);
|
||||
@ -121,7 +121,6 @@ public class HTMLPreviewRenderer extends HTMLRenderer {
|
||||
_postBodyBuffer.append("protocol=").append(sanitizeTagParam(a.protocol)).append('&');
|
||||
_postBodyBuffer.append("\">").append(sanitizeString(a.name)).append("</a>");
|
||||
}
|
||||
importAddress(a);
|
||||
}
|
||||
_postBodyBuffer.append("<br />\n");
|
||||
}
|
||||
|
@ -443,7 +443,16 @@ public class HTMLRenderer extends EventReceiverImpl {
|
||||
}
|
||||
|
||||
public void importAddress(Address a) {
|
||||
if (I2PAppContext.getGlobalContext().getProperty("syndie.addressExport", "false").equalsIgnoreCase("true")
|
||||
if (_user != null && _user.getImportAddresses() && !_user.getPetNameDB().containsName(a.name)) {
|
||||
PetName pn = new PetName(a.name, a.schema, a.protocol, a.location);
|
||||
_user.getPetNameDB().add(pn);
|
||||
try {
|
||||
_user.getPetNameDB().store(_user.getAddressbookLocation());
|
||||
} catch (IOException ioe) {
|
||||
//ignore
|
||||
}
|
||||
}
|
||||
if (BlogManager.instance().getImportAddresses()
|
||||
&& I2PAppContext.getGlobalContext().namingService().lookup(a.name) == null
|
||||
&& a.schema.equalsIgnoreCase("i2p")) {
|
||||
PetName pn = new PetName(a.name, a.schema, a.protocol, a.location);
|
||||
@ -630,7 +639,7 @@ public class HTMLRenderer extends EventReceiverImpl {
|
||||
_postBodyBuffer.append(getSpan("summDetailAddr")).append("Addresses:</span>");
|
||||
for (int i = 0; i < _addresses.size(); i++) {
|
||||
Address a = (Address)_addresses.get(i);
|
||||
|
||||
importAddress(a);
|
||||
PetName pn = null;
|
||||
if (_user != null)
|
||||
pn = _user.getPetNameDB().getByLocation(a.location);
|
||||
@ -649,7 +658,6 @@ public class HTMLRenderer extends EventReceiverImpl {
|
||||
_postBodyBuffer.append("protocol=").append(sanitizeTagParam(a.protocol)).append('&');
|
||||
_postBodyBuffer.append("\">").append(sanitizeString(a.name)).append("</a>");
|
||||
}
|
||||
importAddress(a);
|
||||
}
|
||||
_postBodyBuffer.append("<br />\n");
|
||||
}
|
||||
|
Reference in New Issue
Block a user