diff options
author | Evan Prodromou <evan@controlyourself.ca> | 2009-05-25 22:47:23 -0400 |
---|---|---|
committer | Evan Prodromou <evan@controlyourself.ca> | 2009-05-25 22:47:23 -0400 |
commit | 76aa85fe5ef408cecf7c40c0c56d58ff9ac9fcbb (patch) | |
tree | f2bd52d08e421f934bc8466ab1ecb4facbbcc6a5 /scripts/xmppdaemon.php | |
parent | b140bcdee4b1f4c8f2f34a89a9c5c51e7ecfe826 (diff) | |
parent | 68d90bcab04713d53cf3731d45729a617e68a2fa (diff) |
Merge branch '0.8.x' into stats
Conflicts:
README
Diffstat (limited to 'scripts/xmppdaemon.php')
-rwxr-xr-x | scripts/xmppdaemon.php | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/scripts/xmppdaemon.php b/scripts/xmppdaemon.php index ef3f8c63d..b79fa1b3b 100755 --- a/scripts/xmppdaemon.php +++ b/scripts/xmppdaemon.php @@ -152,11 +152,6 @@ class XMPPDaemon extends Daemon $body = preg_replace('/d[\ ]*('. $to .')[\ ]*/', '', $pl['body']); $this->add_direct($user, $body, $to, $from); } else { - $len = mb_strlen($pl['body']); - if($len > 140) { - $this->from_site($from, 'Message too long - maximum is 140 characters, you sent ' . $len); - return; - } $this->add_notice($user, $pl); } @@ -255,15 +250,13 @@ class XMPPDaemon extends Daemon function add_notice(&$user, &$pl) { $body = trim($pl['body']); - $content_shortened = common_shorten_link($body); + $content_shortened = common_shorten_links($body); if (mb_strlen($content_shortened) > 140) { - $content = trim(mb_substr($body, 0, 140)); - $content_shortened = common_shorten_link($content); - } - else { - $content = $body; + $from = jabber_normalize_jid($pl['from']); + $this->from_site($from, "Message too long - maximum is 140 characters, you sent ".mb_strlen($content_shortened)); + return; } - $notice = Notice::saveNew($user->id, $content, 'xmpp'); + $notice = Notice::saveNew($user->id, $content_shortened, 'xmpp'); if (is_string($notice)) { $this->log(LOG_ERR, $notice); return; @@ -321,6 +314,13 @@ class XMPPDaemon extends Daemon } } +// Abort immediately if xmpp is not enabled, otherwise the daemon chews up +// lots of CPU trying to connect to unconfigured servers +if (common_config('xmpp','enabled')==false) { + print "Aborting daemon - xmpp is disabled\n"; + exit(); +} + ini_set("max_execution_time", "0"); ini_set("max_input_time", "0"); set_time_limit(0); |