summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2010-01-05 15:04:08 -0800
committerBrion Vibber <brion@pobox.com>2010-01-05 16:11:02 -0800
commiteb22d2d2401293ec87e9fa2c2e7fb053d9780dfd (patch)
treeffd464148a5704fe008e46160d86c0a419687b0c /classes
parent7491274c0eb1317203ed39a6ff2a96acb6c8ed78 (diff)
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.
Diffstat (limited to 'classes')
-rw-r--r--classes/Notice.php13
1 files changed, 11 insertions, 2 deletions
diff --git a/classes/Notice.php b/classes/Notice.php
index 93e94230d..6d75cbcad 100644
--- a/classes/Notice.php
+++ b/classes/Notice.php
@@ -1366,12 +1366,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));
}