X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=scripts%2Fxmppdaemon.php;h=0f98becdac510860f497b9055c94bb97104e50a9;hb=6a40ba776477ec6e70a523fd3c5a4122a72c3208;hp=0ce2f2a28008397867de795afd36d1b0cf943cea;hpb=77c5aecaf5764ad0bfc6f95e5320def61d859c37;p=quix0rs-gnu-social.git diff --git a/scripts/xmppdaemon.php b/scripts/xmppdaemon.php index 0ce2f2a280..0f98becdac 100755 --- a/scripts/xmppdaemon.php +++ b/scripts/xmppdaemon.php @@ -2,7 +2,7 @@ 2) ? $argv[2] : null; +$path = ($argc > 3) ? $argv[3] : null; + require_once(INSTALLDIR . '/lib/common.php'); require_once(INSTALLDIR . '/lib/jabber.php'); require_once(INSTALLDIR . '/lib/daemon.php'); @@ -39,7 +44,6 @@ set_error_handler('common_error_handler'); class XMPPDaemon extends Daemon { - function XMPPDaemon($resource=null) { static $attrs = array('server', 'port', 'user', 'password', 'host'); @@ -152,11 +156,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 +254,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;