summaryrefslogtreecommitdiff
path: root/actions
diff options
context:
space:
mode:
authormillette <millette@controlyourself.ca>2008-11-28 16:01:14 -0500
committermillette <millette@controlyourself.ca>2008-11-28 16:01:14 -0500
commitce0883330306ccb9bd50aef4d7963351284bd698 (patch)
tree48797bd1dac83f1dd08e39a77f11540f53bed249 /actions
parent4fca9960cd5388ff2a12472b956e2504a5af7549 (diff)
shorten urls for posts > 140 chars only, from anywhere. Only show long urls in title attributes for links we shortened ourselves.
darcs-hash:20081128210114-099f7-4e4cde0a983c2ac6d41efb59b46cb7dbf45dc7a6.gz
Diffstat (limited to 'actions')
-rw-r--r--actions/newmessage.php9
-rw-r--r--actions/newnotice.php10
-rw-r--r--actions/postnotice.php12
-rw-r--r--actions/twitapidirect_messages.php4
-rw-r--r--actions/twitapistatuses.php6
5 files changed, 19 insertions, 22 deletions
diff --git a/actions/newmessage.php b/actions/newmessage.php
index d4e289465..67695210e 100644
--- a/actions/newmessage.php
+++ b/actions/newmessage.php
@@ -51,13 +51,12 @@ class NewmessageAction extends Action {
if (!$content) {
$this->show_form(_('No content!'));
return;
-// } else if (mb_strlen($content) > 140) {
} else {
- $content = common_shorten_links($content);
+ $content_shortened = common_shorten_links($content);
- if (mb_strlen($content) > 140) {
- common_debug("Content = '$content'", __FILE__);
- common_debug("mb_strlen(\$content) = " . mb_strlen($content), __FILE__);
+ if (mb_strlen($content_shortened) > 140) {
+ common_debug("Content = '$content_shortened'", __FILE__);
+ common_debug("mb_strlen(\$content) = " . mb_strlen($content_shortened), __FILE__);
$this->show_form(_('That\'s too long. Max message size is 140 chars.'));
return;
}
diff --git a/actions/newnotice.php b/actions/newnotice.php
index a79d0a1a2..932099c60 100644
--- a/actions/newnotice.php
+++ b/actions/newnotice.php
@@ -51,11 +51,11 @@ class NewnoticeAction extends Action {
$this->show_form(_('No content!'));
return;
} else {
- $content = common_shorten_links($content);
+ $content_shortened = common_shorten_links($content);
- if (mb_strlen($content) > 140) {
- common_debug("Content = '$content'", __FILE__);
- common_debug("mb_strlen(\$content) = " . mb_strlen($content), __FILE__);
+ if (mb_strlen($content_shortened) > 140) {
+ common_debug("Content = '$content_shortened'", __FILE__);
+ common_debug("mb_strlen(\$content) = " . mb_strlen($content_shortened), __FILE__);
$this->show_form(_('That\'s too long. Max notice size is 140 chars.'));
return;
}
@@ -63,7 +63,7 @@ class NewnoticeAction extends Action {
$inter = new CommandInterpreter();
- $cmd = $inter->handle_command($user, $content);
+ $cmd = $inter->handle_command($user, $content_shortened);
if ($cmd) {
$cmd->execute(new WebChannel());
diff --git a/actions/postnotice.php b/actions/postnotice.php
index 243aa3163..243081f12 100644
--- a/actions/postnotice.php
+++ b/actions/postnotice.php
@@ -58,13 +58,11 @@ class PostnoticeAction extends Action {
return false;
}
$content = $req->get_parameter('omb_notice_content');
-// if (!$content || strlen($content) > 140) {
- $content = common_shorten_links($content);
- if (mb_strlen($content) > 140) {
- common_user_error(_('Invalid notice content'), 400);
- return false;
- }
-// }
+ $content_shortened = common_shorten_links($content);
+ if (mb_strlen($content_shortened) > 140) {
+ common_user_error(_('Invalid notice content'), 400);
+ return false;
+ }
$notice_uri = $req->get_parameter('omb_notice');
if (!Validate::uri($notice_uri) &&
!common_valid_tag($notice_uri)) {
diff --git a/actions/twitapidirect_messages.php b/actions/twitapidirect_messages.php
index a04ae5fa7..a14a9e567 100644
--- a/actions/twitapidirect_messages.php
+++ b/actions/twitapidirect_messages.php
@@ -115,8 +115,8 @@ class Twitapidirect_messagesAction extends TwitterapiAction {
$this->client_error(_('No message text!'), $code = 406, $apidata['content-type']);
// } else if (mb_strlen($status) > 140) {
} else {
- $status = common_shorten_links($status);
- if (mb_strlen($status) > 140) {
+ $content_shortened = common_shorten_links($content);
+ if (mb_strlen($content_shortened) > 140) {
$this->client_error(_('That\'s too long. Max message size is 140 chars.'),
$code = 406, $apidata['content-type']);
return;
diff --git a/actions/twitapistatuses.php b/actions/twitapistatuses.php
index 6d6d5266f..947d21032 100644
--- a/actions/twitapistatuses.php
+++ b/actions/twitapistatuses.php
@@ -255,9 +255,9 @@ class TwitapistatusesAction extends TwitterapiAction {
// } else if (mb_strlen($status) > 140) {
} else {
- $status = common_shorten_links($status);
+ $status_shortened = common_shorten_links($status);
- if (mb_strlen($status) > 140) {
+ if (mb_strlen($status_shortened) > 140) {
// XXX: Twitter truncates anything over 140, flags the status
// as "truncated." Sending this error may screw up some clients
@@ -271,7 +271,7 @@ class TwitapistatusesAction extends TwitterapiAction {
// Check for commands
$inter = new CommandInterpreter();
- $cmd = $inter->handle_command($user, $status);
+ $cmd = $inter->handle_command($user, $status_shortened);
if ($cmd) {