fixed hard coded twitter char limit

This commit is contained in:
vinz 2017-11-08 22:50:00 +01:00
parent 250221ff7f
commit 5af96d3ec7
1 changed files with 3 additions and 3 deletions

View File

@ -401,11 +401,11 @@ function format_status($notice)
$statusWithoutLinks = preg_replace('`((http|https|ftp)://[^\s<]+[^\s<\.)])`i', '', $statustxt);
$statusLength = mb_strlen($statusWithoutLinks) + $numberOfLinks * 23;
// Twitter still has a 140-char hardcoded max.
if ($statusLength > 140) {
// Twitter raised it but still has a 280-char hardcoded max.
if ($statusLength > 280) {
$noticeUrl = common_shorten_url($notice->getUrl());
// each link uses 23 chars on twitter + 3 for the ' … ' => 26
$statustxt = mb_substr($statustxt, 0, 140 - 26) . ' … ' . $noticeUrl;
$statustxt = mb_substr($statustxt, 0, 280 - 26) . ' … ' . $noticeUrl;
}
return $statustxt;