Mercurial > eldonilo > avatar
changeset 23:d63a2784564d
Set a timeout for the vCard stanza.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Sat, 16 Jul 2011 15:29:26 +0200 |
parents | 9e21bd93f79d |
children | e32ac29df320 |
files | avatar.js configuration.js.example |
diffstat | 2 files changed, 13 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/avatar.js +++ b/avatar.js @@ -117,7 +117,7 @@ if (config.useGravatar) method: 'GET' }; - util.log('No XMPP avatar, falling back to Gravatar for ' + to + '.'); + util.log('No XMPP avatar or timeout, falling back to Gravatar for ' + to + '.'); var r = http.request(options, function(r) { if (r.statusCode != 200) @@ -245,6 +245,7 @@ var getVCard = function(jid, res) { .up(); conn.send(toSend); + setTimeout(noAvatar, config.timeout, res, jid, 'Error: XMPP timeout.'); sent[id] = res; }
--- a/configuration.js.example +++ b/configuration.js.example @@ -38,14 +38,14 @@ config.webPort = 8032; // Directory for the cache of the images. config.directory = 'data'; -// When true, assume that the TYPE of the avatar is image/png if not -// specified. Warning: it doesn’t follow the spec and is only a -// workaround for buggy clients. -config.guessType = false; - // Time after which the avatar will be retrieved again, in seconds. config.expire = 24*60*60; +// Time to wait for a response to a stanza, in milliseconds. This is +// needed for inexistent domain because with some XMPP servers, the +// default is to wait one minute. +config.timeout = 1000; + // Allowed extensions, associated with their MIME type. config.extensions = { png: 'image/png', @@ -58,8 +58,13 @@ config.extensions = { // a SVG image will be displayed. //config.defaultImage = 'http://example.org/default.svg'; +// When true, assume that the TYPE of the avatar is image/png if not +// specified. Warning: it doesn’t follow the spec and is only a +// workaround for buggy clients. +config.guessType = false; + // Try Gravatar if there is a problem during XMPP avatar retrieving. -//config.useGravatar = false; +config.useGravatar = false; // Prints XMPP stanzas config.debug = false;