diff options
author | Tobias Diekershoff <tobias.diekershoff@gmx.net> | 2009-04-18 19:00:20 +0200 |
---|---|---|
committer | Tobias Diekershoff <tobias.diekershoff@gmx.net> | 2009-04-18 19:00:20 +0200 |
commit | 7196410bb0398c15fbab767a9b7cedc513e6520b (patch) | |
tree | a23e3d3447040e1bdebae3a82b6380625c6bdff9 /scripts/xmppdaemon.php | |
parent | 4277a6818c6ac66158dfba3b94bdc1b2eb06b594 (diff) |
shortening links in notices from XMPP
This patch enables shortening of links, that where send from XMPP.
The problem was, that in util.php common_current_user() is not
finding the user account from which is posted, so the service to
shorten is not known, so no shortening at all...
This patch cleans up the xmppdaemon a little bit and hard codes ur1.ca
as shortening service _if_ the user is not set. Ugly but working.
Diffstat (limited to 'scripts/xmppdaemon.php')
-rwxr-xr-x | scripts/xmppdaemon.php | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/scripts/xmppdaemon.php b/scripts/xmppdaemon.php index ef3f8c63d..5711f715d 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; |