From: Brion Vibber Date: Tue, 5 Jan 2010 23:04:08 +0000 (-0800) Subject: Ticket 2135: trim overlong repeats with ellipsis rather than failing. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=92154969029e15673b84f5cc228099f2f5c1b942;p=quix0rs-gnu-social.git Ticket 2135: trim overlong repeats with ellipsis rather than failing. In web interface and retweet/repeat API we show the original untrimmed text, but some back-compat API messages will still show the trimmed 'RT' version. This matches Twitter's behavior on overlong retweets, though we're outputting the RT version in more API results than they do. --- diff --git a/classes/Notice.php b/classes/Notice.php index e8bc509a68..299ed696c1 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -1356,12 +1356,21 @@ class Notice extends Memcached_DataObject { $author = Profile::staticGet('id', $this->profile_id); - // FIXME: truncate on long repeats...? - $content = sprintf(_('RT @%1$s %2$s'), $author->nickname, $this->content); + $maxlen = common_config('site', 'textlimit'); + if (mb_strlen($content) > $maxlen) { + // Web interface and current Twitter API clients will + // pull the original notice's text, but some older + // clients and RSS/Atom feeds will see this trimmed text. + // + // Unfortunately this is likely to lose tags or URLs + // at the end of long notices. + $content = mb_substr($content, 0, $maxlen - 4) . ' ...'; + } + return self::saveNew($repeater_id, $content, $source, array('repeat_of' => $this->id)); }